Using global variables.

Purpose

When ProWesS is installed, it automatically installs a things called "Globals variables", which can be used by the 'C' programs to store some global variables, such as the directory from which you booted ProWesS. There is no reason why this couldn't also be used from SBasic, so several keywords exist, to SET/GET/DELete a determined global variable, or to get the FiRST or NEXT ones. The keywords are appropriately called GSET, GGET, GDEL, GFRST and GNEXT.

Global variables have a name, and a value. The name is the name of the variable itself, just like an SBasic variable, and the value is the content of this. For example, the global variable PWSDIR contains the name of the directory from which you booted ProWesS, e.g. flp1_, or win1_pw_, or whatever. The name of the variable is case sensitive: PWSDIR is not the same as pwsdir.

Syntax

Example


         GSET "A NEW VARIABLE","This is my value"          
this sets the new variable.


         PRINT GGET ("A NEW VARIABLE")
will print 'This is my value'. But:

         PRINT GGET ("a new variable") 
will print -- since this variable was not found.

The following small program prints all of the global variables in your system.

         gname$=""
         gvalue$=""
         GFRST gname$,gvalue$
         IF gname$='--'
           PRINT 'There is NO global variable!'
           STOP
         ENDIF
         PRINT gname$; " = ";gvalue$
         REPeat loop
           GNEXT gname$,gvalue$
           IF gname$='--':EXIT loop
           PRINT gname$;" = ";gvalue$
         END REP loop


You can see how we leave gname$ alone, so that, on each call to GNEXT, it still contains the name of the last variable, enabling us to get the one after that, i.e. the next one.
PROGS, Professional & Graphical Software
last edited 1996 Aug 06 (wl)