narrator Posted March 25, 2011 Share Posted March 25, 2011 Hi,On my page, it first obtains the current folder name for use as a variable:<%Dim fs,fo,catSet fs=Server.CreateObject("Scripting.FileSystemObject")Set fo=fs.GetFolder(server.MapPath("."))cat=fo.nameset fo=nothingset fs=nothing%>It then correctly uses the "cat" (category) variable at the top of the page within a heading.A little lower, another routine chooses between FileExist else read in another file:<%Set fs=Server.CreateObject("Scripting.FileSystemObject")If (fs.FileExists(Server.MapPath("topleft.inc")))=true ThenSet f=fs.OpenTextFile(Server.MapPath("topleft.inc"), 1)Response.Write(f.ReadAll)f.CloseElseSet f=fs.OpenTextFile(Server.MapPath("../inc/topleft.inc"), 1)Response.Write(f.ReadAll)f.CloseEnd IfSet f=Nothingset fs=nothing%>Both alternate "topleft.inc" files make use of the "cat" variable as a heading. "<%=cat%>" but when it reads either file into the page, it prints that code instead of the variable. I can't work out why.Can someone advise why the above choose code is knocking out this variable?Any thoughts how to resolve it?Thanks Link to comment Share on other sites More sharing options...
narrator Posted March 25, 2011 Author Share Posted March 25, 2011 deleted my reply.. thought i figured it out but hadn't..ran into "include" precedence.. sigh2nd edit:Thinking it through.. is it because at that point it is already executing the asp code and can't read in the cat code and execute it at the same time? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 28, 2011 Share Posted March 28, 2011 Opening a file and printing the text is not the same as executing the code. You can use a regular include to include the file and have the code in it executed.http://www.w3schools.com/asp/asp_incfiles.asp Link to comment Share on other sites More sharing options...
narrator Posted March 30, 2011 Author Share Posted March 30, 2011 Opening a file and printing the text is not the same as executing the code. You can use a regular include to include the file and have the code in it executed.http://www.w3schools.com/asp/asp_incfiles.asp Thanks just.. as I said, I ran into include precedence. if existinclude file containing scriptelseend ifFortunately the top part of the include contained the script, so I just pulled that out and set it into the default file so it executes separate to include. I can see how precedence can do your head in.. lol. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.