PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Webdev Globals
Webdev Globals
Débuté par Peter Hite, 27 mai 2016 20:44 - 6 réponses
Posté le 27 mai 2016 - 20:44
I am new to writing Web apps and am having a hard time getting my head around global variables. I would like to be able to use a couple of global variables to hold states, etc. But every time I submit something to the server (a page refresh, new page, etc.), the project initialization code reinitialized the globals. Is there anyway to set a global and keep it throughout a session, or do I just need to pass those values as parameters to all of my different pages? Thanks
Posté le 27 mai 2016 - 21:17
Hi Peter,

it depends of the type of pages you are using: classic, awp or php

Best regards
Posté le 27 mai 2016 - 21:31
Currently the project site is configured as Dynamic AWP. I have 5 globals defined in project server initialization. That initialization code seems to be recalled each time a page is refreshed,
Posté le 27 mai 2016 - 21:55
Hi

If you use dunamic webdev then your globals are useble the way you discribe. If you use AWP you have to pass the global to the page as a param.

In the calling of the page

pagedisplay( thepageyou call, paramglobal)

In the page that is called add a procedure

PROCEDURE mypage( var is string )

Then use var to get the value of you global

regards
Allard
Posté le 27 mai 2016 - 22:37
Hi,

Thank you Allard. I think I'll pass them as suggested. Hopefully I can use a composite variable to pass them all easily. I changed the project to Dynamic Webdev, put a break in the server init code, and it still calls the reinitialization of the globals. Don't know why - will try above and scratch my head another day on this one.
Posté le 28 mai 2016 - 10:31
Hi Peter,

You can declare an AWP context to store your global variables in AWP mode (server side if you want).
Check ConfigureAWPContext() and DeclareAWPContext() in the help for that.

In the project init code you get the previous values again stored by these same commands.

Best regards,

Peter Holemans
Posté le 31 mai 2016 - 15:00
Hi Peter,

That sounds like the ticket. I'll give it a try - Thanks.