ASP Dynamic Include File

xiaoxiao2021-03-06  78

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

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.

The code is as follows: <% 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, "<%") 2 do while aspstart> Aspend 1 Response.write MID (Content, Aspend, 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%>

Example of use: include ("Youinc.asp")

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

New Post(0)