Creating an Active User-De￿ned Function

The ACTDEF command creates a user-de￿ned function that operates like an active function. Active functions have the following characteristics:

￿Their current value is displayed in the active-function readout.

￿Their value can be changed with front-panel keys.

￿Their value is expressed as a variable for operations with other OSA functions. For example, if ACTDEF creates a function called XXXX, the variable XXXX can be used wherever prede￿ned variable appears in the syntax charts.

Like the FUNCDEF command, ACTDEF consolidates a series of OSA commands into one function and gives it a name. Executing the function name is the same as executing the series of commands contained in the function.

In the following example, the function is assigned to a 4USER5 key. Pressing the key executes the function. Active user-de￿ned functions can also be executed with other functions, or used in computer programs as you use any other OSA command.

60

OUTPUT 723;"ACTDEF

NEW_SPAN,10,NM";

Begin de￿nition

of NEW

 

 

SPAN, that

 

 

 

 

has an initial value of 10 nm.

70

OUTPUT 723;"@MPY SP,2,NEW_SPAN@"

Multiply NEW

 

SPAN by 2, then set

 

 

 

 

span equal to the product. End de￿-

 

 

 

nition and store

the function.

80

OUTPUT 723;"KEYDEF 3,NEW_SPAN;"

Assign function

to a 4USER5 key.

90

OUTPUT 723;"VARDEF

YY,0;"

Create a user-de￿ned variable, YY.

100 OUTPUT 723;"MOV YY,NEW_SPAN;"

Set variable equal to NEW

 

SPAN.

 

110 OUTPUT 723;"NEW_SPAN?"

Return value of NEW

 

SPAN to computer .

 

120 ENTER 723;N

 

Assign value to computer variable .

In addition to creating a user-de￿ned function, the ACTDEF command creates a temporary variable that has the same name as the user-de￿ned function. The variable can be used for operations as you would use any prede￿ned variable. The variable exists as long as the user-de￿ned function is stored in internal memory. Do not use existing user-de￿ned function names or reserved words as labels for user-de￿ned functions.

When using a string- or block-data ￿eld to transfer a command de￿nition, be sure to use compatible terminators. Also, any block-￿eld commands within the list must be the absolute type (A# block).

6-8