+ -
当前位置:首页 → 问答吧 → 请问这段代码的大体意思 尤其是 objectfile.write 那些句子

请问这段代码的大体意思 尤其是 objectfile.write 那些句子

时间:2011-06-09

来源:互联网

objInstalled=IsObjectInstalled("Scripting.FileSystemObject")

if not objInstalled then
Response.Write "<strong><font color='#FF0000'>对不起,服务器不支持 FSO(Scripting.FileSystemObject)!您不能试用该功能,请直接修改 'config.asp' 文件中的内容。</font></strong>"
Response.End
end if

set fso=Server.CreateObject("Scripting.FileSystemObject")
set objectfile=fso.CreateTextFile(Server.mappath("config.asp"),true)
objectfile.write "<" & "%" & vbcrlf
objectfile.write "Const blackleach=" & chr(34) & trim(request("blacklist")) & chr(34) & vbcrlf
objectfile.write "Const whiteleach=" & chr(34) & trim(request("whitelist")) & chr(34) & vbcrlf
objectfile.write "Const subjectleach=" & chr(34) & trim(request("subject")) & chr(34)& vbcrlf
objectfile.write "Const bayesleach=" & chr(34) & trim(request("bayes"))& chr(34) & vbcrlf
objectfile.write "%" & ">"
objectfile.close
set objectfile=nothing
set fso=nothing
Response.Write ("保存信息成功!")

Response.End()

作者: weiwei35808   发布时间: 2011-06-09

这个函数楼主应该知道什么意思了,之前我已经回复过了。这里就是正式调用那个函数了

if not objInstalled then
Response.Write "<strong><font color='#FF0000'>对不起,服务器不支持 FSO(Scripting.FileSystemObject)!您不能试用该功能,请直接修改 'config.asp' 文件中的内容。</font></strong>"
Response.End
end if

这里就是如果服务器不支持FSO组件,就报错,然后退出程序执行。

set fso=Server.CreateObject("Scripting.FileSystemObject")
set objectfile=fso.CreateTextFile(Server.mappath("config.asp"),true)
objectfile.write "<" & "%" & vbcrlf
objectfile.write "Const blackleach=" & chr(34) & trim(request("blacklist")) & chr(34) & vbcrlf
objectfile.write "Const whiteleach=" & chr(34) & trim(request("whitelist")) & chr(34) & vbcrlf
objectfile.write "Const subjectleach=" & chr(34) & trim(request("subject")) & chr(34)& vbcrlf
objectfile.write "Const bayesleach=" & chr(34) & trim(request("bayes"))& chr(34) & vbcrlf
objectfile.write "%" & ">"
objectfile.close
set objectfile=nothing
set fso=nothing
Response.Write ("保存信息成功!")

这里就是在服务器当前目录下创建config.asp
然后write就是在里面写下内容
定义了4个常量
blackleach,whiteleach,subjectleach,bayesleach
他们的值分别是上一个页面或者表单传过来的值trim(request("blacklist"))

参考http://www.w3school.com.cn/asp/met_write.asp

作者: tcwsyt   发布时间: 2011-06-09

chr(34)是双引号
vbcrlf是换行。
总的来说就是设置4个常量,这4个常量是从上个页面传过来的

作者: tcwsyt   发布时间: 2011-06-09

然后把这4个常量保存在config.asp里面,如果已经存在了config.asp就用新的覆盖。

作者: tcwsyt   发布时间: 2011-06-09