Date:  11/16/2001 11:02:29 AM Msg ID:  000136
From:  FoxWeb Support Thread:  000123
Subject:  Re: Fw_enter.prg
Private VFP memory variables are not preserved between hits on the same channel and definitely not between hits across channels.  Each channel is a separate instance of VFP and there is no way to know which channel will serve the next request.  Variables and objects defined in your scripts will not be available in the next request unless they are defined as public.  You should NEVER use public variables to save user-specific information between hits.  Whenever you declare a variable as public, this variable remains in memory ONLY for that particular channel, even after the request is processed.  This means that:

a) Public variables only persist in the channel they were declared in.  They will not be available if the next request for a particular user is served by a different channel.
b) Public variables are shared by all users on the same channel so they can not be used to maintain state information.

Also, public variables are cleared from a specific channel if a run-time script error occurs.

The only situation where public memory variables can be used is if they contain information that is not specific to a particular user or application.  For example, you should define your objects as public if their startup code takes too long and you do not want to define them at the beginning of every hit.  If you chose to define your objects as public you should make no assumptions about the state of these objects (or even about whether they exist).  Before using the objects your code should first check for their existence (IF TYPE('ObjectName') = 'O') and then, either create them, or re-initialize all properties.

FoxWeb Support Team
support@foxweb.com

Sent by Cas Nuy on 11/16/2001 06:46:27 AM:
I have used a number of Public declarations in my start program. Sofar i have not found that they were lost. Are you saying that I should use the same method for Public variables ?

Cas

Sent by FoxWeb Support on 11/15/2001 07:58:47 PM:
VFP does stay around in the background, but including your setup code in a single top-level script would not work because:

1. Each channel is a separate instance of VFP, so having the code run once in your top-level script would only run the setup code in a single channel.

2. FoxWeb runs some SET commands before each script:
    * SET commands and initialization
    SET ANSI OFF
    SET PATH TO
    SET TALK OFF
    SET NOTIFY OFF
    SET NEAR OFF
    SET EXACT OFF
    SET DELETED ON
    SET SAFETY OFF
    SET ESCAPE OFF
    SET EXCLUSIVE OFF
    SET MEMOWIDTH TO 1024
    SET DEVELOPMENT ON
    SET CLOCK OFF
    SET CURSOR OFF
    SET BELL OFF
    SET BLINK OFF
    SET ECHO OFF
    SET FULLPATH ON
    SET SYSFORMATS ON
    SET CENTURY ON
    SET REPROCESS TO 2 SECONDS
    SET DATE AMERICAN

3. Whenever a script error occurs, the channel is restarted.

It is really not a problem to run your SET commands with every request.  On my desktop computer I can run the above code over 2 thousand times per second.

Now, if there is other initialization code that you would like to optimize, such as instantiation of COM servers or other variables, you should do so in your FW_ENTER.PRG as follows:

IF TYPE('M.HasInitialized') = 'U'
    PUBLIC HasInitialized
    HasInitialized = .T.
    ... Add your initalization code here...
ENDIF

The code inside the IF statement will only get run once per channel.

FoxWeb Support Team
support@foxweb.com

Sent by Alan Harris-Reid on 11/15/2001 01:36:40 PM:
I am using Fw_enter.prg program for 'global' environment setting for each script, and it does things like set the SET commands, data path, etc.  Once a .fwx script has run, are all the settings lost, or do they 'hang' around until the next .fwx script call (as long as Foxweb is not stopped)?  Could I set my environment once in my 'top-level' script (Index.fwx) and have them 'stick-around', or must I regard each .fwx call as a separate VFP session?  Must I regard each channel as a separate VFP session?  Does VFP stay open in the background while Foxweb is loaded?  Would it make any difference if I used the development version of VFP instead of the runtimes?

Many thanks,
Alan