Syntax, Example – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 103

Advertising
background image

Publication 1746-RM001A-US-P

Execution Control and Interrupt Support Functions 8-7

Syntax

PUSH [0 or 1]

CALL 38

Example

>1

REM EXAMPLE PROGRAM

>10

REM ENABLE EXPANDED ONERR FUNCTION

>20

ONERR 160

>30

PUSH 1

>40

CALL 38

>50

CALL 53: REM GET DATA FROM OUTPUT IMAGE

>60

PUSH 201: REM ADDRESS OF SECOND WORD IN BUFFER

>70

CALL 14: REM GET DATA FROM INPUT BUFFER

>80

POP X: REM VALUE FROM INPUT BUFFER

>90

A=(X*2.499733)-8191.625

>100 PUSH A: REM RESULT OF ABOVE CALCULATION

>110 PUSH 201: REM WORD NUMBER OF BASIC OUTPUT BUFFER

>120 CALL 24: REM BASIC FLOATING POINT TO 16-BIT SIGNED

INTEGER

>130 CALL 54: REM OUTPUT BUFFER TO SLC INPUT FILE

>140 POP Y: REM SLC PROCESSOR STATUS

>150 IF (Y<>0) THEN PRINT “PROCESSOR NOT IN RUN MODE”

>160 GOTO 50

>170 PRINT “ERROR CODE WAS”,XBY(257) : REM BEGINNING OF ONERR

ROUTINE

>175 PRINT “AT LINE “, (256*XBY (69FDH) + XBY(69FEH))

>180 GOTO 50

>190 END

The error in the example above is a missing POP for CALL 53. The missing POP
will cause an A-Stack error and would normally put the processor in Command
mode. When this occurs, print the error code and resume running the program.

Advertising