CLEAR

Clear a variable

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
CLEAR variable[, …]

Arguments

variable

One or more variables to be cleared. (a or n)

Discussion

The CLEAR statement initializes one or more variables to blanks or their zero representations.

If variable is alpha, it is cleared to spaces. If variable is numeric, it is cleared to its zero representation. A CLEAR statement can include different data types.

CLEAR also affects object lifetime. Clearing an object is like setting it to ^NULL (and in traditional Synergy reduces the reference count).

Tip

By default, the CLEAR statement clears a record to spaces. If you are using integer variables, group them together in one record, which should be aligned. Cast the record as an integer when you clear it:

.align LONG
record binary_data
    var     ,i4
    intarr  ,[10]i4
proc
    clear ^i(binary_data)

The integer variables contain zero.

If data types are mixed, use INIT instead of CLEAR.

See also

.ALIGN for information about aligning a record.

Examples

In the following example:

record
    avar        ,a1
    dvar        ,3d1
    idvar       ,[15]d2.2
proc
    clear avar, dvar, idvar[ ]
end

the CLEAR statement is functionally equivalent to

avar = " "                      ;blank
dvar(1) = 0
for i from 1 thru 15
  idvar[i] = 0.0