DMC-41x3 User Manual

Add to my manuals
260 Pages

advertisement

DMC-41x3 User Manual | Manualzz

REM the sum of the amperr bits should be 0 with no amplifier error er=_TA0+mask+_TA2+_TA3

JP#AMPERR,er0

REM Notify user amperr has cleared

MG″AMPERR RESOLVED″

WT3000

RE

JS Subroutine Stack Variables (^a, ^b, ^c, ^d, ^e, ^f, ^g, ^h)

There are 8 variables that may be passed on the subroutine stack when using the JS command. Passing values on the stack is advanced DMC programming, and is recommended for experienced DMC programmers familiar with the concept of passing arguments by value and by reference.

Notes:

1. Passing parameters has no type checking, so it is important to exercise good programming style when passing parameters. See examples below for recommended syntax.

2. Do not use spaces in expressions containing ^.

3. Global variables MUST be assigned prior to any use in subroutines where variables are passed by reference.

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

'

;' call subroutine, pass values

;' print return value

#SUM

EN ,,(^a+^b+^c+^d+^e+^f+^g+^h)

;NO(^a,^b,^c,^d,^e,^f,^g,^h) syntax note for use

;' return sum

:Executed program from program1.dmc

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

;'a value to be passed by reference

;'a global variable

;'note first arg passed by reference

;'message out value after subroutine.

;'message out returned value

;NO(* ^a,^b,^c,^d,^e,^f,^g)

'notes:

'do not use spaces when working with ^

'If using global variables, they MUST be created before the subroutine is run

Executed program from program2.dmc

36.0000

36.0000

Chapter 7 Application Programming

141 DMC-41x3 User Manual

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

Download PDF

advertisement

Table of contents