Skip to main content

Assigned

Assigned (Statement)​

Format​

assigned(Variable)
assigned(Array_Variable[i])
assigned(Array_Variable[row, col])
assigned(Map_Variable[key])

returns boolean_expression

Description​

Returns true if this variable, array element, or map element has been assigned a value, and false if it has not or if Unassign has cleared it. It never stops the program, so it is the way to check a variable before reading it. For a map it tells whether the key is in the map, as key in map does. An element of an array made with Dim is assigned, because DIM fills it with 0.

Example​

a = 5
print assigned(a)
print assigned(b)
dim c(3)
print assigned(c[1])
unassign c[1]
print assigned(c[1])
map ages
ages["Ann"] = 12
print assigned(ages["Ann"])
print assigned(ages["Bob"])

displays

1
0
1
0
1
0

See Also​

ArrayBase, ArrayLength, Assigned, Dim, Fill, Map, Mat, Redim, TypeOf, Unassign, VariableWatch

History​

2.0.0.0New To Version
2.3.2A map key that is not in the map returns false instead of raising error 126, "Map key has not been assigned a value"