<!#includefile = "filename.asp" - >マクロ制限により、ファイルが存在する必要があり、事前コンパイルされます(条件が以前に適用されたかどうかに関係なく)
多くの場合、そのような要件があります。各個人のさまざまな設定など、さまざまなニーズに応じてさまざまなファイルを含める必要があるため、要件はファイルを動的に含めることです。
コードは次のとおりです。
コードコピーは次のとおりです。
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 =何もない
setre = newRegexp
re.pattern = "^/s*="
Aspend = 1
ASPSTART = Instr(Aspend、content、 "<%")+2
dowhileaspstart> aspend+1
Response.Writemid(content、aspend、aspstart-aspend-2)
aspend = strunt(aspstart、content、 "%/>")+2
execute(re.replace(Mid(content、aspstart、aspend-aspstart-2)、 "respons.write"))
ASPSTART = Instr(Aspend、content、 "<%")+2
ループ
respons.writemid(content、aspend)
setre =何もない
エンド機能
使用例:
コードコピーは次のとおりです。
含める( "youinc.asp")