version 3
Undefined (variable) Boolean
Parameter | Type | Description | |
variable | Variable | Variable to test | |
Function result | Boolean | True = Variable is currently undefined | |
False = Variable is currently defined |
Description
Undefined returns True if variable has not been defined, and False if variable has been defined. A variable is defined if a value is assigned to it. A variable is undefined if it does not have a value assigned to it, or if it has been cleared with CLEAR VARIABLE.
If the database has been compiled, the Undefined function returns False for all variables.
Examples
1. Up to version 6, a good way to test if you were running in interpreted mode or in compiled mode was to write:
anyVar:="Hello" CLEAR VARIABLE(anyVar) If (Undefined(anyVar)) ` You are in interpreted mode Else ` You are in compiled mode End if
Starting with version 6, it is more convenient to use the built-in command Compiled application.
2. The following code manages the creation of processes when a menu item for a particular module of your application is chosen. If the process already exists, you bring it to the front; if it does not exist, you start it. To do so, for each module of the application, you maintain an interprocess variable <>PID_... that you initialize in the On Startup database method.
When developing the database, you add new modules. Instead modifying the On Startup database method (to add the initialization of the corresponding <>PID_...) and then reopening the database to reinitialize everything each time you add a module, you use the Undefined command to manage the addition of the new module, on the fly:
` M_ADD_CUSTOMERS global procedure If (Undefined(<>PID_ADD_CUSTOMERS)) ` Takes care of intermediate development stages C_LONGINT(<>PID_ADD_CUSTOMERS) <>PID_ADD_CUSTOMERS:=0 End if If (<>PID_ADD_CUSTOMERS=0) <>PID_ADD_CUSTOMERS:=New process("P_ADD_CUSTOMERS";64*1024;"P_ADD_CUSTOMERS") Else SHOW PROCESS(<>PID_ADD_CUSTOMERS) BRING TO FRONT(<>PID_ADD_CUSTOMERS) End if ` Note: P_ADD_CUSTOMERS, the process master method, sets <>PID_ADD_CUSTOMERS to zero when it ends.
See Also