NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Johan de Klerk on August 20, 2026, 03:14:56 AM

Title: In which Procedure and Embed can I put code that will only Run Once
Post by: Johan de Klerk on August 20, 2026, 03:14:56 AM
Hi,

I need to set some p_web.SSV('xx',YY) variables when the Web Server starts.
It must/need run this once and not on any subsequent requests.

The p_web.GSV('xx') will be used in various browses and forms.
It will be treated as some global variables.

I looked and put a lot or Trace statements in various embeds but all of them runs every time some fields, buttons, option or variable is clicked.

Any help would be appreciated.

Regards

Johan de Klerk
Title: Re: In which Procedure and Embed can I put code that will only Run Once
Post by: Jane on August 20, 2026, 11:24:12 AM
What are you trying to do, Johan?

A session value is going to be tied to a particular session ID, so it will only be "global" for that one session.

I use a number of regular global variables in web apps that are set at startup and then read-only thereafter.

If you don't want to use global variables, you can set host values in the web server procedure when it starts (maybe in ThisWindow.init).  (Since pweb does not exist in the web server, you would use s_web.SetHostValue).



Title: Re: In which Procedure and Embed can I put code that will only Run Once
Post by: rjolda on August 20, 2026, 12:45:46 PM
Hi Johan,
Again, I ask the same question that Jane asked.  What are you trying to do?
I am doing some file upload and manipulation and then save.  The code runs several times but I only wanted it to run ONCE.   So, I looked at the stage number for the stuff I wanted to do and found that it would run only ONCE if I limited it to a certain stage - there are equates for the stage numbers in a form. So, looking at the stage number when your code fires might help you limit it to only a certain stage.
Ron
Title: Re: In which Procedure and Embed can I put code that will only Run Once
Post by: rjolda on August 20, 2026, 12:49:31 PM
Johan,
BTW, the procedures are STATELESS - that means that they do not stay open until closed.  The NT code keeps cycling through the procedure and keeps track of the stage it was in when NT engine last went though it.  So, the code keeps cycling through the form until the user closes it with some action.  SO, watch the stage in a trace as your app runs and you will see it cycling through stages.  There is even a check box on forms to write the stage to the trace.
Ron
Title: Re: In which Procedure and Embed can I put code that will only Run Once
Post by: Johan de Klerk on August 20, 2026, 10:19:29 PM
Hi Jane,

Your advice for SetHostValue and GetHostValue works perfect.
Thank you very much.

Regards
Johan de Klerk
Title: Re: In which Procedure and Embed can I put code that will only Run Once
Post by: Johan de Klerk on August 20, 2026, 10:21:44 PM
Hi Ron,

Thanks for you reply.
Your suggestion has helped me sort out another problem in another part of the system I have been battling with.

Regards
Johan de Klerk