I was looking into dynamic "includes" methods and came down to a solution which uses VBScript's Execute function. This works perfectly for me but I noticed that Execute executes the code but this code cannot declare anything like a variable or function:
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
Why? Thank you!