DoExecute Function:
Open an ASP file and execute its contents (instead of using an Include or Server.Execute()).
Description:
DoExecute Function opens an ASP file and execute its contents (instead of using an Include or Server.Execute()). The file should contain pure ASP code or the function will error out. The problem using Server.Execute() is that it just executes the code, but you can not use any of the variables or functions within your page that you are executing it.
Syntax:
Call DoExecute(fullASPFilePath)
Example:
<%
Call DoExecute(Server.MapPath("aspfile.asp"))
%>
ASP Source Code:
<%
Function DoExecute(strFilePath) Dim fso Dim stream Dim strFileText Set fso = Server.CreateObject("Scripting.FileSystemObject") Set stream = fso.OpenTextFile(strFilePath) strFileText = stream.ReadAll() stream.Close Set stream = Nothing Set fso = Nothing '--- Remove open and close ASP tags strFileText = Replace(strFileText, "<" & "%", "") strFileText = Replace(strFileText, "%" & ">", "") Execute strFileText End Function
%>
|