Rockwell Automation 1746-BAS User Manual

BASIC Language
(Catalog Numbers 1746-BAS and 1746-BAS-T)
Reference Manual

Important User Information

Because of the variety of uses for the products described in this publication, those responsible for the application and use of this control equipment must satisfy themselves that all necessary steps have been taken to assure that each application and use meets all performance and safety requirements, including any applicable laws, regulations, codes and standards.
The illustrations, charts, sample programs and layout examples shown in this guide are intended solely for purposes of example. Since there are many variables and requirements associated with any particular installation, Rockwell International Corporation does not assume responsibility or liability (to include intellectual property liability) for actual use based upon the examples shown in this publication.
Rockwell Automation publication SGI-1.1, Safety Guidelines for the Application, Installation and Maintenance of Solid-State Control (available from your local Rockwell Automation office), describes some important differences between solid-state equipment and electromechanical devices that should be taken into consideration when applying products such as those described in this publication.
Reproduction of the contents of this copyrighted publication, in whole or part, without written permission of Rockwell Automation, is prohibited.
Throughout this manual we use notes to make you aware of safety considerations:
ATTENTION
Attention statements help you to:
identify a hazard
avoid a hazard
recognize the consequences
IMPORTANT
PLC-5 is a registered trademark; and MicroLogix, SLC 500, RSLogix, and RSLinx are trademarks of Rockwell Automation.
Identifies information about practices or circumstances that can lead to personal injury or death, property damage or economic loss
Identifies information that is critical for successful application and understanding of the product.
Language Elements
Data Types
Expressions and Operators

Table of Contents

Preface
Who Should Use This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-1
Purpose of this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-2
How to Use this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-3
Terms and Abbreviations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-4
Conventions Used in this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-4
Rockwell Automation Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-5
Chapter 1
Character Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
The BASIC Program Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Chapter 2
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Chapter 3
Expressions and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Hierarchy of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Trigonometric Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Functional Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Logarithmic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
String Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Special Function Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Chapter 4
BASIC Commands
i Publication 1746-RM001A-US-P
BRKPNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
CONT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Control-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
CALL 18 – Re-enable the Control-C Break Function . . . . . . . . . . . . . 4-5
CALL 19 – Disable the Control-C Break Function. . . . . . . . . . . . . . . 4-6
Control-S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Control-Q. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
EDIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
ERASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
IDLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
LIST@ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
LIST# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
NEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
Table of Contents ii
Command Line CALLs
NULL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
PROG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
PROG1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
PROG2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
RAM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
REM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
REN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
ROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
RROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
RUN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
SNGLSTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
VER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
XFER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
Chapter 5
CALL 73 – Battery-Backed RAM Disable. . . . . . . . . . . . . . . . . . . . . . 5-1
CALL 74 – Battery-Backed RAM Enable . . . . . . . . . . . . . . . . . . . . . . 5-2
CALL 77 – Protected Variable Storage . . . . . . . . . . . . . . . . . . . . . . . . 5-2
CALL 81 – User Memory Module Check and Description. . . . . . . . . 5-3
CALL 82 – Check User Memory Module Map. . . . . . . . . . . . . . . . . . 5-4
CALL 101 – Upload User Memory Module Code to Host. . . . . . . . . 5-4
CALL 103 – Print PRT1 Output Buffer and Pointer . . . . . . . . . . . . . 5-5
CALL 104 – Print PRT1 Input Buffer and Pointer. . . . . . . . . . . . . . . 5-6
CALL 109 – Print Argument Stack. . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
CALL 110 – Print PRT2 Output Buffer Pointer . . . . . . . . . . . . . . . . 5-8
CALL 111 – Print PRT2 Input Buffer Pointer . . . . . . . . . . . . . . . . . . 5-8
Assignment Functions
Control Functions
Publication 1746-RM001A-US-P
Chapter 6
CLEAR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
CLEARI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
CLEARS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
DATA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
DIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
LET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
Chapter 7
CLOCK1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
CLOCK0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
DO-WHILE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
DO-UNTIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
END. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
FOR-TO-(STEP)-NEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6
GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
IF-THEN-ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
Execution Control and Interrupt Support Functions
Table of Contents iii
NEXT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
ON-GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Chapter 8
CALL 16 – Enable DF1 Packet Interrupt . . . . . . . . . . . . . . . . . . . . . . 8-2
CALL 17 – Disable DF1 Packet Interrupt. . . . . . . . . . . . . . . . . . . . . . 8-3
CALL 20 – Enable Processor Interrupt . . . . . . . . . . . . . . . . . . . . . . . . 8-3
CALL 21 – Disable Processor Interrupt. . . . . . . . . . . . . . . . . . . . . . . . 8-4
CALL 26 – Module Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
CALL 38 – Expanded ONERR Restart. . . . . . . . . . . . . . . . . . . . . . . . 8-5
CALL 70 – ROM to RAM Program Transfer . . . . . . . . . . . . . . . . . . . 8-8
CALL 71 – ROM/RAM to ROM Program Transfer. . . . . . . . . . . . . . 8-9
CALL 72 – RAM/ROM Return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9
GOSUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11
ONERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
ON-GOSUB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14
ONTIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14
PUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15
POP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
RETI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
RETURN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20
Math and Backplane Conversion Functions
Clock/Calendar Functions
Chapter 9
CALL 14 – 16-Bit Signed Integer to BASIC Floating-Point . . . . . . . . 9-1
CALL 15 – 16-Bit Unsigned Integer to BASIC Floating-Point. . . . . . 9-2
CALL 24 – BASIC Floating-Point to 16-Bit Signed Integer . . . . . . . . 9-2
CALL 25 – BASIC Floating-Point to 16-Bit Binary . . . . . . . . . . . . . . 9-3
CALL 88: BASIC Floating-Point to SLC Floating-Point. . . . . . . . . . . 9-4
CALL 89: SLC Floating-Point to BASIC Floating-Point. . . . . . . . . . . 9-5
Chapter 10
CALL 40 – Set Clock/Calendar Time . . . . . . . . . . . . . . . . . . . . . . . . 10-1
CALL 41 – Set Clock/Calendar Date . . . . . . . . . . . . . . . . . . . . . . . . 10-2
CALL 42 – Set Day of Week. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
CALL 43 – Retrieve Date/Time String . . . . . . . . . . . . . . . . . . . . . . . 10-4
CALL 44 – Retrieve Date Numeric. . . . . . . . . . . . . . . . . . . . . . . . . . 10-4
CALL 45 – Retrieve Time String . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5
CALL 46 – Retrieve Time Numeric . . . . . . . . . . . . . . . . . . . . . . . . . 10-6
CALL 47 – Retrieve Day of Week String . . . . . . . . . . . . . . . . . . . . . 10-6
CALL 48 – Retrieve Day of Week Numeric . . . . . . . . . . . . . . . . . . . 10-7
CALL 52 – Retrieve Date String . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7
Publication 1746-RM001A-US-P
Table of Contents iv
Status Functions
Chapter 11
CALL 36 – Get Number of Characters in PRT2 Buffers . . . . . . . . . 11-2
CALL 51 – Check CPU Output Image Buffer . . . . . . . . . . . . . . . . . 11-3
CALL 55 – Check CPU Input Image Buffer. . . . . . . . . . . . . . . . . . . 11-4
CALL 58 – Check M0 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
CALL 59 – Check M1 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
CALL 75 – Check SLC 500 Controller CPU Status . . . . . . . . . . . . . 11-7
CALL 80 – Check Battery Condition . . . . . . . . . . . . . . . . . . . . . . . . 11-8
CALL 86 – Check DH485 Interface File Remote Write Status. . . . . 11-8
CALL 87 – Check DH485 Interface File Remote Read Status . . . . . 11-9
CALL 95 – Get Number of Characters in PRT1 Buffers . . . . . . . . 11-10
CALL 97 – Enable Port PRT2 DTR Signal . . . . . . . . . . . . . . . . . . 11-11
CALL 98 – Disable Port PRT2 DTR Signal. . . . . . . . . . . . . . . . . . 11-11
CALL 108 – Enable DF1 Driver Communications. . . . . . . . . . . . . 11-12
CALL 113 – Disable DF1 Driver Communications . . . . . . . . . . . . 11-18
CALL 120 – Clear module Input and Output Buffers . . . . . . . . . . 11-18
CALL 121 – Get SLC Processor Program ID Number . . . . . . . . . . 11-19
Output Functions
Chapter 12
CALL 23 – Transfer Data from the CPU Files to Port 1 or 2 . . . . . . 12-2
CALL 28 – Write to Remote DH485 SLC Data File . . . . . . . . . . . . 12-6
CALL 29 – Read/Write to a PLC/SLC from the
Module Internal String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-13
CALL 31 – Display Current PRT2 Port Setup . . . . . . . . . . . . . . . . 12-14
CALL 37 – Clear PRT2 Input/Output Buffers . . . . . . . . . . . . . . . . 12-15
CALL 54 – Transfer BASIC Output Buffer to CPU Input Image. . 12-15
CALL 57 – Transfer BASIC Output Buffer to CPU M1 File . . . . . 12-16
CALL 85 – Transfer BASIC Output Buffer to DH485
Common Interface File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17
CALL 91 – Write BASIC Output Buffer to Remote DH485 Data File 12-18 CALL 93 – Write Output Buffer to Remote DH485
Common Interface File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-22
CALL 94 – Display Current PRT1 Port Setup . . . . . . . . . . . . . . . . 12-24
CALL 96 – Clear PRT1 Input/Output Buffers . . . . . . . . . . . . . . . . 12-24
CALL 112 – User LED Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-25
CALL 114 – Transmit DF1 Packet. . . . . . . . . . . . . . . . . . . . . . . . . 12-26
CALL 115 – Check DF1 XMIT Status. . . . . . . . . . . . . . . . . . . . . . 12-27
CALL 123 – Write to Remote DF1 PLC Data File. . . . . . . . . . . . . 12-28
PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-35
PH0., PH1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-37
ST@ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-38
Publication 1746-RM001A-US-P
Input Functions
Table of Contents v
Chapter 13
CALL 22 – Transfer Data from Port 1 or 2 to the CPU Files . . . . . . 13-2
CALL 27 – Read Remote DH485 SLC Data File . . . . . . . . . . . . . . . 13-8
CALL 29 – Read/Write to a PLC/SLC from the
Module Internal String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-13
CALL 35 – Get Numeric Input Character from PRT2 . . . . . . . . . . 13-15
CALL 53 – Transfer CPU Output Image to BASIC Input Buffer. . 13-17
CALL 56 – Transfer CPU M0 File to BASIC Input Buffer. . . . . . . 13-18
CALL 84 – Transfer DH485 Interface File to BASIC Input Buffer. 13-19 CALL 90 – Read Remote DH485 Data File to BASIC Input Buffer 13-20 CALL 92 – Read Remote DH485 Common Interface File to
BASIC Input Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-23
CALL 117 – Get DF1 Packet Length . . . . . . . . . . . . . . . . . . . . . . . 13-25
CALL 118 – PLC/SLC Unsolicited Writes . . . . . . . . . . . . . . . . . . . 13-26
CALL 122 – Read Remote DF1 PLC Data File . . . . . . . . . . . . . . . 13-30
GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-38
INPL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-39
INPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-40
INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-40
LD@ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-43
READ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-45
Setup Functions
String Functions
Chapter 14
CALL 30 – Set PRT2 Port Parameters . . . . . . . . . . . . . . . . . . . . . . . 14-1
CALL 78 – Set Program Port Baud Rate. . . . . . . . . . . . . . . . . . . . . . 14-2
CALL 99 – Reset Print Head Pointer . . . . . . . . . . . . . . . . . . . . . . . . 14-3
CALL 105 – Reset PRT1 to Default Settings . . . . . . . . . . . . . . . . . . 14-4
CALL 119 – Reset PRT2 to Default Settings . . . . . . . . . . . . . . . . . . 14-4
MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
Chapter 15
CALL 60 – String Repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1
CALL 61 – String Append . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
CALL 62 – Number to String Conversion . . . . . . . . . . . . . . . . . . . . 15-3
CALL 63 – String to Number Conversion . . . . . . . . . . . . . . . . . . . . 15-4
CALL 64 – Find a String in a String . . . . . . . . . . . . . . . . . . . . . . . . . 15-6
CALL 65 – Replace a String in a String. . . . . . . . . . . . . . . . . . . . . . . 15-7
CALL 66 – Insert a String in a String . . . . . . . . . . . . . . . . . . . . . . . . 15-8
CALL 67 – Delete a String in a String. . . . . . . . . . . . . . . . . . . . . . . . 15-9
CALL 68 – Find the Length of a String. . . . . . . . . . . . . . . . . . . . . . 15-10
STRING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-11
Publication 1746-RM001A-US-P
Table of Contents vi
Decimal/Hexadecimal/Octal/ ASCII Conversion Table
BASIC Command, Statement, and CALL Quick Reference Guide
Appendix A
Mathematical Conversion Overview . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
Appendix B
Mnemonic List Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1
Index
Publication 1746-RM001A-US-P

Preface

Read this preface to familiarize yourself with the rest of the manual. This preface covers the following topics:
who should use this manual
the purpose of this manual
how to use this manual
terms and abbreviations
conventions used in this manual
Rockwell Automation support

Who Should Use This Manual

Use this manual if you are responsible for designing, installing, programming, or troubleshooting control systems that use Allen-Bradley small logic controllers.
You should have a basic understanding of SLC 500™ products. You should understand programmable controllers and be able to interpret the ladder logic instructions required to control your application. If you do not, contact your local Rockwell Automation representative for information on available training courses before using this product.
P-1 Publication 1746-RM001 A-US-P
P-2

Purpose of this Manual

This manual is a reference guide for programming the BASIC or BASIC-T module. This manual is intended for reference purposes only.
Chapter Title Contents
Preface Describes the purpose, background, and scope of this manual. Also lists related
publications.
1 Language Elements Describes BASIC program lines, line numbers, statements, commands,
operators, and line length.
2 Data Types Describes and illustrates data types, variable names and types.
3 Expressions and Operators Describes and illustrates arithmetic, logical, relational, trigonometric, functional,
logarithmic, string, and special function operators.
4 BASIC Commands Describes and illustrates BRKPNT, CONT, [CTRL-C], [CTRL-S], [CTRL-Q], EDIT,
ERASE, IDLE, LIST, LIST@, LIST#, MODE, NEW, NULL, PROG, PROG1, PROG2, RAM, REM, REN, ROM, RROM, RUN, SNGLSTP, VER, and XFER commands and CALLs 18 and 19.
5 Command Line CALLS Describes and illustrates CALLs 73, 74, 77, 81, 82, 101, 103, 104, 109, 110, and
111.
6 Assignment Functions Describes and illustrates CLEAR, CLEARI, CLEARS, DATA, DIM, LET and
RESTORE functions.
7 Control Functions Describes and illustrates CLOCK1, CLOCK0, DO-WHILE, DO-UNTIL, END,
FOR-TO-(STEP)-NEXT, GOTO, IF-THEN-ELSE, NEXT, and ON-GOTO functions.
8 Execution Control and Interrupt
Support Functions
9 Math and Backplane Functions Describes and illustrates CALLs 14, 15, 24, 25, 88, and 89.
10 Clock/Calendar Functions Describes and illustrates CALLs 40, 41, 42, 43, 44, 45, 46, 47, 48, and 52.
11 Status Functions Describes and illustrates CALLs 36, 51, 55, 58, 59, 75, 80, 86, 87, 95, 97, 98, 108,
12 Output Functions Describes and illustrates CALLs 23, 28, 29, 31, 37, 54, 57, 85, 91, 93, 94, 96, 112,
13 Input Functions Describes and illustrates CALLs 22, 27, 29, 35, 53, 56, 84, 90, 92, 117, 118, 122,
14 Setup Functions Describes and illustrates CALLs 30, 78, 99, 105, 119, and MODE functions.
15 String Functions Describes and illustrates CALLs 60, 61, 62, 63, 64, 65, 66, 67, 68, and STRING
Appendix A Decimal/Hexidecimal/Octal/
ASCII Conversion Table
Appendix B BASIC Command, Statement, and
CALL Quick Reference Guide
Describes and illustrates CALLs 16, 17, 20, 21, 26, 38, 70, 71, 72, and GOSUB, ONERR, ON-GOSUB, ONTIME, PUSH, POP, RETI, RETURN, and STOP functions.
113, 120, and 121.
114, 115, 123, and PRINT, PH0. PH1. and ST@ functions.
and GET, INPL, INPS, INPUT, LD@ and READ functions.
functions.
Lists the Decimal/Hexidecimal/Octal/ASCII equivalents.
Lists the various commands, statements, and CALLs needed for BASIC programming.
Publication 1746-RM001A-US-P
Related Documentation
The following documents contain additional information regarding Rockwell Automation products. To obtain a copy, contact your local Rockwell Automation office or distributor.
For Read this document Publication Number
P-3
A BASIC and BASIC-T manual that provides information on installing and using the 1746-BAS and 1746-BAS-T modules.
A programming manual with detailed instructions on installing and using BASIC Development Software to program the BASIC and BASIC-T modules.
An overview of the SLC 500 family of products SLC 500™ System Overview 1747-SO001A-US-P
A description of how to install and use a Modular SLC 500 Processor
A reference manual that contains status file data and instruction set information for SLC 500 processors
A description of how to install and use a module that acts as a bridge between DH485 networks and devices requiring DF1 protocol.
An application example demonstrating how to transfer ASCII data to an SLC 5/02 or later processor using a remote SLC 500 BASIC module.
In-depth information on grounding and wiring Allen-Bradley programmable controllers
A glossary of industrial automation terms and abbreviations
SLC 500™ BASIC and BASIC-T Modules User Manual
BASIC Development Software Programming Manual
Modular Hardware Style Installation and Operation Manual
SLC 500™ and MicroLogix™ 1000 Instruction Set Reference Manual
DH-485/RS-232C Interface Module User’s Manual
ASCII Data Transfer to the SLC 500™ BASIC Module (Series B)
Allen-Bradley Programmable Controller Grounding and Wiring Guidelines
Allen-Bradley Industrial Automation Glossary
1746-UM004A-US-P
1746-PM001A-US-P
1747-6.2
1747-6.15
1747-6.12
1746-2.41
1770-4.1
AG-7.1
An article on wire sizes and types for grounding electrical equipment

How to Use this Manual

To use this manual effectively, use the worksheets provided in Appendix B. The worksheets can help you document your application and settings and also facilitate the flow of information to other individuals in your organization for implementation.
National Electric Code Published by the National Fire Protection
Association of Boston, MA
Publication 1746-RM001A-US-P
P-4

Terms and Abbreviations

The following terms and abbreviations are specific to this product. For a complete listing of Allen-Bradley terminology, refer to the Allen-Bradley Industrial Automation Glossary, publication number ICCG-7.1.
Module SLC 500 BASIC and BASIC-T Modules (catalog numbers
1746-BAS and 1746-BAS-T)
BASIC development software BASIC Development Software (catalog
number 1747-PBASE)
BASIC —the BASIC-52 programming language
console device — the device connected to the BASIC module program port.
This device is used as an interface between the user and the BASIC program.
DH485 network communication protocol
EPROM Erasable Programmable Read Only Memory
EEPROM — Electrically Erasable Programmable Read Only Memory
memory module — BASIC or BASIC-T modules EEPROM or UVPROM
MTOP system control value that holds the last valid memory address
program port — the port used to program the module. Either PRT1 or port
DH485 can be used as the program port.
RAM — Random Access Memory

Conventions Used in this Manual

ROM — Read Only Memory, refers to the optional memory module memory
space (EEPROM or UVPROM)
RS-232/423 serial communication interface
RS-422 differential communication interface
RS-485 network communication interface
SCADA — Supervisory Control and Data Acquisition
scalar variable — a variable with a single value
SLC 500 SLC 500 fixed and modular controller
UVPROM — Ultra Violet Erasable Programmable Read Only Memory
The following conventions are used throughout this manual:
Bulleted lists such as this one provide information, not procedural steps.
Numbered lists provide sequential steps or hierarchical information.
Italic type is used for emphasis.
Te xt in this font indicates words or phrases you should type.
Publication 1746-RM001A-US-P
Key names match the names shown and appear in bold, capital letters within
brackets (for example,
[ENTER]).
P-5

Rockwell Automation Support

Allen-Bradley offers support services worldwide, with over 75 Sales/Support Offices, 512 authorized Distributors and 260 authorized Systems Integrators located throughout the United States alone, plus Rockwell Automation representatives in every major country in the world.
Local Product Support
Contact your local Rockwell Automation representative for:
sales and order support
product technical training
warranty support
support service agreements
Technical Product Assistance
If you need to contact Rockwell Automation for technical assistance, please review the information in the appropriate chapter first. Then call your local Rockwell Automation representative.
Your Questions or Comments on this Manual
If you find a problem with this manual, please notify us of it on the enclosed Publication Problem Report.
If you have any suggestions for how this manual could be made more useful to you, please contact us at the address below:
Rockwell Automation Control and Information Group Technical Communication, Dept. A602V P.O. Box 2086 Milwaukee, WI 53201-2086
Publication 1746-RM001A-US-P
P-6
Publication 1746-RM001A-US-P
Chapter
1

Language Elements

This chapter introduces you to the elements of a BASIC program. These elements include BASIC:
line numbers
statements, commands, and operators
line length

Character Set

The BASIC Program Line

BASIC programs are composed of a group of BASIC program lines. Each BASIC program line is composed of a group of ASCII characters. Refer to Appendix A for a complete listing of ASCII character codes.
BASIC program lines consist of a BASIC line number and BASIC statements and operators. BASIC program lines are restricted to the BASIC line length.
BASIC Line Numbers
We refer to BASIC line numbers as:
[ln num]
BASIC line numbers indicate the order that the program lines are stored in memory and are also used as references when branching and editing. This number may be any whole integer from 1 to 65535. Typically you start numbering BASIC programs with line number 10 and increment by 10. This allows you to add additional lines later as you work on your program.
Since the computer runs the statements in numerical order, additional lines need not appear in consecutive order on the screen. If you enter line 35 after line 40, the computer still runs line 35 after line 30 and before line 40. This technique saves you from reentering an entire program if you forget to include a line.
IMPORTANT
1 Publication 1746-RM001A-US-P
The first line of your program must be a comment.
1-2 Language Elements
Typically, the line numbers of a program start out looking like the first column and end up looking something like the second column below:
#1 #2 10 5 20 7 30 10 40 15 50 20 60 30 70 35 80 40
.. .. ..
IMPORTANT
Reuse of an existing line number causes all of the information referenced by the original line number to be lost. Be careful when entering numbers in the Command mode, as you may accidentally erase some program lines. You may delete an existing line by retyping it with no information following it and pressing
[RETURN].
BASIC Statements, Commands, and Operators
BASIC program lines consist of a BASIC line number and BASIC statements and operators. Depending on the logic of your program, there may be more than one statement on a line. If so, each must be separated by a colon (:).
BASIC Line Length
A BASIC program line always begins with a line number and must contain at least one character, but no more than 68 characters. A program line ends when you press
[RETURN].
Publication 1746-RM001A-US-P
Chapter

Data Types

This chapter provides you a method of defining or displaying data within the BASIC programming language through the use of:
data types
variables
2

Data Types

Data types are broken down into three sections: argument stack, string and numeric elementary data types, and backplane conversion data.
Argument Stack
The argument stack (A-stack) stores all constants that the BASIC or BASIC-T module is currently using. Operations such as add, subtract, multiply, and divide always operate on the first two numbers of the argument stack and return the result to the stack. The argument stack is 203 bytes long. Each floating point number placed in the stack requires 6 bytes of storage. The argument stack can hold up to 33 floating point numbers before overflowing.
In addition, the PUSH command saves data to the argument stack and the POP command restores data from the stack. PUSHes and POPs are typically associated with CALLs. PUSHes and POPs are mechanisms used to transfer information to and from CALL routines.
PUSH makes a copy of the variable being PUSHed, then puts that copy on the top of the argument stack. POP takes the value on the top of the argument stack and copies it to the variable being POPped.
String Data Types
A string is a character or group of characters stored in memory. Usually, the characters stored in a string make up a word or a sentence. Strings allow you to use characters instead of numbers. Strings are shown as:
$([expr])
The module uses single-dimension string variables, a string variable (the define and manipulate 255 different strings in the module. Initially, no memory is allocated for strings. Memory is allocated using the STRING statement. Strings are declared and manipulated through the $ operator.
1 Publication 1746-RM001A-US-P
[expr] value) ranges from 0 to 254. This means that you can
$([expr]). The dimension of
2-2 Data Types
When allocating memory for a string, you must account for the overhead bytes used by BASIC to manipulate strings. BASIC uses one overhead byte per string being declared plus one additional overhead byte.
Example 1
String 106,20
Allocates space for five 20 byte strings (100 bytes) and includes five overhead bytes (1 per string) and one additional overhead byte.
In the module you can define strings with the LET statement, the INPUT statement, and with the ASC operator.
Example 2
>10 STRING 106,20 >20 $(1)=“THIS IS A STRING, ” >30 INPUT “WHAT’S YOUR NAME? - ”,$(2) >40 PRINT $(1),$(2) >50 END
READY >RUN
WHAT’S YOUR NAME? - FRED THIS IS A STRING, FRED
READY >
You can also assign strings to each other with a LET statement.
Example 3
LET $(2)=$(1)
Result: Assigns the string value in $(1) to the STRING $(2).
Publication 1746-RM001A-US-P
Data Types 2-3
Numeric Data Types
There are two different numeric data types:
integer numbers
floating-point numbers
You can enter and display numbers in four formats: integer, decimal, hexadecimal, and exponential.
Example
129, 34.98, 0A6EH, 1.23456E+3
The BASIC or BASIC-T module interprets all numbers as floating-point numbers except when performing logical operations. When performing logical operations, the module converts floating-point numbers to integers, performs the operation, then converts the result back to floating-point.
Integer Numbers
The module operates on unsigned 16-bit integers that range from 0 to 65535 or 0FFFFH. You can enter all integers in either decimal or hexadecimal format. You indicate a hexadecimal number by placing the character H after the number (example: 170H). If the hexadecimal number begins with A through F, then it must be preceded by a zero. (For example, you must enter A567H as 0A567H.) When an operator, such as .AND. requires an integer, the module truncates the fraction portion of the number so it fits the integer format. Integers are shown as:
[integer]
IMPORTANT
The SLC 500 processor operates on signed 16-bit integers that range from –32768 to 32767. If an integer value larger than 32767 is passed to the processor from the module, that value is interpreted as negative by the processor.
Floating-Point Numbers
In the module, all numbers are stored as floating-point numbers. Floating-point numbers are numbers in which the decimal point floats depending on the significant digits of a specific number. The processor accounts for the location of the decimal point. This allows the processor to store only the significant digits of a value, thus saving memory space.
You can represent the following range of numbers in the module:
+1E –127 to +.99999999 +127
There are eight significant digits. Numbers are internally rounded to fit this precision.
Publication 1746-RM001A-US-P
2-4 Data Types
Backplane Conversion Data
The module communicates with the local processor through the SLC 500 I/O backplane. All data communicated to and from the SLC 500 is in SLC 500 format. The SLC 500 formats are:
16-bit signed integer (–32768 to 32767)
16-bit binary (0000000000000000 to 1111111111111111)

Variables

IMPORTANT
Variables that include a single-dimension expression [exp] are dimensioned or arrayed variables. Variables that contain a letter or a letter and a number are scalar variables. Any variables entered in lower case are changed to upper case. Variables are shown as:
[var]
The module allocates variables in a static manner, which means the first time a variable is used, the module allocates a portion of memory (8 bytes) specifically for that variable. This memory cannot be de-allocated on a variable to variable basis. This means that if you execute a statement (example: >10 Q - 3), you cannot tell the module that the variable Q no longer exists to free up the 8 bytes of memory that belong to Q. You can clear the memory allocated to variables by executing a CLEAR statement. The CLEAR statement frees all memory allocated to variables. Variables may be set aside for reuse to save memory.
IMPORTANT
Any integer larger than 32767 is interpreted as a negative number by the SLC 500 processor
The module requires less time to find a scalar variable because there is no expression to evaluate. To run a program as fast as possible, use single-dimension variables only when necessary. Use scalar variables for intermediate variables and assign the final result to a dimensioned variable. Also, put the most frequently used variables first. Variables defined first require the least amount of time to locate.
Publication 1746-RM001A-US-P
Data Types 2-5
Variable Names
Variables may represent either numeric values or strings. Variable names can only be eight characters long. The module compares the first, last, and number of characters in a variable name with the first, last, and number of characters in other variable names to determine if it is a unique variable name. The characters allowed in a variable name are letters, numbers, and the decimal point. Special type declaration characters are also allowed.
A variable can be a letter (for example
A, X, or I) followed by a:
single-dimension expression, (example: J(4), G(A+6), I(10*SIN (X))
number followed by a single-dimension expression (example: A1(8),
P7(10*SIN(X)), W8(A + C))
number (0 to 9) or letter (example: AA, AC, XX, A1, X3, G8) except for the
following combinations:
IMPORTANT
Reserved words (words already used in BASIC functions or statements) cannot be used as variable names.
CR, DO, IE, IF, IP, ON, PI, SP, TO, UI, UO
Variable Types
Type declaration characters indicate what a variable represents. The following type declaration character is recognized:
Character Variable Type
$ String variable
The only other legal variable type is a floating-point variable. Floating-point variables do not require a type declaration.
Publication 1746-RM001A-US-P
2-6 Data Types
Publication 1746-RM001A-US-P
Chapter
3

Expressions and Operators

This chapter describes and illustrates how you manipulate and/or evaluate expressions and statements within the BASIC program or the command line. Table
3.1 lists the corresponding mnemonics.
Table 3.1 Chapter Reference Guide
If you need (to) Use this mnemonic Page
Absolute value ABS( ) 3-9 Return the integer value of the ASCII character. ASC( ) 3-12 Return the arctangent of the argument. ATN( ) 3-8 Retrieve data from the specified memory address. CBY( ) 3-16 Count the value converted ASCII character. CHR( ) 3-14 Return the cosine of argument. COS( ) 3-8 Retrieve or assign data to or from the internal data memory of
the BASIC or BASIC-T module. Test for empty input buffer. EOF 3-15 “e” (2.7182818) TO THE X EXP( ) 3-11 Test for number of free bytes of RAM memory. FREE 3-15 Integer INT( ) 3-10 Read the number of bytes of memory in the current selected
program. Natural log LOG( ) 3-11 Read the last valid memory address. MTOP 3-16 One’s complement NOT( ) 3-9 PI-3.1415926 PI 3-10 Random number RND 3-11 Sign SGN 3-10 Return the sine of the argument SIN( ) 3-8 Square Root SQR( ) 3-10 Return the tangent of the argument. TAN( ) 3-8 Retrieve and/or assign the free running clock value. TIME 3-17 Retrieve or assign data to or from the external data memory of
the module. Addition + 3-3 Division / 3-4 Exponentiation ** 3-4 Multiplication * 3-4 Subtraction - 3-4 Logical AND .AND. 3-6 Logical OR .OR. 3-6
DBY( ) 3-16
LEN 3-15
XBY( ) 3-17
1 Publication 1746-RM001A-US-P
3-2 Expressions and Operators
Table 3.1 Chapter Reference Guide
If you need (to) Use this mnemonic Page
Logical Exclusive OR .XOR. 3-6 Direct communications to port PRT1. @ 3-15 Direct communications to port PRT2. # 3-15

Expressions and Operators

An expression is a logical mathematical expression that involves operators, constants, and variables. There are eight types of operators that may act on an expression:
arithmetic
logical
relational
trigonometric
functional
logarithmic
string
special function
Expressions
Expressions are simple or complex.
Simple expression:
12*EXP(A)/100,H(1) + 55,
Publication 1746-RM001A-US-P
Complex expression:
A stand alone variable [var] or constant [const] is also considered an expression. Expressions are shown as:
[expr]
(SIN(A)*SIN(A)+COS(A)* COS(A)/2)
Operators
An operator performs a defined operation on variables or constants. Operators require either one or two operands. Typical two operand operators include ADD(+), SUBTRACT(-), MULTIPLY(*) and DIVIDE(/). We call operators that require only one operand, single-operand operators. Typical single-operand operators are SIN, COS, and ABS.
Expressions and Operators 3-3

Hierarchy of Operators

The hierarchy of operators is the order that the operations in an expression are performed. You can write complex expressions using only a small number of parentheses. To illustrate the hierarchy of operators, examine the following equation:
4+3*2 = ?
In this equation, multiplication has precedence over addition. Therefore, multiply (3*2) and then add 4.
4+3*2 = 10
When an expression is scanned from left to right, an operation is not performed until an operator of lower or equal precedence is encountered. In the example, you cannot perform addition until the multiplication operation is complete because multiplication has a higher precedence. Use parentheses if you are in doubt about the order of precedence or to enhance program readability. The precedence of operators from highest to lowest in the module is:
1.
1. Operators that use parentheses ( )
1.1.
2.
2. Exponentiation (**)
2.2.
3.
3. Negation (-)
3.3.

Arithmetic Operators

4.
4. Multiplication (*) and division (/)
4.4.
5.
5. Addition (+) and subtraction (-)
5.5.
6.
6. Relational expressions (-, <>, >, >=, <, <-).
6.6.
7.
7. Logical AND (.AND.)
7.7.
8.
8. Logical OR (.OR.)
8.8.
9.
9. Logical XOR (.XOR.)
9.9.
The module contains a complete set of arithmetic operators that are divided into two groups: dual-operand operators and single-operand operators.
The general form of all dual-operand instructions is:
(expr) OP (expr), where OP is one of the following arithmetic operators
Add ( + )
Use the Addition operator to add the first and the second expressions together.
Example Result
>PRINT 3+2 5
Publication 1746-RM001A-US-P
3-4 Expressions and Operators
Divide ( / )
Use the Division operator to divide the first expression by the second expression.
Example Result
>PRINT 100/5 20
Exponentiation ( **)
Use the Exponentiation operator to raise the first expression to the power of the second expression. The maximum power to which you can raise a number is 255.
Example Result
>PRINT 2**3 8
Multiply ( * )
Use the Multiplication operator to multiply the first expression by the second expression.
Example Result
>PRINT 3*3 9
Subtract ( - )
Use the Subtraction operator to subtract the second expression from the first expression.
Example Result
>PRINT 9-6 3
Negation ( - )
Use the Negation operator to change an expression from positive to negative.
Example Result
>PRINT –(9+4) –13
Publication 1746-RM001A-US-P
Expressions and Operators 3-5
Overflow and Division by Zero
During the evaluation of an expression if an overflow, underflow, or division by zero error occurs, the module generates error messages and reverts to Command mode. Refer to the ONERR operation in chapter 8 for more information on how to trap these errors.
The largest result allowed from any calculation is 0.99999999 E+127. If this number is exceeded, the module generates the and returns to Command mode.
The smallest result allowed from any calculation is 0.99999999 E-128. If this number is exceeded, the module generates the message and returns to Command mode.
If an attempt is made to divide any number by zero, the module generates the
ERROR: DIVIDE BY ZERO message and returns to Command mode.
>10 PRINT 9/0 >20 PRINT “PROGRAM SHOULD NOT GET HERE.”
ERROR: ARITH. OVERFLOW message
ERROR: ARITH. UNDERFLOW
READY >RUN
ERROR: DIVIDE BY ZERO - IN LINE 10
10 PRINT 9/0
-----------------X
READY >
>10 PRINT 9.9E126*(2) >
READY >RUN
ERROR: ARITH. OVERFLOW - IN LINE 10
10 PRINT 9.9E126*(2)
-------------------------X
READY >
Publication 1746-RM001A-US-P
3-6 Expressions and Operators

Logical Operators

The module contains a complete set of logical operators that are divided into two groups: dual-operand operators and single-operand operators.
The general form of all dual-operand instructions is:
(expr) OP (expr), where OP is one of the following logical operators.
These operators perform BIT-WISE logical operations on numbers between 0 (0000H) and 65535 (0FFFFH) inclusive. If the argument is outside this range, then the module generates an
ERROR: BAD ARGUMENT message and returns to
Command mode. All decimal places are truncated, not rounded. Use the following table for bit manipulations on 16-bit values.
Table 3.2 Bit Manipulations on 16-Bit Values
X Y X .AND.Y X .OR.Y X .XOR.Y
00000 01011 10011 11110
.AND.
Use the logical .AND. operator to logically AND expressions together.
Example Result
>PRINT 3.AND.2 2
.OR.
Use the logical .OR. operator to logically OR expressions together.
Example Result
>PRINT 1.OR.4 5
.XOR.
Use the logical exclusive .XOR. operator to logically XOR expressions together.
Example Result
>PRINT 7.XOR.6 1
Publication 1746-RM001A-US-P
Expressions and Operators 3-7

Relational Operators

Relational expressions involve the operators =, < >, >, >=, <, and <=. In the module, relational operations are typically used to test a condition. The module relational operators return a result of 65535 (0FFFFH) if the relational expression is true, and a result of 0 if the relation expression is false. The result returns to the argument stack. Because of this, it is possible to display the result of a relational expression.
Relational expressions are shown as:
[rel expr]
Example Result
>PRINT 1=0 0 >PRINT 1>0 65535 >PRINT A<>A 0 >PRINT A=A 65535
You can chain relational expressions with the logical operators .AND., .OR., and .XOR.. This makes it possible to test a complex condition with ONE statement.
>10 IF (A>E).AND.(A>C).OR.(A>D)THEN...
Additionally, you can use the NOT([expr]) operator.
>10 IF NOT(A>E).AND.(A>C)THEN...
By chaining relational expressions with logical operators, you can test particular conditions with one statement.
IMPORTANT
When using logical operators to link relational expressions, you must be sure operations are performed in the proper sequence. When in doubt, use parentheses.
Publication 1746-RM001A-US-P
3-8 Expressions and Operators

Trigonometric Operators

The module contains a complete set of trigonometric operators. These operators are single-operand operators.
SIN([expr])
Use the SIN operator to return the sine of the argument. The argument is expressed in radians. Calculations are carried out to 7 significant digits. The argument must be between +
Example Result
>PRINT SIN(PI/4) .7071067 >PRINT SIN(0) 0
200000.
COS([expr])
Use the COS operator to return the cosine of the argument. The argument is expressed in radians. Calculations are carried out to 7 significant digits. The argument must be between +
Example Result
>PRINT COS(PI/4) .7071067 >PRINT COS(0) 1
200000.
TAN([expr])
Use the TAN operator to return the tangent of the argument. The argument is expressed in radians. The argument must be between +
Example Result
>PRINT TAN(PI/4) 1 >PRINT TAN(0) 0
200000.
ATN([expr])
Use the ATN operator to return the arctangent of the argument. The result is in radians. Calculations are carried out to 7 significant digits. The ATN operator returns a result between –PI/2 (3.1415926/2) and PI/2.
Example Result
>PRINT ATN(PI) 1.2626272 >PRINT ATN(1) .78539804
Publication 1746-RM001A-US-P
Expressions and Operators 3-9
Comments on Trigonometric Functions
The SIN, COS, and TAN operators use a Taylor series to calculate the function. These operators first reduce the argument to a value between 0 and PI/2. This reduction is accomplished by the following equation:
reduced argument=(user arg/PI – INT(user arg/PI) *PI
The reduced argument, from the above equation, is between 0 and PI. The reduced argument is then tested to see if is greater than from
PI to yield the final value. If it is not, then the reduced argument is the final
value.
Although this method of angle reduction provides a simple and economical means of generating the appropriate arguments for a Taylor series, there is an accuracy problem associated with this technique. The accuracy problem is noticed when the user argument is large (example:
greater than 1000). This is because significant
digits in the decimal (fraction) portion of the reduced argument are lost in the
(user arg/PI - INT (user arg/PI)) expression. As a general rule, keep the
arguments for the trigonometric functions as small as possible.
PI/2. If it is, then it is subtracted

Functional Operators

The module contains a complete set of functional operators. These operators are single-operand operators.
ABS([expr])
Use the ABS operator to return the absolute value of the expression.
Example Result
>PRINT ABS(5) 5 >PRINT ABS(–5) 5
NOT([expr])
Use the NOT operator to return a 16-bit one’s complement of the expression. The expression must be a valid integer (example:
inclusive
Example Result
>PRINT NOT(65000) 535 >PRINT NOT(0) 65535
). Non-integers are truncated, not rounded.
between 0 and 65535 (0FFFFH)
Publication 1746-RM001A-US-P
3-10 Expressions and Operators
INT([expr])
Use the INT operator to return the integer portion of the expression.
Example Result
>PRINT INT(3.7) 3
>PRINT INT(100.876) 100
PI
PI is a stored constant. In the module PI is stored as 3.1415926.
SGN([expr])
Use the SGN operator to return a value of +1 if the argument is greater than zero, zero if the argument is equal to zero, and –1 if the argument is less than zero.
Example Result
>PRINT SGN(52) 1 >PRINT SGN(0) 0 >PRINT SGN(–8) -1
SQR([expr])
Use the SQR operator to return the square root of the argument. The argument may not be less than zero.
Example Result
>PRINT SQR(9) 3 >PRINT SQR(45) 6.7082035 >PRINT SQR(100) 0
Publication 1746-RM001A-US-P
Expressions and Operators 3-11
RND
Use the RND operator to return a pseudo-random number in the range between 0 and 1 inclusive. The RND operator uses a 16-bit binary seed and generates 65536 pseudo-random numbers before repeating the sequence. The numbers generated are specifically between 0/65535 and 65535/65535 inclusive.
IMPORTANT
Example Result
>PRINT RND .26771954
Unlike most BASIC languages, the RND operator in the module does not require an argument or a dummy argument. If an argument is placed after the RND operator, a bad syntax error occurs.

Logarithmic Operators

The module contains a complete set of logarithmic operators. These operators are single-operand operators.
LOG([expr])
Use the LOG operator to return the natural logarithm of the argument. The argument must be greater than 0. This calculation is carried out to 7 significant digits.
Example Result
>PRINT LOG(12) 2.484906 >PRINT LOG(EXP(1)) 1
If base 10 logs are needed, the following expression may be used:
(x)=log(x)/log(10)
log
10
The log is natural.
EXP([expr])
Use the EXP operator to raise the number e (2.7182818) to the power of the argument.
Example Result
>PRINT EXP(1) 2.7182818 >PRINT EXP(LOG(2)) 2
Publication 1746-RM001A-US-P
3-12 Expressions and Operators

String Operators

Two operators in the module can manipulate STRINGS. These operators are ASC( ) and CHR( ).
ASC([expr])
Use the ASC operator to return the integer value of the ASCII character placed in the parentheses.
>1 REM EXAMPLE PROGRAM >10 PRINT ASC(a) >20 PRINT ASC(A)
READY >RUN
65 65
READY >
The decimal representation for the ASCII character A is 65. The decimal representation for the ASCII character a is 97. However, the module capitalizes all ASCII characters not contained within quotation marks. Similarly, special ASCII characters whose decimal value is greater than 127 should not be used.
In addition, you can evaluate individual characters in a defined ASCII string with the ASC operator.
>1 REM EXAMPLE PROGRAM >5 STRING 1000,40 >10 $(1) =“THIS IS A STRING” >20 PRINT $(1) >30 PRINT ASC($(1),1) >40 END
READY >RUN
THIS IS A STRING 84
READY >
Publication 1746-RM001A-US-P
Expressions and Operators 3-13
When you use the ASC operator as shown above, the $([expr]) denotes what string is accessed. The expression after the comma selects an individual character in the string. In the above example, the first character in the string is selected. The decimal representation for the ASCII character T is 84. String character position 0 is invalid.
>NEW
>1 REM EXAMPLE PROGRAM >5 STRING 1000,40 >10 $(1)=“ABCDEFGHIKJL” >20FORX=1TO12 >30 PRINT ASC($(1),X), >40 NEXT X >50 END
READY >RUN
65 66 67 68 69 70 71 72 73 75 74 76 READY >
The numbers printed in the previous example represent the ASCII characters A through L.
You can also use the ASC operator to change individual characters in a defined string.
In general, the ASC operator lets you manipulate individual characters in a string. A simple program can determine if two strings are identical.
>NEW
>1 REM EXAMPLE PROGRAM >5 STRING 1000,40 >10 $(1) = “ABCDEFGHIJKL” >20 PRINT $(1) >30 ASC($(1),1) = 75 : REM DECIMAL EQUIVALENT OF K >40 PRINT $(1) >50 ASC($(1),2) = ASC($(1),3) >60 PRINT $(1)
READY >RUN
ABCDEFGHIJKL KBCDEFGHIJKL KCCDEFGHIJKL
READY >
Publication 1746-RM001A-US-P
3-14 Expressions and Operators
CHR([expr])
Use the CHR operator to convert a numeric expression to an ASCII character.
Example Result
>PRINT CHR(65) A
Like the ASC operator, the CHR operator also selects individual characters in a defined ASCII string.
>NEW
>1 REM EXAMPLE PROGRAM >5 STRING 1000,40 >10 $(1) = “The module” >20 FOR I = 1 TO 16 : PRINT CHR($(1),I),: NEXT I
READY >RUN
The module READY >
In the example above, the expressions contained within the parentheses, following the CHR operator have the same meaning as the expressions in the ASC operator.
Unlike the ASC operator, you cannot assign the CHR operator a value. A statement such as CHR ($(1),1)= H is INVALID and generates an
ERROR: BAD SYNTAX
message, causing the module to go into Command mode. Use the ASC operator to change a value in a string, or use the string support CALL routine – replace string in a string.
IMPORTANT
Use the CHR function only in a print statement. You cannot use the CHR operator in a DATA statement.
Publication 1746-RM001A-US-P
Expressions and Operators 3-15

Special Function Operators

The module contains a complete set of special function operators. These operators manipulate the I/O hardware and memory addresses of the module.
# and @
Use the # and @ operators to direct communications. Communication takes place through port PRT1 when the @ operator is programmed, and through port PRT2 when the # operator is programmed. The absence of either the # or @ operators indicates that communication should take place through a program port (port PRT1 or port DH485).
Example Result
>10 A = GET# >10 A = GET@
The next character in the PRT2 input buffer is assigned to variable A. The next character in the PRT1 input buffer is assigned to variable A.
EOF
Use the EOF operator to test for an empty input buffer before executing an input statement or function. This prevents input statements from waiting indefinitely on empty input buffers. Use the EOF# statement to test for an empty input buffer for port PRT2. Use the EOF@ statement to test for an empty input buffer for port PRT1.
>10 REM EXAMPLE PROGRAM >20 IF (NOT(EOF)) THEN A=GET >30 REM IF BUFFER NOT EMPTY, READ SINGLE CHARACTER
FREE
Use the system control value FREE to tell you how many bytes of RAM are available to the user. When the current selected program is in RAM, the following relationship is true:
FREE = MTOP – LEN – 511
LEN
Use the system control value LEN to tell you how many bytes of memory the currently selected program occupies. This is the length of the program and does not include the size of string memory or the variables and array memory usage. You cannot assign LEN a value, it can only be read. A NULL program (example: no program) returns a LEN of 1. The 1 represents the end of program file character.
IMPORTANT
The module does not require any dummy arguments for the system control values.
Publication 1746-RM001A-US-P
3-16 Expressions and Operators
MTOP
Use the MTOP operator to retrieve the last valid memory address in RAM that is available to the module. After reset, the module sizes the external memory and assigns the last valid memory address to the system control value MTOP. The module does not use any external RAM beyond the value assigned to MTOP. If this value has not been changed by CALL 77, then the last valid BASIC address is 5FFFH (24575).
Example Result
>PRINT MTOP 24575 PH0.MTOP 5FFFH
CBY([expr])
Use the CBY operator to retrieve data from the program or code memory address location of the module. You cannot assign CBY a value; it can only be read. The argument for the CBY operator must be a valid integer between 0 and 65535 (0FFFFH). If it is not a valid integer, a bad argument error occurs.
IMPORTANT
Improper use of this operator may cause a malfunction of the module.
Example Result
A = CBY(1000)
The value in the program or code memory address location 1000 is assigned to variable A.
DBY([expr])
Use the DBY operator to retrieve or assign data to or from the internal data memory of the module. Both the value and the argument in the DBY operator must between 0 and 255 inclusive. This is because there are only 256 internal memory locations in the module and one byte can only represent a quantity between 0 and 255 inclusive.
IMPORTANT
Example Result
A = DBY(B)
DBY(250) = CBY(1000)
Improper use of this operator may cause a malfunction of the module.
The value in internal memory location B is assigned to variable A. B must be between 0 and 255.
The value in program or code memory location 1000 is assigned to internal memory location 250.
Publication 1746-RM001A-US-P
Expressions and Operators 3-17
XBY([expr])
Use the XBY operator to retrieve or assign data to or from the external data memory of the module. The argument for the XBY operator must be a valid integer between 0 and 65535 (0FFFFH). The value assigned to the XBY operator must between 0 and 255 inclusive. If it is not, a bad argument error occurs.
IMPORTANT
Example Result
A = XBY(0F000H)
XBY(4000H) = DBY(100)
Improper use of this operator may cause a malfunction of the module.
The value in external memory location 0F00H is assigned to variable A.
The value in internal memory location 100 is assigned to external memory location 4000H.
TIME
Use the TIME operator to retrieve or assign a value to the free running clock resident in the module. After reset, time is equal to 0. The CLOCK1 statement enables the free running clock. When the free running clock is enabled, the special function operator TIME increments once every 5 milliseconds. The units of time are in seconds.
When TIME is assigned a value with a LET statement (example:
TIME=100), only
the integer portion of TIME is changed.
>CLOCK1 (enable FREE RUNNING CLOCK)
>CLOCK0 (disable FREE RUNNING CLOCK)
>PRINT TIME (display TIME)
3.315
>TIME = 0 (set TIME = 0)
>PRINT TIME (display TIME)
.315 (only the integer is changed)
Publication 1746-RM001A-US-P
3-18 Expressions and Operators
You can change the fraction portion of TIME by manipulating the contents of internal memory location 71 (47H). You can do this by using a DBY(71) statement. Each count in internal memory location 71 (47H) represents 5 milliseconds of TIME.
Continuing with the example:
>DBY(71) = 0 (fraction of TIME = 0)
>PRINT TIME 0
>DBY(71) = 3 (fraction of TIME = 3*5ms = 15 ms)
>PRINT TIME
1.5 E–2
Only the integer portion of TIME changes when a value is assigned. This allows you to generate accurate time intervals. For example, if you want to create an accurate 12-hour clock: there are 43200 seconds in a 12-hour period, so an ONTIME 43200, [ln num] statement is used. When the TIME interrupt occurs, the statement TIME 0 is executed, but the millisecond counter is not re-assigned a value. If interrupt latency exceeds 5 milliseconds, the clock remains accurate.
Publication 1746-RM001A-US-P
Chapter
4

BASIC Commands

This chapter describes and illustrates words and expressions that cause a function to occur within the BASIC program or the command line. Table 4.1 lists the corresponding mnemonics.
Table 4.1 Chapter Reference Guide
If you need (to) Use this mnemonic Page
Set the program break point. BRKPNT 4-2 Re-enable the Disable the Continue after a Stop or Stop execution & return to Command mode. CONTROL-C 4-4 Restart a list after Interrupt a list command. CONTROL-S 4-7 Edit a line of the BASIC program. EDIT 4-8 Delete the last BASIC program stored in ROM by a PROG
command. Force the module to enter “wait until interrupt mode”. IDLE 4-10 List the program to the console devise. LIST 4-11 List the program to the serial printer. LIST# 4-12 List the program to the device connected to port PRT1. LIST@ 4-12 Set port parameters of ports PRT1, PRT2, and DH485. MODE 4-12 Erase the program stored in RAM. NEW 4-14 Set NULL count after carriage return-line feed. NULL 4-14 Save the current program in EPROM. PROG 4-15 Save the baud rate information in EPROM. PROG1 4-16 Save the baud rate information in EPROM and execute the
program after reset. Evoke RAM mode. RAM 4-19 Specify a remark or comment line. REM 4-19 Renumber the BASIC program. REN 4-20 Select ROM mode. ROM 4-20 Select ROM mode and execute the selected program. RROM 4-21 Execute a program. RUN 4-22 Initiate single-step program execution. SNGLSTP 4-23 Verify the module firmware version. VER 4-25 Transfer a program from ROM to RAM. XFER 4-26
[CTRL-C] break function. CALL 18 4-5
[CTRL-C] break function. CALL 19 4-6
[CTRL-C].CONT4-3
[CTRL-S]. CONTROL-Q 4-8
ERASE 4-9
PROG2 4-17
1 Publication 1746-RM001A-US-P
4-2 BASIC Commands

BRKPNT

Purpose
Use the BRKPNT command to set a program break point at the line number specified by this command. Program execution stops just before the line number specified by the BRKPNT command. If the line number is zero, the break point is disabled. After the break point is reached, you can examine variables by using assignment statements. Continue from the break point by using the CONT command. Once the break point is reached, it is disabled. To stop at the same place twice, set the break point twice. The BRKPNT command works only on programs executing from RAM. It does not stop a program executing from ROM.
Syntax
BRKPNT[ln num]
Example
>1 REM EXAMPLE PROGRAM >10 D=0 : SU=0 : AV=0 >20 REM GET 100 DATUM POINTS >30 FOR I=1 TO 100 >40 REM GET ANOTHER DATUM >50 GOSUB 140 >60 REM SUM THE DATA >70 GOSUB 170 >80 NEXT I >90 REM AVERAGE THE DATA >100 GOSUB 200 >110 REM PRINT RESULT >120 PRINT “THE AVERAGE VALUE IS ”,AV >130 END >140 REM THIS SUBROUTINE GENERATES RANDOM DATA >150 D=RND >160 RETURN >170 REM THIS SUBROUTINE SUMS THE DATA >180 SU=SU+D >190 RETURN >200 REM THIS SUBROUTINE AVERAGES THE DATA >210 AV=SU/I >220 RETURN
Publication 1746-RM001A-US-P
READY >BRKPNT 160
Breakpoint enabled.
READY >RUN
STOP - IN LINE 160 READY >PRINT D,SU,AV
.86042573 0 0
>D=.5
>PRINT D,SU,AV
.500
>CONT
THE AVERAGE VALUE IS .48060383
READY >
BASIC Commands 4-3

CONT

Purpose
Use the CONT command to resume execution of a program stopped by a
[CTRL-C], BRKPNT command, or a STOP statement. If you stop a program by
pressing you can resume execution of the program by typing CONT. If you press while
[CTRL-C] on the console device or by execution of a STOP statement,
[CTRL-C]
[CTRL-C] is enabled, it stops the program. Use CONT to continue. Between
the stopping and the re-starting of the program you may display the values of variables or change the values of variables. However, you cannot CONTinue if the program is modified during the STOP or after an error.
IMPORTANT
[CTRL-C] clears all input and output buffers.
Syntax
CONT
Publication 1746-RM001A-US-P
4-4 BASIC Commands
Example
>NEW
>1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 10000 >20 PRINT I >30 NEXT I >40 END
READY >RUN
1 2 3 4 5 6 7 8 9
10 [CTRL-C]
pressed

Control-C

STOP - IN LINE 15 READY >CONT
20 21 22
Purpose
Use the [CTRL-C] command to stop execution of the current program and return the module to the Command mode. In some cases you can continue execution of the program using a CONTinue. See the explanation for CONTinue for more information.
IMPORTANT
[CTRL-C] clears all input and output buffers.
Syntax
[CTRL-C]
Publication 1746-RM001A-US-P
Example
>1 REM EXAMPLE PROGRAM >10 FOR I = 1 TO 10000
>20 PRINT I >30 NEXT I >40 END >RUN
1 2 3 4
5 [CTRL-C]
STOP – IN LINE 20
READY >PRINT I
27
>I =10
>CONT
10 11 12
BASIC Commands 4-5
pressed

CALL 18 – Re-enable the Control-C Break Function

Notice that after [CTRL-C] is pressed and I is printed the value of I is 27. The value of I is incremented several times before
[CTRL-C] is detected.
Purpose
Re-enable the [CTRL-C] break function by executing CALL 18 in a module program or from the Command mode.
IMPORTANT
When [CTRL-C] is disabled, you are unable to stop program execution through a BASIC command. Cycling power re-enables disables power and press
[CTRL-C] is executed.
[CTRL-C] checking until the program once again
[CTRL-C]. To stop program execution,you must cycle
[CTRL-C] before the line that disables
Publication 1746-RM001A-US-P
4-6 BASIC Commands
Syntax
CALL 18
Example
>1 REM EXAMPLE PROGRAM >10 CALL 19 . >90 CALL 18

CALL 19 – Disable the Control-C Break Function

Purpose
Disable the [CTRL-C] break function by executing CALL 19 in a module program or from the Command mode.
When CALL 19 is executed, the RUN operations is disabled. Cycling power returns the normal operation if it is disabled from the Command mode
.
IMPORTANT
[CTRL-C] is enabled by default.
[CTRL-C] break function for both LIST and
[CTRL-C] function to
Syntax
CALL 19
Example
>1 REM EXAMPLE PROGRAM >10 CALL 19
Publication 1746-RM001A-US-P
BASIC Commands 4-7

Control-S

Purpose
Use the [CTRL-S] command to interrupt the scrolling of a BASIC program during the execution of a LIST command. port if you are running a program. In this case XOFF (
[CTRL-S] stops output from the transmitting
[CTRL-S]) operates as
follows:
XOFF only operates on PRINT statements.
When received during a PRINT, data output is suspended immediately but
program execution continues.
When received at any other time, the program continues until encountering a
PRINT statement. At this time data output is suspended. The program continues to fill the output buffer until the buffer is full.
XON ([CTRL-Q]) is required to resume data output operation.
IMPORTANT
[CTRL-S] only works if you have enabled software
handshaking on the program port.
Syntax
[CTRL–S]
Example
> LIST 1 REM EXAMPLE PROGRAM 10A=1 20 DO [CTRL–S] . . . [CTRL–Q] 30A=A+1 40 PRINT A 50 WHILEA<20
READY >
In this example, the output is suspended when [CTRL–S] is pressed. The output is continued after
[CTRL–Q] is pressed.
Publication 1746-RM001A-US-P
4-8 BASIC Commands

Control-Q

Purpose
Use the [CTRL-Q] command to restart a LIST command or PRINT output that is interrupted by
[CTRL-S].
Syntax
[CTRL–Q]
Example
> LIST 1 REM EXAMPLE PROGRAM 10A=1 20 DO [CTRL–S] . . . [CTRL–Q] 30 A = A+1 40 PRINT A 50 WHILEA<20

EDIT

READY >
In this example, the output is suspended when [CTRL–S] is pressed. The output is continued after
[CTRL–Q] is pressed.
Purpose
Use the EDIT command to access the BASIC line editor. Use this editor to edit a line of the current program in RAM. Table 4.2 lists the BASIC editor operations.
Publication 1746-RM001A-US-P
Table 4.2 BASIC Editor Operations
Operation Function Key Strokes
Move Use the Move operation to provide
right/left cursor control.
Replace Use the Replace operation to replace
the character at the current cursor position.
Insert Use the Insert operation to insert text
at the current cursor position.
Important: When you use the Insert operation, all text to the right of the cursor disappears until you press the second
[Ctrl–A]. Total line length is
79 characters.
Delete Use the Delete operation to delete the
character at the cursor position.
Exit Use the Exit operation(s) to exit the
editor with or without saving the changes.
Retype Use the Retype operation to copy the
current line of text and insert it at the line following the current line. The cursor is moved to the first character on the new line.
[Space bar] – moves the cursor one
space to the right.
[Backspace] – moves the cursor one
space to the left. Press the key that corresponds to the
character that replaces the character at the current cursor position.
[Ctrl–A]
Important: You must press a second
[Ctrl–A] to terminate the Insert
command.
[Ctrl–D]
[Ctrl–Q] – exits the editor and
replaces the old line with the edited line.
[Ctrl–C] – exits the editor without
saving any changes made to the line.
[RETURN]
BASIC Commands 4-9

ERASE

Syntax
EDIT
Example
>EDIT 150
Displays program line number 150 for editing.
Purpose
Use the ERASE command to delete the last BASIC program stored in EEPROM through a PROG command.
Syntax
ERASE
Publication 1746-RM001A-US-P
4-10 BASIC Commands
Example
>ERASE
>ROM 13 ERASED
The last program stored in EEPROM (ROM 13 in this example) is erased.

IDLE

Purpose
Use the IDLE command to force the module to enter wait until Interrupt mode. Program execution halts until an ONTIME condition is met. The ONTIME interrupt must be enabled before executing the IDLE command or else the module enters a wait forever mode.
[CTRL-C] exits the IDLE command if [CTRL-C] is
enabled.
Syntax
IDLE
Example
>1 REM EXAMPLE PROGRAM >10 TIME = 0 >20 CLOCK1 >30 ONTIME 2,70 >40 IDLE >50 PRINT “END OF TEST!!!” >60 END >70 PRINT “TIMER INTERRUPT AT – ”,TIME,“SECONDS.” >80 RETI
Publication 1746-RM001A-US-P
READY >RUN
TIMER INTERRUPT AT – 2.005 SECONDS. END OF TEST!!!
BASIC Commands 4-11

LIST

Purpose
Use the LIST command to print the program to the console device. Spaces are inserted after the line number, and before and after statements. This helps in the debugging of module programs. You can terminate the listing of a program at any time by pressing the listing using
IMPORTANT
[CTRL-C] on the console device. You can interrupt and continue
[CTRL-S] and [CTRL-Q].
[CTRL–C] terminates the listing if [CTRL–C] checking is
enabled.
[CTRL–S] halts the listing until [CTRL–Q] is pressed if
software handshaking in enabled.
Syntax
LIST [ln num]
LIST [ln num] - [ln num]
The first variation causes the program to print from the designated line number [ln num] to the end of the program. The second variation causes the program to print from the first designated line number [ln num] to the second designated line number [ln num].
IMPORTANT
You must separate the two line numbers with a dash (–).
Example
>LIST 1 REM EXAMPLE PROGRAM 10 PRINT “LOOP PROGRAM” 20FORI=1TO3 30 PRINT I 40 NEXT I 50 END
READY >LIST 30 1 REM EXAMPLE PROGRAM 30 PRINT I 40 NEXT I 50 END
READY >LIST 20–40 1 REM EXAMPLE PROGRAM 20FORI=1TO3 30 PRINT I 40 NEXT I
Publication 1746-RM001A-US-P
4-12 BASIC Commands

LIST@

LIST#

Purpose
Use the LIST@ command to print the program to the device attached to port PRT1. All comments that apply to the LIST command apply to the LIST@ command. You must configure PRT1 port parameters to match your particular list device. The PRT1 parameters (baud rate, parity, stop bits, and so on) can be set using the MODE command.
Syntax
LIST@
Examples
LIST@ :REM LISTS ALL LINES IN THE PROGRAM
LIST@10–20 :REM LISTS LINES 10 THROUGH 20
Purpose

MODE

Use the LIST# command to print the program to the device attached to port PRT2. All comments that apply to the LIST command apply to the LIST# command. You must configure the PRT2 port parameters to match your particular list device. The PRT2 parameters (baud rate, parity, stop bits, and so on) can be set using the MODE command.
Syntax
LIST#
Example
Refer to LIST@ examples.
Purpose
Use the MODE command to set the port parameters of ports PRT1, PRT2, and DH485. Table 4.3 lists the port parameters and default settings for ports PRT1 and PRT2. Table 4.4 lists the port parameters for port DH485.
Publication 1746-RM001A-US-P
BASIC Commands 4-13
Table 4.3 PRT1 and PRT2 Port Parameters
Port Parameters Selections Default Settings
baud rate 300, 600, 1200, 2400, 4800, 9600, 19200 1200 arg1 (parity) None (N), Even (E), Odd (O) N arg2 (number of data bits) 7 or 8 8 arg3 (number of stop bits) 1 or 2 1 arg4 (handshaking) No handshaking (N)
Software handshaking (S) Hardware handshaking (H) Hardware and software handshaking (B)
arg5 (storage type) Store information in user ROM and RAM (E)
Store information in battery backed RAM (R)
S
R
IMPORTANT
If any argument (other than port name and baud rate) is left blank, then that argument defaults to the previously specified value for that argument.
Table 4.4 DH485 Port Parameters
Port Parameters Selections Default
Settings
baud rate 300, 600, 1200, 2400, 4800, 9600, 19200 19200 arg1 (host node address) 0 to 31 0 arg2 (module node address) 0 to 31 1 arg3 (maximum node address) 1 to 31 31 arg4 (not used) arg5 (storage type) Store information in user ROM and RAM (E)
Store information in battery backed RAM (R)
IMPORTANT
If any argument (other than port name) is left blank, then that argument defaults to the previously specified value for that
R
argument.
Syntax
MODE(port name, baud rate, arg1, arg2, arg3, arg4, arg5)
Publication 1746-RM001A-US-P
4-14 BASIC Commands
Example
>1 REM EXAMPLE PROGRAM >10 MODE(DH485,19200,0,1,2,,R) . . . >25 MODE(PRT1,1200,N,8,,,)
NEW
IMPORTANT
The E storage type option cannot be used if MODE is used as a statement.
Purpose
Use the NEW command to delete the program currently stored in RAM. In addition, all variables are set equal to ZERO; all strings and all BASIC evoked interrupts are cleared. The free running clock, string allocation, and internal stack pointer values are not affected. The NEW command is used to erase a program and all variables in RAM.
Syntax
NEW
Example
>NEW
>LIST

NULL

Publication 1746-RM001A-US-P
>READY >
Purpose
Use the NULL command to determine how many NULL characters (00H) the module outputs after a carriage return in a print statement. After initialization this value is set to 0. Most printers contain a RAM buffer that eliminates the need to output NULL characters after a carriage return.
Syntax
NULL[integer]
BASIC Commands 4-15

PROG

IMPORTANT
Before you attempt to program EEPROM, read the PROG, PROG1 and PROG2 sections of this chapter.
Purpose
Use the PROG command to program the resident EEPROM with the current program in RAM. The module cannot program UVPROMs.
IMPORTANT
Be sure you have selected the program you want to save before using the PROG command. Your module does not automaticallycopy the RAM program to EEPROM. If an error
After you type
occurs during EEPROM programming, the message
Programming sequence failure
PROG, the module displays the number in the EEPROM FILE the
is displayed.
ERROR:
program occupies. Programming takes only a few seconds.
Syntax
PROG
Example
>LIST 1 REM EXAMPLE PROGRAM 10 FOR I=1 TO 10 20 PRINT I 30 NEXT I 40 END
READY >PROG
ROM 12
Programming sequence successful.
READY >ROM 12
>LIST 1 REM EXAMPLE PROGRAM 10 FOR I=1 TO 10 20 PRINT I 30 NEXT I 40 END
READY >
The program just placed in the EEPROM is the 12th program stored.
Publication 1746-RM001A-US-P
4-16 BASIC Commands

PROG1

IMPORTANT
IMPORTANT
If you exceed the available EEPROM space, you cannot continue programming until it is erased. Use the ERASE command to erase the last program stored in EEPROM. Be sure to use CALL 81 or CALL 82 to determine memory space prior to programming your EEPROM. Refer to chapter 5 for information regarding CALLs 81 and 82.
Before you attempt to program an EEPROM, read the PROG, PROG1 and PROG2 sections of this chapter.
Purpose
Use the PROG1 command to program the resident EEPROM with port information for all three ports as well as store MTOP information. At module powerup, the module reads this information and initializes MTOP and all three serial ports. The sign-on message is sent to the console immediately after the module completes its reset sequence. If the baud rate on the console device changes, you must re-program the EEPROM to make the module compatible with the new console. Re-program by changing the appropriate port or MTOP information, then execute PROG1 again.
Syntax
PROG1
Example
READY >PROG1
Programming sequence successful.
Publication 1746-RM001A-US-P
BASIC Commands 4-17

PROG2

IMPORTANT
Before you attempt to program an EEPROM, read the PROG, PROG1 and PROG2 sections of this chapter. Note, the PROG2 command does not transfer the RAM program to EEPROM. The PROG2 command enables the first program in EEPROM to be loaded at each powerup.
Purpose
Use the PROG2 command the same as you would the PROG1 command except for the following: instead of signing on and entering the Command mode, the module immediately begins executing the first program stored in the resident EEPROM. Otherwise, it executes the program stored in RAM.
You can use the PROG2 command to RUN a program on powerup without connecting to a console. Saving PROG2 information is the same as typing a ROM 1, RUN command sequence. This feature also allows you to write a special initialization sequence in BASIC and generate a custom sign-on message for specific applications. The PROG2 command does not alter the first program in the memory module.
IMPORTANT
The PROG2 command does not cause the module to RUN at powerup if PRT1 default communications are selected via JW4. Refer to Chapter 3 of the SLC 500™ BASIC and BASIC-T Modules User Manual (publication number 1746-UM004A-US-P) for more information.
The following figure shows the module operation from a power-up condition using PROG1 and PROG2, or battery backed RAM.
Syntax
PROG2
Example
READY >PROG2
Programming sequence successful.
Publication 1746-RM001A-US-P
4-18 BASIC Commands
Figure 4.1 Operation of PROG1 or PROG2
Start
Is
battery backup
enabled?
Yes
Has
PROG1 or PROG2
been executed?
Is
battery-backed RAM MTOP and Port information
valid?
Yes
Initialize ports using
battery-backed RAM
Is
user EEPROM
checksum correct?
No
No
Yes
No
Erase RAM
program
Erase MTOP and port
information in
battery-backed RAM
Copy EEPROM MTOP and
port information to
battery-backed RAM
Store default MTOP and
port information in
battery-backed RAM
Print sign-on message
Yes
Has
PROG2
been executed?
No
Is
RAM program
present?
No
Print sign-on
message
Enter Command
Mode
Yes
Yes
Print checksum error
message
Enter command mode
Execute ROM1
Execute RAM program
Publication 1746-RM001A-US-P
BASIC Commands 4-19
RAM
Purpose
Use the RAM command to tell the module interpreter to select the current program out of RAM. The current program is displayed during a LIST command and executed when
IMPORTANT
Available user RAM = MTOP–H
H =LEN+S+6*A+ 8*V+512
Where:
LEN = system control value that contains current RAM program length
S = number of bytes allocated for strings (first value in the STRING instruction)
A = sum of all (array sizes +1)
V = sum of all variable names used (including each array name)
RUN is typed.
RAM space is limited to 24K bytes. Use the following formula to calculate the available user RAM space
REM
Syntax
RAM
Example
READY >RAM
Purpose
Use the REM command to specify a comment line in a BASIC program. Adding comment lines to a program makes the program easier to understand. Program lines that start with a REM command cannot be terminated with a colon (:). REM commands can be placed after a colon (:) in a program line. This allows you to place a comment on each line.
IMPORTANT
REM commands add time to program execution. Use them selectively or place them at the end of the program where they do not affect program execution speed. Do not use REM commands in frequently-called loops or subroutines.
Publication 1746-RM001A-US-P
4-20 BASIC Commands
Syntax
REM
Example
>10 REM THIS IS A COMMENT LINE >20 NEW : REM THIS IS ALSO A COMMENT LINE
REN
Purpose
Use the REN command to renumber program lines.
Syntax
REN[new number],[old number],[increment]
Examples
Example Result
REN
REN 20
REN 300,50
REN 1000,900,20
Renumbers the entire program. The first new line number is 10. Line numbers increment by 10.
Renumbers the entire program. The first new line number is 10. Line numbers increment by 20.
Renumbers the entire program. The first new line number is 300. Line numbers increment by 50.
Renumbers the program from line 900 on up. Line number 900 becomes line number 1000. Any following line numbers increment by
20.
ROM
Publication 1746-RM001A-US-P
Purpose
Use the ROM command to tell the module interpreter to select the current program out of EEPROM or UVPROM. The current program is displayed during a LIST command and executed when
IMPORTANT
Your module can execute and store up to 255 programs in EEPROM depending on the size of the programs and the capacity of the EEPROM. The programs are stored in a sequence string, referred to as the EEPROM file, in EEPROM for retrieval and execution.
RUN is typed.
BASIC Commands 4-21
When you enter ROM [integer], the module selects that program out of EEPROM memory and makes it the current program. If no integer is typed after the ROM command (example:
ROM) the module defaults to ROM 1. Since the programs are
stored in sequence in EEPROM, the integer following the ROM command selects the program the user wants to run or list. If you attempt to select a program that does not exist (example: you type EEPROM) the message
ERROR: PROM MODE is displayed.
ROM 8 and only 6 programs are stored in the
The module does not transfer the program from EEPROM to RAM when the ROM mode is selected. If you attempt to alter a program in the ROM mode by typing in a line number, the message
ERROR: PROM MODE is displayed. The XFER
command allows you to transfer a program from EEPROM to RAM for editing purposes. You do not get an error message if you attempt to edit a line of RAM program.
IMPORTANT
When you transfer programs from EEPROM to RAM you lose the previous RAM contents.
Since the ROM command does not transfer a program to RAM, it is possible to have different programs in ROM and RAM simultaneously. You can move back and forth between the two modes when in Command mode. If you are in Run mode, you can change back and forth using CALLS 70, 71, and 72. You can also use all of the RAM for variable storage if the program is stored in EEPROM. The system control value MTOP always refers to RAM. The system control value LEN refers to the currently selected program in RAM or ROM.
Syntax
ROM[integer]
Example
READY >ROM1

RROM

Purpose
Use the RROM command to tell the module interpreter to select the current program out of EEPROM or UVPROM and then execute the program. This command is equivalent to typing
IMPORTANT
Your module can execute and store up to 255 programs in EEPROM depending on the size of the programs and the capacity of the EEPROM. The programs are stored in a sequence string, referred to as the EEPROM file, in EEPROM for retrieval and execution.
ROM and then RUN.
Publication 1746-RM001A-US-P
4-22 BASIC Commands
When you enter RROM [integer], the module selects that program out of EEPROM memory, makes it the current program, and starts program execution. If no integer is typed after the RROM command (example:
RROM) the module
defaults to RROM 1. Since the programs are stored in sequence in EEPROM, the integer following the RROM command selects the program the user wants to run or list. If you attempt to select a program that does not exist (example: you type
RROM 8 and only 6 programs are stored in the EEPROM) the message ERROR: PROM MODE is displayed.
The module does not transfer the program from EEPROM to RAM when ROM mode is selected. If you attempt to alter a program in ROM mode by typing in a line number, the message
ERROR: PROM MODE is displayed. The XFER command
allows you to transfer a program from EEPROM to RAM for editing purposes. You do not get an error message if you attempt to edit a line of RAM program.
IMPORTANT
When you transfer programs from EEPROM to RAM you lose the previous RAM contents.
Since the RROM command does not transfer a program to RAM, it is possible to have different programs in ROM and RAM simultaneously. You can move back and forth between the two modes when in Command mode. If you are in Run mode, you can change back and forth using CALLS 70, 71, and 72. You can also use all of the RAM for variable storage if the program is stored in EEPROM. The system control value MTOP always refers to RAM. The system control value LEN refers to the currently selected program in RAM or ROM.
Syntax
RROM[integer]
Example
READY >RROM
RUN
Publication 1746-RM001A-US-P
Purpose
Use the RUN command to set all variables equal to zero, clear all BASIC evoked interrupts, and begin program execution with the first line number of the selected program. The RUN command and the GOTO statement are the only ways you can place the module interpreter into Run mode from Command mode. Terminate program execution at any time by pressing
[CTRL-C] on the console device.
Syntax
RUN
BASIC Commands 4-23
Variations
Some BASIC interpreters allow a line number to follow the RUN command (example:
RUN 100). The module does not permit this variation on the RUN
command.
Execution begins with the first line number. To obtain a function similar to the RUN [ln num] command, use the GOTO [ln num] statement in the Direct mode. See statement GOTO in chapter 7.
Example
>1 REM EXAMPLE PROGRAM >10FORI=1TO3 >20 PRINT I >30 NEXT I >40 END >RUN
1 2 3

SNGLSTP

READY >
Purpose
Use the SNGLSTP command to initiate single-step program execution. If the number specified by this command is zero, single-step execution is disabled. If the number is not zero, a break point is set before each line in the program. Start the program by typing the RUN command. After each stop, type
CONT to execute the
next line. You can inspect variables or assign variables at each break point. SNGLSTP works only on programs executing from RAM. It does not stop a program executing from EEPROM.
Syntax
SNGLSTP[integer]
Publication 1746-RM001A-US-P
4-24 BASIC Commands
Example
>1 REM EXAMPLE PROGRAM >10FORI=1TO5 >20 PRINT I >30 NEXT I >40 PRINT “PASSED FOR – NEXT LOOP” >50 PRINT “THIS IS THE END” >60 END
READY >SNGLSTP 20
SINGLE STEP ENABLED
READY >RUN
STOP – LINE 20 READY >CONT
1
STOP – LINE 30 READY >CONT
STOP – LINE 20 READY >CONT
2
STOP – LINE 30 READY >CONT
STOP – LINE 20 READY >CONT
3
STOP – LINE 30 READY >SNGLSTP 0
Publication 1746-RM001A-US-P
SINGLE STEP DISABLED
READY >CONT
4 5 PASSED FOR – NEXT LOOP THIS IS THE END
READY >
BASIC Commands 4-25
VER
Purpose
Use the VER command to print the module sign-on message that displays the current version of the firmware.
Syntax
VER
Example
>VER SLC 500 module–Catalog Number 1746-BAS Firmware release: x.xx Allen–Bradley Company, Copyright 19xx All rights reserved
>
Publication 1746-RM001A-US-P
4-26 BASIC Commands

XFER

Purpose
Use the XFER command to transfer the current selected program in ROM to RAM and select RAM mode. After the XFER command executes, you can edit the program in the same way you edit any RAM program.
IMPORTANT
The XFER command clears existing RAM programs.
Syntax
XFER
Example
READY >XFER
Publication 1746-RM001A-US-P
Chapter
5

Command Line CALLs

This chapter describes and illustrates CALLs that cause a function to occur within the BASIC or BASIC-T module. These CALLs cannot be executed within the BASIC program but are entered at the command line. Table 5.1 lists the corresponding mnemonics.
Table 5.1 Chapter Reference Guide
If you need (to) Use this mnemonic Page
Battery-backed RAM disable CALL 73 5-1 Battery-backed RAM enable CALL 74 5-2 Protected variable storage CALL 77 5-2 User memory module check and description CALL 81 5-3 Check the user memory module map. CALL 82 5-4 Upload the user memory module code to host. CALL 101 5-4 Print port PRT1 output buffer and pointer. CALL 103 5-5 Print port PRT1 input buffer and pointer. CALL 104 5-6 Print the argument stack. CALL 109 5-7 Print port PRT2 output buffer and pointer. CALL 110 5-8 Print port PRT2 input buffer and pointer. CALL 111 5-8

CALL 73 – Battery-Backed RAM Disable

Purpose
Use CALL 73 to disable the battery-backed RAM. When this CALL is executed, the message Disabling battery-backed RAM allows a purging reset. When power to the module is turned OFF, the contents of RAM are destroyed. When power is reapplied, RAM is cleared and battery back-up is re-enabled.
Battery Backup Disabled is printed on the host terminal.
Syntax
CALL 73
Example
>CALL 73
Battery Backup Disabled
>REM TURNING POWER OFF, THEN BACK ON
1 Publication 1746-RM001A-US-P
5-2 Command Line CALLs

CALL 74 – Battery-Backed RAM Enable

CALL 77 – Protected Variable Storage

Purpose
Use CALL 74 to enable the battery-backed RAM. When this CALL is executed, the message Battery-backed RAM is enabled on module powerup and remains enabled until you execute a CALL 73 or until the battery fails.
Battery Backup Enabled is printed on the host terminal.
Syntax
CALL 74
Example
>CALL 74
Battery Backup Enabled
IMPORTANT
Change CALL 77 from Command mode only to ensure proper operation.
Purpose
Use CALL 77 to reserve the top of RAM memory for protected variable storage. Values are saved if BATTERY-BACKUP is invoked. You store values with the ST@ command and retrieve them with the LD@ command. Each variable stored requires 6 bytes of storage space.
You must subtract 6 times the number of variables stored from MTOP reducing available RAM memory. This value is PUSHed onto the stack as the new MTOP address. All appropriate variable pointers are reconsidered. Do this only in Command mode.
IMPORTANT
IMPORTANT
Do not let the ST@ address write over the MTOP address. This could alter the value of a variable or string. The lowest setting MTOP may be set to is 4096 (1000H).
Call 77 de-allocates all the string memory along with the string contents. Therefore, make sure that you perform this CALL before the execution of the string statement.
Syntax
Publication 1746-RM001A-US-P
PUSH [new MTOP address] CALL 77
Command Line CALLs 5-3
Example: (For saving 2 variables)
>PRINT MTOP 24575 >PRINT MTOP-12 24563 >PUSH 24563:REM NEW MTOP ADDRESS >CALL 77
>1 REM EXAMPLE PROGRAM >10 K = 678*PI >20 L = 520 >30 PUSH K >40 ST@ 24575 : REM STORE K IN PROTECTED AREA >50 PUSH L >60 ST@ 24569 : REM STORE L IN PROTECTED AREA >70 REM TO RETRIEVE PROTECTED VARIABLES >80 LD@ 24575 : REM REMOVE K FROM PROTECTED AREA >90 POP K >100 LD@ 24569 : REM REMOVE L FROM PROTECTED AREA >110 POP L >120 REM USE LD@ AFTER POWER LOSS AND BATTERY BACK-UP IS USED

CALL 81 – User Memory Module Check and Description

Purpose
Use CALL 81 to check the user memory module before burning a program into the memory module. This routine:
determines the number of memory module programs
determines the number of bytes left in the memory module
determines the number of bytes in the RAM program
prints a message indicating if enough space is available in the memory module
for the RAM program
checks memory module checksum if program is found
prints a caution message is checksum fails
IMPORTANT
CALL 81 cannot detect a defective memory module.
No PUSHes or POPs are needed.
Syntax
CALL 81
Publication 1746-RM001A-US-P
5-4 Command Line CALLs
Example
>CALL 81
Number of BASIC programs in (E)EPROM.......... 3
Available bytes to end of user (E)EPROM....... 7944
Available bytes to beginning of assembly pgm.. 3848
Length of BASIC program in RAM................ 76
Program will fit in (E)EPROM.
READY >

CALL 82 – Check User Memory Module Map

Purpose
Use CALL 82 to check the user memory module and display a map of where all the BASIC programs are stored. The programmer can determine by using this CALL where the empty space in the memory module is located and how much space is available. No PUSHes or POPs are needed.
Syntax
CALL 82
Example
>CALL 82
8010H -- 805CH --> ROM 1 805DH -- 80A9H --> ROM 2 80AAH -- 80F6H --> ROM 3 80F7H -- FFFFH --> UNUSED
>

CALL 101 – Upload User Memory Module Code to Host

Publication 1746-RM001A-US-P
Purpose
Use CALL 101 to upload the code in the user memory module to the host terminal. This CALL requires two PUSHes and no POPs. The first PUSH is the starting address. The second PUSH is the ending address. This CALL converts data within the address range to Intel program port. An error message is printed if the addresses are not consistent.
Hex format, then prints the information to the
Syntax
PUSH [starting address] PUSH [ending address] CALL 101
Example
>PUSH 8000 : PUSH 804FH : CALL 101
:108000003107021327CC3313276607005FFF473081 :108010005509000A8B41E034290D1000149C3130C1 :108020002C32302C33302C34300D0A001EA049EA9B :1080300030A6330D0900289B41E049290D06003286 :1080400097490D0A003CA04AEA4FA6330D090046A5 :00000001F >
Command Line CALLs 5-5

CALL 103 – Print PRT1 Output Buffer and Pointer

Purpose
Use CALL 103 to print the complete output buffer with address, front pointer, and number of characters in the buffer to the program port screen. No PUSHes or POPs are needed.
Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Syntax
CALL 103
Publication 1746-RM001A-US-P
5-6 Command Line CALLs
Example
>CALL 103
PRT1 Output Queue
6D00H 3AH 31H 30H 38H 30H 34H 30H 30H 30H 39H 37H 34H 39H 30H 44H 30H 6D10H 41H 30H 30H 33H 43H 41H 30H 34H 41H 45H 41H 34H 46H 41H 36H 33H 6D20H 33H 30H 33H 30H 48H 20H 33H 33H 48H 20H 33H 30H 48H 20H 34H 38H 6D30H 48H 20H 32H 30H 48H 20H 33H 33H 48H 20H 33H 33H 48H 20H 34H 38H 6D40H 48H 20H 32H 30H 48H 20H 33H 33H 48H 20H 33H 30H 48H 20H 34H 38H 6D50H 48H 20H 32H 30H 48H 20H 33H 34H 48H 20H 33H 38H 48H 0DH 0AH 20H 6D60H 36H 44H 33H 30H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 34H 38H 6D70H 48H 20H 32H 30H 48H 20H 33H 34H 48H 20H 33H 38H 48H 0DH 0AH 20H 6D80H 36H 44H 37H 30H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 33H 32H 6D90H 48H 20H 33H 30H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 33H 33H 6DA0H 48H 20H 33H 34H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 33H 33H 6DB0H 48H 20H 33H 38H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 33H 34H 6DC0H 48H 20H 33H 38H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 33H 32H 6DD0H 48H 20H 33H 30H 48H 20H 34H 38H 48H 20H 32H 30H 48H 20H 33H 33H 6DE0H 48H 20H 33H 34H 48H 0DH 0AH 20H 36H 44H 43H 30H 48H 20H 34H 38H 6DF0H 48H 20H 32H 30H 48H 20H 33H 33H 48H 20H 33H 38H 48H 20H 34H 34H
Output queue front pointer is: 6D29H

CALL 104 – Print PRT1 Input Buffer and Pointer

Purpose
Use CALL 104 to print the complete input buffer with address, front pointer, and number of characters in the buffer to the program port screen. No PUSHes or POPs are needed.
Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Syntax
CALL 104
Publication 1746-RM001A-US-P
Command Line CALLs 5-7
Example
>CALL 104
PRT1 Input Queue
6C00H 33H 0DH 43H 41H 4CH 4CH 20H 31H 30H 34H 7FH 7FH 7FH 7FH 7FH 7FH 6C10H 7FH 7FH 52H 45H 4DH 20H 45H 58H 41H 4DH 50H 4CH 45H 53H 7FH 7FH 6C20H 7FH 7FH 7FH 7FH 7FH 7FH 7FH 7FH 7FH 7FH 0DH 0DH 0DH 0DH 0DH 0DH 6C30H 0DH 0DH 0DH 45H 58H 41H 4DH 7FH 7FH 7FH 7FH 52H 45H 4DH 20H 45H 6C40H 58H 41H 4DH 50H 4CH 45H 53H 20H 4FH 4EH 20H 50H 41H 47H 45H 20H 6C50H 36H 2DH 37H 0DH 43H 41H 4CH 4CH 20H 31H 30H 34H 0DH 52H 4DH 41H 6C60H 4EH 54H 20H 7FH 7FH 7FH 54H 20H 44H 41H 54H 41H 0DH 52H 45H 4DH 6C70H 20H 54H 48H 45H 52H 45H 20H 49H 53H 20H 4EH 4FH 20H 52H 45H 41H 6C80H 4CH 20H 52H 45H 53H 50H 4FH 4EH 53H 45H 20H 57H 48H 49H 43H 48H 6C90H 20H 57H 49H 4CH 4CH 20H 53H 48H 4FH 57H 20H 55H 50H 20H 49H 4EH 6CA0H 20H 41H 4EH 20H 45H 58H 41H 4DH 50H 4CH 45H 0DH 0DH 0DH 0DH 0DH 6CB0H 52H 45H 4DH 20H 45H 58H 41H 4DH 50H 4CH 45H 53H 20H 4FH 4EH 20H 6CC0H 50H 41H 47H 45H 20H 36H 2DH 36H 0DH 50H 55H 53H 48H 20H 38H 30H 6CD0H 30H 30H 48H 3AH 50H 7FH 7FH 20H 70H 55H 53H 7FH 7FH 7FH 3AH 20H 6CE0H 50H 55H 53H 48H 20H 38H 30H 7FH 30H 34H 46H 48H 20H 3AH 43H 41H 6CF0H 4CH 4CH 20H 31H 30H 31H 0DH 0DH 0DH 43H 41H 4CH 4CH 20H 31H 30H
Input queue front pointer is: 6C5DH

CALL 109 – Print Argument Stack

Purpose
Use CALL 109 to print the top 9 values on the argument stack to the console. No PUSHes or POPs are needed. Use this information as a troubleshooting aid. It does not affect the contents of the argument stack or pointer to the stack.
Syntax
CALL 109
Example
>CALL 109
1C9H 00H 00H 00H 00H 00H 00H 1CFH 00H 00H 00H 00H 00H 00H 1D5H 00H 00H 00H 00H 00H 00H 1DBH 41H 67H 50H 00H 00H 7EH 1E1H 83H 75H 00H 00H 00H 7CH 1E7H 13H 04H 00H 00H 00H 7CH 1EDH 32H 84H 70H 00H 00H 85H 1F3H 32H 76H 80H 00H 00H 85H 1F9H 00H 00H 00H 00H 00H 00H
Argument stack pointer is: 01FEH
Publication 1746-RM001A-US-P
5-8 Command Line CALLs

CALL 110 – Print PRT2 Output Buffer Pointer

Purpose
Use CALL 110 to print the complete output buffer with addresses, front pointer and the number of characters in the buffer to the console device. No PUSHes or POPs are needed.
Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Syntax
CALL 110
Example
>CALL 110
PRT2 Output Queue
6F00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F10H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F20H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F30H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F40H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F50H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F60H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F70H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F80H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6F90H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6FA0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6FB0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6FC0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6FD0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6FE0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6FF0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H

CALL 111 – Print PRT2 Input Buffer Pointer

Publication 1746-RM001A-US-P
Output queue front pointer is: 6F00H
Purpose
Use CALL 111 to print the complete input buffer with addresses, front pointer and the number of characters in the buffer to the console device. No PUSHes or POPs are needed.
Use this information as a troubleshooting aid. It does not affect the contents of the buffer.
Syntax
CALL 111
Command Line CALLs 5-9
Example
>CALL 111
PRT2 Input Queue
6E00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E10H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E20H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E30H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E40H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E50H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E60H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E70H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E80H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6E90H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6EA0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6EB0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6EC0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6ED0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6EE0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 6EF0H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H
Input queue front pointer is: 6E00H
Publication 1746-RM001A-US-P
5-10 Command Line CALLs
Publication 1746-RM001A-US-P
Chapter
6

Assignment Functions

This chapter describes and illustrates commands that assign storage, reset data storage, and values to variables within the BASIC program or from the command line. Table 6.1 lists the corresponding mnemonics.
Table 6.1 Chapter Reference Guide
If you need (to) Use this mnemonic Page
Clear variables, interrupts & strings. CLEAR 6-1 Clear interrupts. CLEARI 6-3 Clear all stacks. CLEARS 6-3 Data read by Read statement. DATA 6-4 Allocate memory for array variables. DIM 6-4 Assign a variable or a string a value (LET is optional). LET 6-5 RESTORE read pointer. RESTORE 6-7

CLEAR

Purpose
Use the CLEAR statement to set all variables equal to 0 and reset all BASIC evoked interrupts and stacks. This means that after the CLEAR statement is executed, an ONTIME statement must be executed before the module acknowledges the internal timer interrupts. ERROR trapping with the ONERR statement also does not occur until an ONERR [ln num] statement is executed.
The CLEAR statement does not affect the free running clock that is enabled by the CLOCK1 statement. CLOCK0 is the only module statement that can disable the free running clock.
CLEAR also does not reset the memory that has been allocated for strings, so it is not necessary to enter the STRING [exp], [expr] statement to re-allocate memory for strings after the CLEAR statement is executed. In general, CLEAR is used to erase all variables.
Syntax
CLEAR
1 Publication 1746-RM001A-US-P
6-2 Assignment Functions
Example
>CLEAR
>LIST 1 REM EXAMPLE PROGRAM 10 DIM A(4) 20 DATA 10,20,30,40 30 FOR I=0 TO 3 40 READ A(I) 50 NEXT I 60 FOR J=O TO 3 70 PRINT A(J) 80 NEXT J
READY >PRINT A(1),I,J
000
>RUN
10 20 30 40
READY >PRINT A(1),I,J
2044
>CLEAR
>PRINT A(1),I,J
000
Publication 1746-RM001A-US-P
Assignment Functions 6-3

CLEARI

Purpose
Use the CLEARI statement to clear all of the BASIC evoked interrupts. The ONTIME interrupt is disabled after the CLEARI statement is executed.
CLEARI does not affect the free running clock enabled by the CLOCK1 statement. CLOCK0 is the only module statement that can disable the free running clock.
You can use this statement to selectively DISABLE ONTIME interrupts during specific sections of your BASIC program. You must execute the ONTIME statement again before the specific interrupts are enabled.
IMPORTANT
When the CLEARI statement is LISTed it appears as CLEARI.
Syntax
CLEARI
Example

CLEARS

READY >CLEARI
Purpose
Use the CLEARS statement to reset all of the stacks. The control, argument, and internal stacks all reset to their initialization values. You can use this command to reset the stacks if an error occurs in a subroutine.
IMPORTANT
When the CLEARS statement is LISTed it appears as CLEARS.
Syntax
CLEARS
Example
READY >CLEARS
Publication 1746-RM001A-US-P
6-4 Assignment Functions

DATA

Purpose
Use the DATA statement to specify the expressions that you can retrieve with a READ statement. If multiple expressions per line are used, you must separate them with a comma.
Every time a READ statement is encountered the next consecutive expression in the DATA statement is evaluated and assigned to the variable in the READ statement. You can place DATA statements anywhere within a program. They are not executed and do not cause an error. DATA statements are considered chained and appear as one large DATA statement. If at anytime all the data is read and another READ statement is executed, the program terminates and the message
ERROR: NO DATA - IN LINE XX prints to the console device. The module
returns to Command mode.
Syntax
DATA
Example
>LIST 1 REM EXAMPLE PROGRAM 10 DIM A(4) 20 DATA 10,ASC(A),ASC(C),35.627 30 FOR I=0 TO 3 40 READ A(I) 50 NEXT I 60 FOR J=O TO 3 70 PRINT A(J) 80 NEXT J
DIM
Publication 1746-RM001A-US-P
READY >RUN
10 65 67
35.627
IMPORTANT
You cannot use the CHR operator in a DATA statement.
Purpose
Use the DIM statement to reserve storage for matrices. The storage area is first assumed to be zero. Matrices in the BASIC module may have only one dimension and the size of the dimensioned array may not exceed 254 elements.
Assignment Functions 6-5
Once a variable is dimensioned in a program it may not be re-dimensioned. An attempt to re-dimension an array causes an array size error that causes the module to enter the Command mode.
If an array variable is used that was not dimensioned by a DIM statement, BASIC assigns a default value of 10 to the array size. All arrays are set equal to zero when the RUN command, NEW command or the CLEAR statement is executed.
The number of bytes allocated for an array is six times the array size plus one
(array size + 1)). For example, the array A (100) requires 606 bytes of storage.
(6 Memory size usually limits the size of a dimensioned array.
Syntax
DIM
Examples
LET
More than one variable can be dimensioned by a single DIM statement.
>
1 REM EXAMPLE PROGRAM
>10 DIM A(25), C(15), A1(20)
Error on attempt to re-dimension array:
>1 REM EXAMPLE PROGRAM >10 A(5) = 10 : REM BASIC ASSIGNS DEFAULT OF 10 TO ARRAY A >20 DIM A(5) : REM ARRAY RE-DIMENSION ERROR >
READY >RUN
ERROR: ARRAY SIZE - IN LINE 20
20 DIM A(5) : REM ARRAY RE-DIMENSION ERROR
---------------X READY >
Purpose
Use the LET statement to assign a variable to the value of an expression.
Syntax
LET [var] = [expr]
Publication 1746-RM001A-US-P
6-6 Assignment Functions
Examples
>1 REM EXAMPLE PROGRAM >10 LET A = 10*SIN(C)/100
>1 REM EXAMPLE PROGRAM >10 LET A = A +1
NOTE
The - sign used in the LET statement is not an equality operator. It is a replacement operator. The statement should be read A is replaced by A plus one. The word LET is always optional (example:
LET A = 2 is the same as A=2).
When LET is omitted the LET statement is called an IMPLIED LET. We use the word LET to refer to both the LET statement and the IMPLIED LET statement.
Also use the LET statement to assign string variables:
LET $(1)=“THIS IS A STRING” or LET $(2)=$(1)
Before you can assign strings you must execute the STRING [expr], [expr] statement or else a memory allocation error occurs that causes the module to enter the Command mode.
Publication 1746-RM001A-US-P
Assignment Functions 6-7

RESTORE

Purpose
Use the RESTORE statement to reset the internal read pointer to the beginning of the data so that it may be read again.
Syntax
RESTORE
Example
>1 REM EXAMPLE PROGRAM >10FORI=1TO3 >20 READ A,C >30 PRINT A,C >40 NEXT I >50 RESTORE >60 READ A,C >70 PRINT A,C >80 DATA 10,20,10/2,20/2,SIN(PI),COS(PI)
READY >RUN
10 20 510 0-1 10 20
Publication 1746-RM001A-US-P
6-8 Assignment Functions
Publication 1746-RM001A-US-P
Chapter
7

Control Functions

This chapter describes and illustrates commands executed within the BASIC program or from the command line to control the internal clock or the flow of the BASIC program. Table 7.1 lists the corresponding mnemonics.
Table 7.1 Chapter Reference Guide
If you need (to) Use this mnemonic Page
Disable the real time clock. CLOCK0 7-2 Enable the real time clock. CLOCK1 7-1 Set up a conditional do-loop. DO-UNTIL 7-4 Set up a conditional do-loop. DO-WHILE 7-3 Terminate a program execution. END 7-5 Set up a for-next loop. FOR-TO-(STEP)-NEXT 7-6 Go to the program line number. GOTO 7-7 Conditional test IF-THEN-ELSE 7-8 Test a for-next loop condition. NEXT 7-9 Conditional GOTO ON-GOTO 7-11

CLOCK1

Purpose
Use the CLOCK1 statement to enable the free running clock resident on the BASIC or BASIC-T module. The special function operator TIME is incremented once every 5 milliseconds after the CLOCK1 statement is executed. The CLOCK1 statement uses an internal TIMER to generate an interrupt once every 5 milliseconds. Because of this, the special function operator TIME has a resolution of 5 milliseconds. The special function operator TIME counts from 0 to
65535.995 seconds. After reaching a count of 65535.995 seconds TIME overflows back to a count of zero. The interrupts associated with the CLOCK1 statement cause the module programs to run at about 99.6% of normal speed. This means that the interrupt handling for the free running clock uses about 0.4% of the total CPU time
.
IMPORTANT
This does not include additional overhead for ON-TIME user interrupt handling execution.
Syntax
CLOCK1
1 Publication 1746-RM001A-US-P
7-2 Control Functions
Example
>NEW
>1 REM EXAMPLE PROGRAM >10 TIME = 0 >15 DBY(71) = 0 >20 CLOCK1 >30 ONTIME 2,100 >40 DO >50 WHILE TIME < 10 >60 END >100 PRINT “TIMER INTERRUPT AT - ”,TIME,“ SECONDS” >110 ONTIME TIME+2,100 >120 RETI
READY >RUN
TIMER INTERRUPT AT - 2.01 SECONDS TIMER INTERRUPT AT - 4.015 SECONDS TIMER INTERRUPT AT - 6.01 SECONDS TIMER INTERRUPT AT - 8.01 SECONDS TIMER INTERRUPT AT - 10.01 SECONDS

CLOCK0

Purpose
Use the CLOCK0 (zero) statement to disable or turn off the free running clock resident on the BASIC module. After CLOCK0 is executed, the special function operator TIME no longer increments. CLOCK0 is the only module statement that can disable the free running clock. CLEAR and CLEARI do not disable the free running clock, only its associated ONTIME interrupt.
IMPORTANT
CLOCK1 and CLOCK0 are independent of the clock/calendar.
Syntax
CLOCK0
Example
READY >CLOCK0
Publication 1746-RM001A-US-P
Control Functions 7-3

DO-WHILE

Purpose
Use the DO-WHILE statement to set up loop control within a module program. The operation of this statement is similar to the DO-UNTIL [rel expr]. All statements between the DO and the WHILE [rel expr] are executed as long as the relational expression following the WHILE statement is true. You can nest DO-WHILE statements.
The control stack (C-stack) stores all information associated with loop control (example: DO-WHILE, DO-UNTIL, FOR-NEXT and BASIC subroutines). The control stack is 157 bytes long. DO-WHILE and DO-UNTIL loops and GOSUB commands use 3 bytes of the control stack. FOR-NEXT loops use 17 bytes.
IMPORTANT
Excessive nesting exceeds the limits of the control stack, generating an error, and causing the module to enter Command mode.
Syntax
DO-WHILE [rel expr]
Examples
Simple DO-WHILE
>NEW
>1 REM EXAMPLE PROGRAM >10 DO >20A=A+1 >30 PRINT A >40 WHILEA<4 >50 PRINT “DONE” >60 END
READY >RUN
1 2 3 4
DONE
READY >
Nested DO-WHILE
>NEW
Publication 1746-RM001A-US-P
7-4 Control Functions
>1 REM EXAMPLE PROGRAM >10 A=0 : C=0 >20 DO >30 A=A+1 >40 DO >45 C=C+1 >50 PRINT A,C,A*C >60 WHILE C<>3 >70 C=0 >80 WHILE A<4 >90 END
READY >RUN
111 122 133 212 224 236 313 326 339

DO-UNTIL

READY >
Purpose
Use the DO-UNTIL statement to set up loop control within a module program. All statements between the DO and the UNTIL[rel expr] are executed until the relational expression following the UNTIL statement is TRUE. You can nest DO-UNTIL loops.
The control stack (C-stack) stores all information associated with loop control (example: DO-WHILE, DO-UNTIL, FOR-NEXT and BASIC subroutines). The control stack is 157 bytes long. DO-WHILE and DO-UNTIL loops and GOSUB commands use 3 bytes of the control stack. FOR-NEXT loops use 17 bytes.
IMPORTANT
Excessive nesting exceeds the limits of the control stack, generating an error, and causing the module to enter Command mode.
Syntax
Publication 1746-RM001A-US-P
DO-UNTIL [rel expr]
Control Functions 7-5
Examples
Simple DO-UNTIL Nested DO-UNTIL
>1 REM EXAMPLE PROGRAM >1 REM EXAMPLE PROGRAM >10 A=0 >10 DO >20 DO >20 A=A+1 >30 A=A+1 >30 DO >40 PRINT A >40 C=C+1 >50 UNTIL A=4 >50 PRINT A,C,A*C >60 PRINT “DONE” >60 UNTIL C=3 >70 END >70 C=0 >RUN >80 UNTIL A=3
>90 END RUN
END
Purpose
Use the END statement to terminate program execution. CONT does not operate if the END statement is used to terminate execution. An
CONTINUE prints to the console. Always include an END statement to properly
ERROR : CAN’T
terminate a program.
Syntax
END
Example
End Statement Termination
>1 REM EXAMPLE PROGRAM >10FORI=1TO4 >20 PRINT I, >30 NEXT I >40 END
READY >RUN
1234 READY >
Publication 1746-RM001A-US-P
7-6 Control Functions

FOR-TO-(STEP)-NEXT

Purpose
Use the FOR- TO-(STEP)-NEXT statement to set up and control program loops.
The control stack (C-stack) stores all information associated with loop control (example: DO-WHILE, DO-UNTIL, FOR-NEXT and BASIC subroutines). The control stack is 157 bytes long. DO-WHILE and DO-UNTIL loops and GOSUB commands use 3 bytes of the control stack. FOR-NEXT loops use 17 bytes.
IMPORTANT
Excessive nesting exceeds the limits of the control stack, generating an error, and causing the module to enter Command mode.
Syntax
FOR [expr] TO [expr] STEP [expr] . . . NEXT [expr]
Examples
>1 REM EXAMPLE PROGRAM >5 E=0 : C=10 : D=2 >10 FOR A=E TO C STEP D >20 PRINT A >30 NEXT A >40 END >RUN
0 2 4 6 8 10
READY
>1 REM EXAMPLE PROGRAM >10FORI=1TO4 >20 PRINT I, >30 NEXT I >40 END
READY >RUN
1234
Publication 1746-RM001A-US-P
Control Functions 7-7
In the first example, since E-0, C-10, D-2, and the PRINT statement at line 20 executes 6 times, the values of A that are printed are 0, 2, 4, 6, 8 and 10. A represents the name of the index or loop counter. The value of E is the starting value of the index. The value of C is the limit value of the index and the value of D is the increment to the index.
If the STEP statement and the value D are omitted, the increment value defaults to 1, therefore; STEP is an optional statement. The NEXT statement returns the loop to the beginning of the loop and adds the value of D to the current index value. The current index value is then compared to the value of C, the limit value of the index.
If the index is less than or equal to the limit, control transfers back to the statement after the FOR statement. Stepping backward (FOR I-100 TO 1 STEP-1) is permitted in the module. The NEXT statement is always followed by the appropriate variable. You may nest FOR-NEXT loops up to 9 times.
>1 REM EXAMPLE PROGRAM >1 REM EXAMPLE PROGRAM >10 FOR I=1 TO 4 >10 FOR I=0 TO 8 STEP 2 >20 PRINT I, >20 PRINT I >30 NEXT I >30 NEXT I >40 END >40 END >RUN >RUN >1234 0
2 4 6 8

GOTO

READY READY
Purpose
Use the GOTO statement to cause BASIC to transfer control to the line number ([ln num]) specified.
Syntax
GOTO [ln num]
Example
>1 REM EXAMPLE PROGRAM >50 GOTO 100
Publication 1746-RM001A-US-P
7-8 Control Functions
If line 100 exists, this statement causes execution of the program to resume at line
100. If line number 100 does not exist, the message
NUMBER
is printed to the console device and the module enters the Command
ERROR: INVALID LINE
mode.
Unlike the RUN command, the GOTO statement, if executed in the Command mode, does not clear the variable storage space or interrupts. However, if the GOTO statement is executed in the Command mode after a line is edited, the module clears the variable storage space and all BASIC evoked interrupts.

IF-THEN-ELSE

Purpose
Use the IF-THEN-ELSE statement to set up a conditional test.
Syntax
IF [rel expr] THEN valid statement ELSE valid statement
Examples
Example 1
>1 REM EXAMPLE PROGRAM >10 IF A =100 THEN A=0 ELSE A=A+1
Upon execution of line 10 IF A is equal to 100, THEN A is assigned a value of 0. IF A does not equal 100, A is assigned a value of A+1. If you want to transfer control to different line numbers using the IF statement, you may omit the GOTO statement. The following examples give the same results:
>20 IF INT(A)<10 THEN GOTO 100 ELSE GOTO 200
or
>20 IF INT(A)<10 THEN 100 ELSE 200
Publication 1746-RM001A-US-P
You can replace the THEN statement with any valid module statement as shown below:
>30 IF A<>10 THEN PRINT A ELSE 10 >30 IF A<>10 PRINT A ELSE 10
Control Functions 7-9
Example 2
You may execute multiple statements following the THEN or ELSE if you use a colon to separate them.
>30 IF A<>10 THEN PRINT A : GOTO 150 ELSE 10 >30 IF A<>10 PRINT A : GOTO 150 ELSE 10
In these examples, if A does not equal 10, then both PRINT A and GOTO 150 are executed. If A equals 10, then control passes to 10.
Example 3
You may omit the ELSE statement. If you omit the ELSE statement control passes to the next statement.
>1 REM EXAMPLE PROGRAM >20 IF A=10 THEN 40 >30 PRINT A

NEXT

In this example, if A equals 10 then control passes to line number 40. If A does not equal 10, line number 30 is executed.
Purpose
Use the NEXT statement to return the FOR-TO-(STEP)-NEXT loop to the beginning of the loop and add the value of the index increment to the index. The current index value is then compared to the index limit to determine if another loop should be performed.
Syntax
NEXT
Publication 1746-RM001A-US-P
7-10 Control Functions
Example
>1 REM EXAMPLE PROGRAM >5 E=0 : C=10 : D=2 >10 FOR A=E TO C STEP D >20 PRINT A >30 NEXT A >40 END >RUN
0 2 4 6 8 10
READY >
>NEW
>1 REM EXAMPLE PROGRAM >10 FOR I = 0 TO 8 STEP 2 >20 PRINT I >30 NEXT I >40 END
>RUN
0 2 4 6 8
Publication 1746-RM001A-US-P
Control Functions 7-11

ON-GOTO

Purpose
Use the ON-GOTO statement to transfer control to the line(s) specified by the GOTO statement when the value of the expression following the ON statement is encountered in the BASIC program.
Syntax
ON [expr] GOTO [ln num]
Example
>1 REM EXAMPLE PROGRAM >10 ON Q GOTO 100,200,300
Control is transferred to line 100 if Q is equal to 0 and then to line 200 if Q is equal to 1. If Q is equal to 2, control is transferred to line number 300, and so on. All comments that apply to GOTO apply to the ON statement. If Q is less than zero, an enters Command mode. If Q is greater than the line number list following the GOTO statement, an ON-GOTO statement provides conditional branching options within the module program.
ERROR: BAD ARGUMENT message is generated and the BASIC module
ERROR: BAD SYNTAX message is generated. The
Publication 1746-RM001A-US-P
7-12 Control Functions
Publication 1746-RM001A-US-P
Chapter
8

Execution Control and Interrupt Support Functions

This chapter describes and illustrates commands that control data flow and program transfer between ROM and RAM within the BASIC program or from the command line. Table 8.1 lists the corresponding mnemonics.
Table 8.1 Chapter Reference Guide
If you need (to) Use this
mnemonic
Enable the interrupt capability when a DF1 packet is received. CALL 16 8-2 Disable the DF1 packet interrupt capability. CALL 17 8-3 Enable the SLC processor interrupt capability. CALL 20 8-3 Disable the SLC processor interrupt capability. CALL 21 8-4 Generate an interrupt to the SLC processor. CALL 26 8-4 Initiate transactions defined by CALLs 27, 28, 122, and 123. CALL 38 8-5 ROM to RAM program transfer CALL 70 8-8 ROM/RAM to ROM program transfer CALL 71 8-9 RAM/ROM return CALL 72 8-9 Execute a subroutine. GOSUB 8-11 Go to line number when an error is detected. ONERR 8-12 Conditional GOSUB ON-GOSUB 8-14 Generate an interrupt when TIME is equal to or greater than
ONTIME argument-line number. POP argument stack to variables. POP 8-17 PUSH expressions on argument stack. PUSH 8-15 Return from interrupt. RETI 8-18 RETURN from subroutine. RETURN 8-18 Break program execution. STOP 8-20
ONTIME 8-14
Page
1 Publication 1746-RM001A-US-P
8-2 Execution Control and Interrupt Support Functions

CALL 16 – Enable DF1 Packet Interrupt

Purpose
Use CALL 16 to enable the DF1 packet interrupt capability. One argument is PUSHed and no arguments are POPped. The input argument is the BASIC line number of the beginning of the interrupt routine that the program should jump to, when a valid DF1 packet is received in the port PRT2 buffer. You should process the packet within the interrupt routine. A RETI executed within the routine returns you to the point in the program before the interrupt occurred. This command has no effect if the DF1 protocol is not enabled (CALL 108). Also, jumper JW4 must be in a position enabling DF1 for port PRT2.
Once this CALL is enabled, port PRT2 is checked by the processor at the end of each line of BASIC code for a DF1 message received.
If the DF1 packet arrives due to CALL 122 or CALL 123 when CALL 16 is enabled, you will receive the DF1 packet interrupt but the DF1 packet will have been removed from the input buffer.
Interrupts are disabled when the module is in Command mode. CALL 16 disabled is the default of the module when entering Run mode. CALL 16 must be re-executed every time Run mode is entered.
Syntax
PUSH [BASIC line number] CALL 16
Example
>1 REM EXAMPLE PROGRAM >10 REM ENABLE DF1 PACKET INTERRUPT >20 PUSH 800: REM LINE NUMBER OF START OF DF1 INTERRUPT ROUTINE >30 CALL 16 >800 (BEGINNING OF INTERRUPT ROUTINE)
: (PROCESS THE PACKET)
>850 RETI
Publication 1746-RM001A-US-P
Execution Control and Interrupt Support Functions 8-3

CALL 17 – Disable DF1 Packet Interrupt

CALL 20 – Enable Processor Interrupt

Purpose
Use CALL 17 to disable the DF1 packet interrupt capability enabled with CALL
16. This routine has no input or output arguments.
Syntax
CALL 17
Example
>1 REM EXAMPLE PROGRAM >10 REM DISABLE DF1 PACKET INTERRUPT ENABLED WITH CALL 16 >20 CALL 17
Purpose
Use CALL 20 to allow the processor to interrupt the module. One argument is PUSHed and no arguments are POPped. The PUSH is the BASIC line number of the beginning of the interrupt routine that the program should jump to, when word 0, bit 15 in the CPU output image table, toggles from a low to a high value. The module detects this transition automatically and jumps to an interrupt routine. A RETI executed within the interrupt routine returns you to the point in the module program before the interrupt occurred.
The module monitors CPU output file word 0, bit 15 at the end of every BASIC line and generates the interrupt if the bit goes high. The CPU must hold the interrupt request bit low for at least 10 milliseconds prior to requesting interrupt service. The bit must be held high for at least one scan so the bit can be detected by the module.
If another interrupt is detected before the previous one is fully serviced, the new interrupt is marked pending. Only one interrupt is pending at a time.
Interrupts are disabled when the module is in Command mode. CALL 20 disabled is the default of the module when entering Run mode. CALL 20 must be re-executed every time Run mode is entered.
Syntax
PUSH [BASIC line number] CALL 20
Publication 1746-RM001A-US-P
8-4 Execution Control and Interrupt Support Functions
Example
>1 REM EXAMPLE PROGRAM >10 REM ENABLE PROCESSOR INTERRUPTS >20 PUSH 1000 : REM LINE NUMBER OF START OF PROCESSOR
>30 CALL 20 >1000 (BEGINNING OF THE PROCESSOR INTERRUPT ROUTINE)
:
>1050 RETI
INTERRUPT ROUTINE

CALL 21 – Disable Processor Interrupt

CALL 26 – Module Interrupt

Purpose
Use CALL 21 to disable the processor interrupt capability enabled with CALL 20. This routine has no input or output arguments.
Syntax
CALL 21
Example
>1 REM EXAMPLE PROGRAM >10 REM DISABLE PROCESSOR INTERRUPTS ENABLED WITH CALL 20 >20 CALL 21
Purpose
Use CALL 26 to generate an interrupt to the SLC 5/02 and above processors. No
arguments are PUSHed and one argument is POPped. The POP shows the status of the SLC processor. When this CALL is executed, an I/O event interrupt is issued by the module to interrupt the normal processor operating cycle in order to scan a specified subroutine. This interrupt causes the SLC processor to execute the interrupt subroutine file configured in the module slot configuration (ISR numbered file). The module remains in this CALL routine until an interrupt acknowledge is received from the processor. CALL 26 must be executed in the BASIC program each time the SLC processor is to be interrupted.
Publication 1746-RM001A-US-P
This CALL has no effect if the SLC processor is not in the Run mode.
After the module issues the CALL, it may take up to 5 milliseconds for the execution of interrupt to occur.
Loading...