【发布时间】:2011-08-19 14:29:39
【问题描述】:
我正在研究动态的“包含”方法,最终找到了一个使用 VBScript 的 Execute 函数的解决方案。这对我来说非常有效,但我注意到 Execute 执行代码,但此代码不能声明变量或函数之类的东西:
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Server.MapPath(strFile)) Then
Set objFile = objFSO.OpenTextFile(Server.MapPath(strFile), 1)
strSource = objFile.ReadAll
// Filter out comment- and ASP tags cos they return errors
strSource = Replace(strSource, Chr(60)&Chr(37), "")
strSource = Replace(strSource, Chr(37)&Chr(62), "")
objRegExp.Pattern = "^[ \t]*(//¦\')[\s\S]*?$"
strSource = objRegExp.Replace(strSource, "")
// Execute the code
On Error Resume Next
Execute strSource 'etc........
end if
为什么?谢谢!
【问题讨论】:
标签: vbscript asp-classic execute