Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see How to Migrate to InterSystems IRIS, available on the WRC Distributions page (login required).

UNASSIGNED

Determines if a variable is unassigned.

Synopsis

UNASSIGNED(var)

Arguments

var A user variable. If var is not a valid variable name, MVBasic issues a syntax error.

Description

The UNASSIGNED function determines whether a variable is assigned or not assigned. If var is not assigned a value, UNASSIGNED returns 1. If var is assigned a value, UNASSIGNED returns 0. An assigned value can be a single value, a dynamic array value, or the null string.

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:

UNASSIGNED should not be used on system variables (@ variables). It always returns 1 for all @ variables, whether or not the @ variable currently has a value.

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 user variables.

The ASSIGNED function is the functional opposite of the UNASSIGNED function.

Examples

The following example tests the assignment of several variables. UNASSIGNED returns 0 (assigned) for all of these variables:

a=123
b="fred"
c=1:@VM:2:@VM:3
d=""
^a="fruit"
^a(3)="banana"
^||a="ppv"
PRINT UNASSIGNED(a)
PRINT UNASSIGNED(b)
PRINT UNASSIGNED(c)
PRINT UNASSIGNED(d)
PRINT UNASSIGNED(^a)
PRINT UNASSIGNED(^a(3))
PRINT UNASSIGNED(^||a)

See Also

Feedback