Galil Motion Control DMC-21 5 Series User Manual page 99

Table of Contents

Advertisement

4. Please refer to the JS command in the controller's command reference for further important information.
Example: A Simple Adding Function
#add;
JS
#sum(1,2,3,4,5,6,7,8)
MG_JS
EN
#sum
EN,,
(^a+^b+^c+^d+^e+^f+^g+^h)
:XQ
36.0000
Example: Variable, and an Important Note about Creating Global Variables
#var;
value=5;
global=8;
JS
#SUM
(&value,1,2,3,4,5,6,7);
MG
value;
MG
_JS;
EN;
#SUM;
^a=^b+^c+^d+^e+^f+^g+^h+
global
EN,,^a
:XQ
36.0000
36.0000
Example: Working with Arrays
#array;
DM
speeds[8];
DM
other[256];
JS
#initAry("speeds",0);
JS
#initAry("other",0);
EN;
#initAry;
^a[^b]=1;
^b=^b+1;
JP
#initAry(^b<^a[-1]);
EN,,^a
Chapter 7 Application Programming ▫ 94
'label for main program
'call subroutine and pass values
'print return value
'(^a,^b,^c,^d,^e,^f,^g,^h) syntax note for use
'return sum
'loop for main program
'label for main program
'value to be passed by reference
'global variable
'first argument passed by reference
'message value after subroutine
'message returned value
'loop for main program
'label for main program
'dimension arrays
'set elements in speeds[] starting at index 0
'set elements in other[] starting at index 0
'(array ^a, index ^b) set elements starting at index
'increment index
DMC-21x5 User Manual 1.0a1

Advertisement

Table of Contents
loading

Table of Contents