Statements
Statements are separated by a new line (CR-LF) or a colon (‘:’). The statements of the language are:
Alias
Create an alias for an identifier (not just any identifier). Alias is either a parameter or another alias. ID must be a legal variable name. You cannot create an alias for an array element.
Like Const definitions, Alias definitions can be made to identifiers not yet defined. Circular definitions are not allowed.
Any duplicate definition of an identifier in the same scope is illegal. However, a local definition can shadow a definition from the global scope. Using a single identifier to denote two different objects is NOT allowed (i.e., you cannot have both a label and a variable named all_done).
Like constant, variable, and function declarations, Alias declarations made in the global scope are imported into all functions (including the main function).
Example:
Alias speed = MOTOR.SPEED ‘save some keystrokes
Call
Call sub[(arg1, arg2, ...)]
sub is the name of a subroutine. The current program counter is saved and sub is invoked. When sub finishes (by reaching either an exit sub or end sub statement, control is returned to the statement logically following Call.
A subroutine is essentially a function with no return value. The parameter passing conventions followed by subroutines are the same as those followed by functions.
Cls
This statement transmits 40 line-feed characters (ASCII code = 10) to the serial port. Cls clears the display of the console.
Const
const name = x
Declares symbolic constants to be used instead of numeric values. Forward references are allowed, but circular references are not supported.
'supported const x = y + 2
const y = 17 'unsupported const x = y + 2
const y = x - 2
Like alias, variable, and function declarations, Const declarations made in the global scope are imported into all functions (including the main function).
Dim
Dim var1 [, var2 [...]] as type [NV]
All variables must be declared. Local variables must be declared in the function before use.
The NV specifier is used on a Dim statement in the global scope.
Variables in the global scope are automatically imported into functions and subroutines. Variables in function scope (including inside the main function) are not accessible in other functions.
Arrays cannot be assigned directly.
'This is not allowed dim x(5), y(5) as integer
x = y 'Instead, a loop is needed: dim x(5), y(5), i as integer
for i = 1 to 5 x(i) = y(i) next i
Exit
Exit {{Sub|Function|Interrupt|For|While}]
Exits the closest enclosing context of the specified type. It is a compile-time error to EXIT a construct not currently in scope.
For…Next
For loop_counter = Start_Value To End_Value [Step increment]
...statements...
Next
If step increment is not specified, uses 1 as the step increment. If step increment is positive, continues to the value of End_Value. If step increment is negative, continues to the value of var = limit.
The loop index variable must be a simple identifier, not an array element or a parameter and must be a numeric variable (integer or float).
for var = init to limit step delta stlist next var
Substantially more efficient code is generated if delta is a constant (i.e., the default value of 1 is used, or specified as an expression that is evaluated at compile-time).
Function
Function function-name [(argument-list)] as function-type
...statements...
End Function
On function entry, all local variable strings are “” and all numeric locals are zero (including all elements of local arrays). If the function takes no arguments, omit the argument-list. An empty argument-list is illegal. The value returned from the function is specified by assigning an identifier with the name of the function.
Example:
function cube(x as float) as float cube = x * x * x end function
Arguments are passed by value. Arrays can not be returned by a function. Arrays passed to a function are passed by value.
If the return value is not set, a runtime error condition is generated (caught with ON ERROR).
Array actuals must conform with formals to the extent that they have the same number of dimensions, and EXACTLY the same type. The size of each dimension is available to the function through the use of local constants that are bound on function entry.
Example:
function sum(x(n) as integer) as integer dim i, total as integer sum = 0 for i = 1 to n total = total + x(i) next sum = total end function
This function exploits the fact that the variable N is automatically assigned a value when the function is called and the value is the extent of the array passed on invocation. N is a read-only variable in this context. Attempts to write to N cause compile-time errors.
The local variable, total is automatically initialized to 0 upon function entry.
GoTo
GoTo label
A program can only GoTo a label in the same scope. A GoTo may jump out of a For or While loop, but not INTO one.
If…Then…Else
if condition1 then ...statement block1... elseif condition2 then ...statement block2... else ...statement block3... end if
IF...THEN...ELSE statements control program execution based on the evaluation of numeric expressions. The IF...THEN...ELSE decision structure permits the execution of program statements or allows branching to other parts of the program based on the evaluation of the expression.
There are two structures of IF... THEN...ELSE statements, single line and block formats.
$Include
$include inclfile
$include include-file-name
Textually include inclfile at this point in the compilation. There can be no space between $ and include. The $include directive must start at the beginning of the line.
Input
input [prompt-string][,|;]input-variable
Input reads a character string received by the console tab in the program view, terminated by a carriage return.
As an option, the prompt message is transmitted when the Input statement is encountered. If the prompt string is followed by a semicolon, a question mark is printed at the end of the prompt string. If a comma follows the prompt string, no question mark is printed. This input statement is typically used for debugging purposes.
Interrupt … End Interrupt
interrupt {Interrupt-Source-Name} ...program statements... end interrupt
Interrupt handlers can be located anywhere in the program text (e.g., before main).
MOVE.ABORT
MOVE.ABORT stops motor motion and allows continued program execution. Deceleration is determined by the controlled stop deceleration rate (CS.DEC).
MOVE.GOABS
MOVE.GOABS (Go Absolute) moves the motor to the position specified by MOVE.TARGETPOS. This position is based on a zero position at electrical home.
The motor speed follows a velocity profile as specified by MOVE.ACC, MOVE.RUNSPEED, and MOVE.DEC . Direction of travel depends on current position and target position only (MOVE.DIR has no effect). After the program initiates MOVE.GOABS, it immediately goes to the next instruction.
Change MOVE.ACC, MOVE.RUNSPEED, and MOVE.DEC during a move using MOVE.GOUPDATE.
MOVE.GOHOME
MOVE.GOHOME moves the motor shaft to the electrical home position (PL.FB = 0).
The motor speed follows a trapezoidal velocity profile as specified by MOVE.ACC, MOVE.RUNSPEED, and MOVE.DEC. After the program initiates MOVE.GOHOME, it immediately goes to the next instruction.
MOVE.GOHOME performs the same action as setting MOVE.TARGETPOS to zero and executing a MOVE.GOABS function. Change MOVE.ACC, MOVE.DEC and MOVE.RUNSPEED during a move using MOVE.GOUPDATE
MOVE.GOREL
MOVE.GOREL (Go Relative) moves the motor shaft a relative distance from the current position.
Distance, as specified in MOVE.RELATIVEDIST, is either positive or negative. The motor speed follows a trapezoidal velocity profile as specified by MOVE.ACC, MOVE.RUNSPEED, and MOVE.DEC.
The program does not wait for motion completion. After the program initiates this move it immediately goes to the next instruction.
Change MOVE.ACC, MOVE.RUNSPEED, and MOVE.DEC during a move using MOVE.GOUPDATE.
MOVE.GOUPDATE
MOVE.GOUPDATE (Update Move) updates a move in process with new variables. This allows you to change motion “on the fly” without having to stop and restart the motion function with new variables.
MOVE.GOVEL
MOVE.GOVEL (Go Velocity) moves the motor shaft at a constant speed.
The motor accelerates and reaches maximum speed as specified by MOVE.ACC and MOVE.RUNSPEED, with direction determined by MOVE.DIR. Stop motion by:
- Programming MOVE.ABORT for maximum deceleration allowed by current limits.
- Programming MOVE.RUNSPEED = 0 for deceleration at rate set by MOVE.DEC.
After the program initiates MOVE.GOVEL, it immediately goes to the ne xt instruction.
Change variables during a move using MOVE.GOUPDATE.
On Error GoTo
On Error Goto Error-Handler-Name
or
On Error Goto 0
When a firmware runtime error condition occurs, Error-Handler-Name is called, the error handler is de-installed, and an internal flag (inerror-handler) is set. Any subsequent runtime error (including attempting to set the error handler, or return from the On Error handler) causes an immediate Stop.
On Error Goto 0 disables the current On Error handler. If an error occurs when no error handler is installed, Stop is invoked.
Pause( )
Pause(Pause_Time) causes the program to pause the amount of time specified by the Pause_Time argument. The motion of the motor is not affected.
print expression1 [ [,;] expression2 ] [;]
Print a list of expressions, separated by delimiters to the console. Any number of delimiters (including zero) can appear before or after the list of expressions. At least one delimiter must appear between each pair of expressions in the print list. The print statement is primarily used for debugging purposes.
Example:
print ‘ print a newline
print , ‘ advance a single tab stop
print a,b ‘ print a and b, tab between
print a,b, ‘ print a and b, tab between and at end
print ,,,x,,, ‘ tab tab tab x tab tab tab
VM.RESTART
VM.RESTART clears the run time error variables and causes program execution to start again from the beginning of the program. Any Interrupts, Subroutines, WHEN statements or loops in process are aborted. This statement is used to continue program execution after a Run Time Error Handler or to abort from WHEN statements without satisfying the condition.
VM.RESTART does not clear the data area or change any program or motion variables.
Select Case
Select Case test-expression Case expression-list1 ...statement block1... Case expression-list2 ...statement block1... Case expression-list3 ...statement block1... Case Else ...else block... End Select
test-expression must evaluate to an INTEGER or FLOAT value.
expression-list1 is a non-empty list of case-defn, separated by commas.
There can be only one Case Else and, if present, it must appear as the last case. It is selected only if all other tests fail.
case-defn can be any of the following:
expr
expr to expr (tests inclusive (closed range))
is relop expr (<, =, =, =, > )
is expr (equiv to “is = expr”)
Select-case statements where the case-defn expressions are composed solely of integer constants are evaluated much quicker at run-time. (Cases involving variables must be transformed to logically equivalent if-then-else statements.)
Static
Static var1 [, var2[...]] as type
where type is:
INTEGER 32 bit integer
FLOAT IEEE single precision float
STRING default length is 32 characters
Static is used for declaring variables before use. All variables (except parameters) must be declared before they can be used. The Static statement is used in a Function, Sub or Interrupt to specify that the specified variable's value be remembered even when the Function or Sub is finished. The next time that the Function, Sub or Interrupt is executed, the value will be available.
Example:
Main while 1 call MySub pause(1) wend End Main '-------------- Subroutines and Functions ------------ sub MySub dim x as integer 'value is forgotten static y as integer 'value is remembered x= x + 1 y = y + 1 print x,y end sub
Stop
Stops the execution of the program.
Sub…End Sub
Sub [argument-list] ...body of the sub-procedure... End Sub
Declare a subroutine. Invoked via Call. Optionally takes arguments. As with Function, it is illegal to provide an empty parameter list (‘()’) if the subroutine takes no parameters.
Swap
Swap x, y
Swaps the values of the variables. The variable types must be the same. Does not work on arrays or strings.
When
When when-condition , when-action
When is used for very fast output response to certain input conditions. You specify the condition and action. Upon encountering When, program execution waits until the defined condition is satisfied. The program immediately executes the action and continues with the next line of the program.
The When statement provides latching of several variables when the When condition is satisfied. These variables are:
|
WHEN.DRVHANDWHEEL |
WHEN.FB1MECHPOS |
|
WHEN.PLCMD |
WHEN.DRVTIME |
|
WHEN.PLFB |
|
The software checks for the defined condition at the 4Khz rate. The when action is queued up and executed immediately. The when action will be executed within 25 microseconds of the when condition being met.
While…Wend
While condition ...statement block... Wend
While...Wend tells the program to execute a series of statements as long as an expression after the While statement is true.
If the expression is true, the loop statements between While and Wend are executed. The expression is evaluated again and if the expression is still true, the loop statements are executed again. This continues until the expression is no longer true. If the expression is not true, the statement immediately following the Wend statement is executed.




