Dynamic incrude file

xiaoxiao2021-03-06  98

The file must be present in the The macro limit must be presented and pre-compiled (regardless of whether the front is conditioned)

There are often such requirements, requiring the number of different files such as the individual people according to different requirements, so it is required to dynamically include files.

code show as below:

Function include (2004322195331.htm) Dim re, content, fso, f, aspStart, aspEnd set fso = CreateObject ( "Scripting.FileSystemObject") set f = fso.OpenTextFile (server.mappath (2004322195331.htm)) content = f. Readall f.close set f = Nothing set fso = nothing set re = new regexp Re.pattern = "^ / s * =" aspend = 1 aspstart = INSTR (Aspend, Content, "<%") 2 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, "<%") 2 Loop Response.write MID (Content, Aspend) Set Re = Nothingend Function

Use example:

Include ("Youinc.asp")

转载请注明原文地址:https://www.9cbs.com/read-104937.html

New Post(0)