UNASSIGNED()

UNASSIGNED()

Top  Previous  Next

 

The UNASSIGNED() function tests whether a variable is unassigned.

 

 

Format

 

UNASSIGNED(var)

 

where

 

varis the variable to be tested.

 

 

All QMBasic variables except those in common blocks are initially unassigned. Any attempt to use the contents of the variable in an expression would cause a run time error until such time as a value has been stored in it. The UNASSIGNED() function allows a program to test whether a variable is unassigned, returning True if it is unassigned or False if it is assigned.

 

 

Example

 

SUBROUTINE VALIDATE(ACCOUNT.CODE, ERROR)

BEGIN CASE

  CASE UNASSIGNED(ACCOUNT.CODE)

     ERROR = 1

  CASE ACCOUNT.CODE MATCHES '3N-5N'

     ERROR = 2

  ...etc...

  CASE 1

     ERROR = 0

END CASE

RETURN

END

 

This program fragment validates an account code. The use of the UNASSIGNED() function prevents an abort if the variable has not been assigned.

 

 

See also:

ASSIGNED()