<!#includefile = "filename.asp"-> 매크로 제한으로 인해 파일은 존재해야하며 조건이 이전에 적용되었는지 여부에 관계없이 사전 컴파일됩니다.
종종 그러한 요구 사항이 있습니다. 각 개인의 다른 설정과 같은 다른 요구에 따라 다른 파일이 포함되어야하므로 요구 사항에는 파일을 동적으로 포함해야합니다.
코드는 다음과 같습니다.
코드 사본은 다음과 같습니다.
functioninclude (filename)
Dimre, Content, FSO, F, Aspstart, Aspend
setfso = createobject ( "Scripting.FilesyStemObject")
setf = fso.opentextfile (server.mappath (filename))
내용 = F. Readall
f.close
setf = 아무것도
setfso = 아무것도
setre = newRegexp
re.pattern = "^/s*="
aspend = 1
aspstart = inst (Aspend, 컨텐츠, "<%")+2
dowhileaspstart> aspend+1
Response.WriteMid (Content, Aspend, Aspstart-Aspend-2)
aspend = instr (aspstart, 컨텐츠, "%/>")+2
execute (re.replace (MID (Content, AspStart, Aspend-AspStart-2), "response.write"))
aspstart = inst (Aspend, 컨텐츠, "<%")+2
고리
Response.WriteMid (Content, Aspend)
setre = 아무것도
최종 기능 장애
사용의 예 :
코드 사본은 다음과 같습니다.
포함 ( "youinc.asp")