Push, Syntax, Example – Rockwell Automation 1771-DB BASIC MODULE User Manual
Page 182
Chapter
Statements
11
11 -30
Use the PUSH statement to place the arithmetic expression or expressions
in the BASIC module argument stack. This statement evaluates the
arithmetic expression, or expressions, following the PUSH statement and
then places them in sequence on the argument stack. Each variable
PUSHed increments the A-stack by 6 bytes.
The PUSH and POP statements provide a simple means of passing
parameters to call routines (see Chapters 12 and 13). In addition, the
PUSH and POP statements are used to pass parameters to BASIC
subroutines and to swap variables. The last value PUSHed onto the
argument stack is the first value POPped off the argument stack.
You can push more than one expression onto the argument stack using a
single PUSH statement with multiple expressions (expr, expr, expr).
You must follow each expression with a comma. The last value pushed
onto the argument stack is the last expression encountered in the push
statement.
Important: The argument stack can hold up to 33 floating point numbers
before overflowing.
Syntax
PUSH
expr, expr, ... expr
Example
>1 REM EXAMPLE PROGRAM
>10 A = 10
>20 C = 20
>30 PRINT “A = ”,A,“ AND C = ” C
>40 PUSH A,C
>50 POP A,C
>60 PRINT “A = ”,A,“ AND C = ”,C
>70 END
READY
>RUN
A = 10 AND C = 20
A = 20 AND C = 10
READY
>NEW
>10 PUSH 0
>20 CALL 14
>30 POP W
>40 PRINT W
>50 END
READY
>RUN
0
PUSH
Chapter