View Full Version : Testing for existance of variable


10-24-2004, 05:58 AM
Stating the discount per item while the shopping cart web page builds is reliant on the existance or non-existance of a customer account number variable. If he's been here before, he's got one: no problem. If he hasn't, though, and if he really might not commit the cart for purchase, he doesn't have or need one. How do I test for this? See, eval_valid(acct)=.f. errors out, saying the page can't be built since the variable "acct" doesn't exist. And of course the same occurs when I use acct="". I'd really like to use something like

if exist(acct)
do x
do y
end if



10-24-2004, 07:49 AM

If eval_valid("acct")=.f., then the variable does not exist. Variables in WAS are very different than in a conventional database. For example, most variables only exist within the page. You can have session variables, but they exist only for the session. If the session times out. they are lost. You can now create application variables when you publish, and these work somewhat like global variables. The variable value is written to a text file where it can be retrieved. You can also save a value to a file and then retrieve it for every page, similar to the application variable concept. To access these "variables", they have to be loaded each time the page runs. I believe the application variables are loaded automatically. In any case, you can not access any variable defined in a database.


Edward Larrabee
10-25-2004, 05:22 AM
You can also use cookies. See Using Cookies.