SCOPE |
scope = SCOPE( varname AS STRING ) AS INTEGER
Returns the scope of the named variable. Note; the variable name must be passed as a string so that we can check for the existence of a variable otherwise the function will fail during parsing.
The function returns one of these constants
CONST MB_SC_UNKNOWN = 0 CONST MB_SC_GLOBAL_VAR = 1 CONST MB_SC_GLOBAL_CONST = 2 CONST MB_SC_GLOBAL_ARRAY = 3 CONST MB_SC_LOCAL_VAR = 4 CONST MB_SC_LOCAL_ARRAY = 5 CONST MB_SC_ENVIRONMENT = 6 CONST MB_SC_GLOBAL_FUNC = 7 CONST MB_SC_LOCAL_FUNC = 8
Examples:
OPTION MODULE "Scope Tester" OPTION ENVIRONMENT "ENV" "Variable and Function Scope"
$LIBRARY "mybasic2_extlib.dll"
PRINT ENVIRONMENT( "env" ), PRINT "---------------------------",
CONST Constant = 12
PUBLIC global_arr(10) AS REAL PUBLIC global_var AS INTEGER
DIM local_arr(10) AS REAL DIM local_var AS INTEGER
PRINT MODULE;"(constant): ";SCOPE( "constant" ), PRINT MODULE;"(global_arr): ";SCOPE( "global_arr" ), PRINT MODULE;"(global_var): ";SCOPE( "global_var" ), PRINT MODULE;"(env): ";SCOPE( "env" ), PRINT MODULE;"(local_arr): ";SCOPE( "local_arr" ), PRINT MODULE;"(local_var): ";SCOPE( "local_var" ), PRINT MODULE;"(version): ";SCOPE( "version" ), PRINT MODULE;"(REG.write): ";SCOPE( "REG.write" ),
END |