Date:  04/08/2006 10:48:56 AM Msg ID:  002910
From:  FoxWeb Support Thread:  002903
Subject:  Re: Include FoxWeb Code
My original response still applies.  You will need to rename leftmenu.txt to leftmenu.fwx and include it with the Server.Execute method.

FoxWeb Support Team
support@foxweb.com email

Sent by Joe Goldsmith on 04/07/2006 11:19:14 PM:
I am very sorry for not being accurate in my description. I need to be more clear.
 
I have a number of pages that utilize the same code. Since the maintenance issue is great, I decided to put the code in a text file then use the FoxPro FILE2STR function to import the code into every page. Thus, I only have to make a change to one page to update all pages.
 
The page to import is a collection of HTML and FoxWeb. The problem is that the FoxWeb code will not work. For example:
 
MAIN PAGE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<%
RESPONSE.EXPIRES=0
LOCAL ONE,TWO,THREE
M.ONE=Session.GetVar('gONE')
M.TWO=Session.GetVar('gTWO')
M.THREE=Session.GetVar('gTHREE')
%>
<HTML>
<HEAD>
<TITLE>My TItle</TITLE>
</HEAD>
<BODY>
<TABLE><TR><TD>
Page header
</TD></TR></TABLE>
<TABLE>
  <TR>
    <TD>
      <TABLE>
        <TR>
          <TD>
              <%=FILETOSTR('include/leftmenu.txt)%>
          </TD>
        </TR>
      </TABLE>
    </TD>
    <TD>
        COLUMN 2 Code
    </TD>
  </TR>
</TABLE>
 
The file, include/leftmenu.txt contains a mix of HTML and FoxWeb code. Specifically, there is code to check to see if M.TWO from SETVAR has a value. For example:
 
INCLUDE/LEFTMENU.TXT
<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#0000FF">
  <TR>
    <TD>
      <%IF EMPTY(M.TWO)%>
        <A HREF="doone.fwx" class="a3">Login</A><BR>
      <%ELSE%>
        <A HREF="dotwo.fwx" class="a3">Logout</A><BR>
      <%ENDIF%>
    </TD>
  </TR>
</TABLE>
 
When the code <%=FILETOSTR('include/leftmenu.txt)%> imports the file INCLUDE/LEFTMENU.TXT the code block <%IF EMPTY(M.TWO)%> does not execute. This is the problem I am having so any advice to get this working is helpful.
 
Joe
 
 
Sent by FoxWeb Support on 04/07/2006 07:35:26 AM:
As it is, your "Another Script Inserting File" should send the following output:
 
Name: ContentOfGfname<%Response.Write("Name: "+lcName)%>
 
The 2nd part is the content of include.txt, which is inserted, but not executed.  If you want to execute the code in include.txt, you will need to rename it to include.fwx and call it with Server.Execute:
 
<%
lcName=Session.GetVar('gFNAME')
*Line below prints out the label name and the value of lcName
Response.Write("Name: "+lcName)
Server.Execute('include.fwx')
*Nothing is written but expect "Name: Joe" to be written
%>

FoxWeb Support Team
support@foxweb.com email

Sent by Joe Goldsmith on 04/06/2006 08:06:19 PM:
I have a login script and use SETVAR to carry some information from one page to another. I also have a header script in txt format where I use FILETOSTR to insert the header script. And, the header script has some FoxWeb code. The problem is that the FoxWeb code included header script does not work. I now understand that the txt header script file cannot be compiled so the FoxWeb code does not work when inserted using the FILETOSTR function. Would anyone have an idea as to how to insert a header script wile FoxWeb code into another script? Example:
 
*Login script
*Get user name
<%Session.SetVar("gFNAME","Joe")%>
 
*Include.txt
<%Response.Write("Name: "+lcName)%>
 
Another Script Inserting File
<%
lcName=Session.GetVar('gFNAME')
*Line below prints out the label name and the value of lcName
Response.Write("Name: "+lcName)
 
<%=FILETOSTR('include.txt')%>
*Nothing is written but expect "Name: Joe" to be written
%>
 
Anyone know how to insert a file with FoxWeb Script so that the FoxWeb script in the inserted file works?
 
Joe