Caché MultiValue Basic Reference
ASSIGNED
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Determines if a variable is assigned.
Synopsis
ASSIGNED(var)
Arguments
var A user variable. If var is not a valid variable name, MVBasic issues a syntax error.
Description
The ASSIGNED function determines whether a user variable is assigned or not assigned. If var is assigned a value, ASSIGNED returns 1. If var is not assigned a value, ASSIGNED returns 0. An assigned value can be a single value or a dynamic array value. ASSIGNED also returns 1 if var is assigned the empty string (""), or is assigned an unassigned variable.
The input var can be a local variable, a global variable, or a process-private global variable. It can be with or without subscripts.
Note:
ASSIGNED should not be used on system variables (@ variables). It always returns 0 for all @ variables, whether or not the @ variable currently has a value.
The UNASSIGNED function is the functional opposite of the ASSIGNED function.
The COMMON statement initializes variables as unassigned in Caché MVBasic. Array variable initialization varies with different MultiValue emulations.
You can use the $KILL statement to unassign variables.
Examples
The following example tests the assignment of several variables. ASSIGNED returns 1 (assigned) for variables a through f. ASSIGNED returns 0 (unassigned) for variable g.
a=123
b="fred"
c=1:@VM:2:@VM:3
d=""
e=NULL
f=g
PRINT ASSIGNED(a)
PRINT ASSIGNED(b)
PRINT ASSIGNED(c)
PRINT ASSIGNED(d)
PRINT ASSIGNED(e)
PRINT ASSIGNED(f)
PRINT ASSIGNED(g)
Note that variable f is considered assigned, even though it is assigned to an unassigned variable.
See Also