DMC-40x0 Command Reference
JS • 139
Variables may be passed by value or by reference. If passed by value, a copy is made in the
subroutine stack, leaving the original variable unchangeable. If passed by reference, the
original variable’s value will be changed when the subroutine writes to its local variable. This
is similar, but not exactly analogous, to a C pointer.
A variable passed by reference is automatically dereferenced; the variable pointer is not exposed
to the user. Following the C syntax, a by-reference pass is accomplished with the ampersand
(&) in the invoking call.
Arrays can be passed in the stack, though only by reference. No “&” is used when passing arrays,
by-reference is assumed. The length of an array is returned by reading index -1, e.g. array[-
1].
To return a value on the stack, write the value in the EN command upon ending the subroutine.
ARGUMENTS:
JS destination (param1,param2,..,param8), condition where
destination is a line number or label. An expression such as (#LABEL + 4) is also valid.
param1 – param8 are optional parameters to pass to the subroutine’s stack, referenced from within
the subroutine as ^a-^h, respectively.
Condition is a conditional statement using a logical operator
USAGE: DEFAULTS:
While Moving
Yes
Default Value
In a Program
Yes
Default Format
Command Line
No
Controller Usage
ALL CONTROLLERS
OPERAND USAGE:
_JS used after JS is called, this operand contains the returned of the subroutine called by JS
RELATED COMMANDS:
Bitwise Logical Operators AND and OR
^a, ^b, ^c, ^d, ^e, ^f, ^g, ^h JS subroutine stack variable
EN
End
EXAMPLES:
JS #SQUARE,V1<5
Jump to subroutine #SQUARE if V1 is less than 5
JS #LOOP,V1<>0
Jump to #LOOP if V1 is not equal to 0
JS #A
Jump to subroutine #A (no condition)
Passing Parameters:
#ADD
JS
#SUM
(1,2,3,4,5,6,7,8)
;' call subroutine, pass values
MG
_JS
return value
EN
'
#SUM
;NO(^a,^b,^c,^d,^e,^f,^g,^h) syntax note for use
EN
,,(^a+^b+^c+^d+^e+^f+^g+^h)
;' return sum
:Executed program from program1.dmc
36.0000
Note:
For additional examples, see the “JS Subroutine Stack Variables (^a, ^b, ^c, ^d, ^e, ^f, ^g, ^h)”
section in the DMC-40x0 User Manual.
Содержание DMC-40x0 Series
Страница 2: ......
Страница 4: ......
Страница 10: ...vi i Table of Contents DMC 40x0 Command Reference This Page is Left Blank Intentionally ...