ถูก จำกัด โดย <!#include file = "filename.asp"-> macro
ไฟล์จะต้องมีอยู่และจะถูกคอมไพล์ไว้ล่วงหน้า (ไม่ว่าเงื่อนไขจะถูกนำหน้า) หรือไม่)
มักจะมีข้อกำหนดดังกล่าวรวมถึงไฟล์ที่แตกต่างกันตามข้อกำหนดที่แตกต่างกัน
หากการตั้งค่าของแต่ละคนแตกต่างกันจำเป็นต้องรวมไฟล์แบบไดนามิก
รหัสมีดังนี้:
functioninclude (ชื่อไฟล์)
dimre, เนื้อหา, fso, f, aspstart, aspend
setfso = createObject ("Scripting.filesystemObject")
setf = fso.opentextfile (server.mappath (ชื่อไฟล์)))
content = f.readall
f.close
setf = ไม่มีอะไร
setfso = ไม่มีอะไร
setre = newregexp
re.pattern = "^/s*="
Aspend = 1
ASPSTART = INSTR (ASPEND, เนื้อหา, "<%")+2
Dowhileaspstart> Aspend+1
Response.writemid (เนื้อหา, Aspend, Aspstart-Aspend-2)
ASPEND = Instr (ASPSTART, เนื้อหา, "%/>")+2
ดำเนินการ (re.replace (mid (เนื้อหา, aspstart, aspend-aspstart-2), "response.write")))))))))))))))))))))))))))
ASPSTART = INSTR (ASPEND, เนื้อหา, "<%")+2
วง
Response.writemid (เนื้อหา, Aspend)
setre = ไม่มีอะไร
endfunction
ตัวอย่างการใช้งาน:
รวม ("youinc.asp")