Jump to content

code conflict affecting variable?


Recommended Posts

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 post
Share on other sites

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 by narrator
Link to post
Share on other sites
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...