existing, existing and valid, existing here, existing here and valid
This function checks if the specified variable is existing.
existing | Retruns true if the variable exists, regardless if declared locally or as a function parameter or globally |
existing here | Returns true if the variable exists and has been defined locally or as a function parameter |
existing and valid | Returns true if the variable exists, regardless if declared locally or as a function parameter or globally, and contains a value of valid type (not void). |
existing here and valid | Returns true if the variable exists and has been defined locally or as a function parameter, and contains a value of valid type (not void). |
In the global variable context (neither a B4P user procedure or function code has been called nor a different B4P sub-program has been started), then
the functions existing here and existing here return true if the variable is a global variable, but not a system variable.
Hint: Use existing here to check if function parameters have been provided in user functions and procedures allowing a variable number of parameters.
Do not use existing as it may provide false results if an equally named global variable is already existing.
Indirect parameter passing is disabled
1
No. | Type | Description |
---|---|---|
1 code |
variable :string |
Variable to check |
Type | Description |
---|---|
boolean | Result true if variable is existing. |
gbl[] = Hello;
table initialize( result, {{ Context, Variable, 'existing()', 'existing here()', 'existing and valid()', 'existing here and valid()' }} );
define procedure ( ho, {{ par, string }} )
{
table append( result, {{ ho, Function parameter, existing (par[]), existing here (par[]),
existing and valid(par[]), existing here and valid(par[]) }} );
table append( result, {{ ho, Unaccessible variable, existing (var[]), existing here (var[]),
existing and valid(var[]), existing here and valid(var[]) }} );
table append( result, {{ ho, Global variable, existing (gbl[]), existing here (gbl[]),
existing and valid(gbl[]), existing here and valid(gbl[]) }} );
table append( result, {{ ho, Valid System variable, existing (runtime settings[crlf]), existing here (runtime settings[ ]),
existing and valid(runtime settings[crlf]), existing here and valid(runtime settings[crlf]) },{''}} );
}
define procedure ( hi )
{
var[] = Ahoi;
table append( result, {{ hi, Function parameter, existing (par[]), existing here (par[]),
existing and valid(par[]), existing here and valid(par[]) }} );
table append( result, {{ hi, Local variable, existing (var[]), existing here (var[]),
existing and valid(var[]), existing here and valid(var[]) }} );
table append( result, {{ hi, Global variable, existing (gbl[]), existing here (gbl[]),
existing and valid(gbl[]), existing here and valid(gbl[]) }} );
table append( result, {{ hi, Valid System variable, existing (runtime settings[crlf]), existing here (runtime settings[ ]),
existing and valid(runtime settings[crlf]), existing here and valid(runtime settings[crlf]) },{''}} );
ho( He );
}
hi;
table append( result, {{ main, Nonexisting variable, existing (var[]), existing here (var[]),
existing and valid(var[]), existing here and valid(var[]) }} );
table append( result, {{ main, Global variable, existing (gbl[]), existing here (gbl[]),
existing and valid(gbl[]), existing here and valid(gbl[]) }} );
table append( result, {{ main, System variable, existing (runtime settings[ ]), existing here (runtime settings[]),
existing and valid(runtime settings[ ]), existing here and valid(runtime settings[]) }} );
table append( result, {{ main, Valid System variable, existing (runtime settings[crlf]), existing here (runtime settings[ ]),
existing and valid(runtime settings[crlf]), existing here and valid(runtime settings[crlf]) }} );
table list( result );
0 : Context | Variable | existing() | existing here() | existing and valid() | existing here and valid()
1 : hi | Function parameter | false | false | false | false
2 : hi | Local variable | true | true | true | true
3 : hi | Global variable | true | false | true | false
4 : hi | Valid System variable | true | false | true | false
5 : | | | | |
6 : ho | Function parameter | true | true | true | true
7 : ho | Unaccessible variable | false | false | false | false
8 : ho | Global variable | true | false | true | false
9 : ho | Valid System variable | true | false | true | false
10 : | | | | |
11 : main | Nonexisting variable | false | false | false | false
12 : main | Global variable | true | true | true | true
13 : main | System variable | true | false | false | false
14 : main | Valid System variable | true | false | true | false