回覆列表
  • 1 # 使用者674626316078

    受 宏限制

    必須存在該檔案並且會預先編譯(不管前面是否加以條件)

    經常有這樣的要求,根據不同的需求要求include不同的檔案

    如各個人的不同設定,所以要求能動態include檔案。

    程式碼如下:

    Function include(filename)

    Dim re,content,fso,f,aspStart,aspEnd

    set fso=CreateObject("Scripting.FileSystemObject")

    set f=fso.OpenTextFile(server.mappath(filename))

    content=f.ReadAll

    f.close

    set f=nothing

    set fso=nothing

    set re=new RegExp

    re.pattern="^\s*="

    aspEnd=1

    aspStart=inStr(aspEnd,content,"

    do while aspStart>aspEnd+1

    Response.write Mid(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,"

    loop

    Response.write Mid(content,aspEnd)

    set re=nothing

    End Function

    使用範例:

    include("youinc.asp")

  • 中秋節和大豐收的關聯?
  • DNF劍魂40~45級應該穿什麼套裝?包括紫裝綠裝?