narrator 0 Posted March 25, 2011 Report 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 Quote Link to post Share on other sites
narrator 0 Posted March 25, 2011 Author Report Share Posted March 25, 2011 (edited) 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? Edited March 25, 2011 by narrator Quote Link to post Share on other sites
justsomeguy 1,135 Posted March 28, 2011 Report 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 Quote Link to post Share on other sites
narrator 0 Posted March 30, 2011 Author Report 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.