Restricted by <!#includefile="filename.asp"-->macro
The file must exist and will be precompiled (regardless of whether the conditions were preceded)
There are often such requirements, including different files according to different requirements
If the settings of each individual are different, it is required to dynamically include files.
The code is as follows:
Functioninclude(filename)
Dimre, content,fso,f,aspStart,aspEnd
setfso=CreateObject("Scripting.FileSystemObject")
setf=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
setf=nothing
setfso=nothing
setre=newRegExp
re.pattern="^/s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
dowhileaspStart>aspEnd+1
Response.writeMid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%/>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write"))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.writeMid(content,aspEnd)
setre=nothing
EndFunction
Example of usage:
include("youinc.asp")