Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual
Page 5

BASIC PROGRAMMING GUIDE
1-2
Basic Interpreters
There are several types and levels of interpreters. A
slow, very basic type of interpreter figures out what
each command is supposed to do during run time. A
token-based interpreter, such as this basic, is much
faster. This type examines each program line as it is
typed in, figures out what it should do, and converts
it to a string of Basic tokens mixed with text. A
token is a single character that represents a
command. For example, an ASCII value of 89H
represents the PRINT command.
After a line is processed, it is stored in memory.
When you type the RUN command, each program
line is scanned. A token causes a branch to an
assembly language routine which carries out the
required action.
ELEMENTS OF A BASIC PROGRAM
Commands
Commands direct or perform an output action.
Examples are PRINT, SAVE, POKE, and LOAD.
Commands do not return a value used for
computation.
Functions
Functions return a value used for computation.
Examples are REGREAD, SIN, and ABS.
Functions do not cause a change in an output.
Line Numbers
Program lines begin with a unique line number.
Each line number may contain one or more Basic
statements separated by a colon. Line numbers are
in the range of 1 - 65535.
Operators
Operators act on or convert numeric or string data.
These include arithmetic (+,-,*, and /), natural
logarithmic (base "e"), trig (SIN, COS), relational
(>, <, or <>), logical (.AND., .OR., .XOR.), and
string (ASC) functions. Special operators control
the hardware-specific features of Basic such as
interrupts, timers, counters, and direct read/write of
I/O ports.
Tasking Statements
Tasking statements define a condition and execution
location when a condition is met. Statements
include ONTICK. Programs executed as a result of
this statement is treated as subroutines. The only
difference between a tasking routine and one called
by a GOSUB is the tasking can be called at any
time.
Expressions
An expression is a combination of instructions,
operators, data (constants, arrays or strings) and
variables which, when evaluated by Basic, is
equivalent to a single numerical value. Many Basic
commands accept expressions as well as explicit
data. Expressions which are used by commands and
functions are also called arguments.
WRITING AND EDITING PROGRAMS
Program development takes place on your PC using
your word processor or the RPC card. Programs
from your PC are downloaded using a serial
communication program.
Each program line can contain at most 79 characters.
Program lines can be entered in any sequence. Basic
properly orders line numbers.
Multiple statements on a single line are allowed
when statements are separated by colon (:) and do
not exceed a total of 79 characters per program line.
Ending a program line with a colon may cause a
program to hang.
There are two ways to write Basic programs. The
first way is to directly type in the program to the
card. All standard Remote Processing cards have a
means of storing programs to a flash type EPROM.
The second way is use a text editor and download
the resulting file to the system. Just be sure to save
files in DOS text format.
Downloading programs means transferring them
from your PC (or MAC or terminal) to the card.
Uploading means transferring them from the card
back to the PC.
When uploading or downloading files, select ASCII
text format. XMODEM, YMODEM, or other
formats are not used. Basic does not know when
you are typing in a program or if something else
(laptop or mainframe) is sending it characters. The
upload and download file does not contain any
special codes; they are simply ASCII characters.
Uploading programs is simply a process of receiving
an ASCII file. You or your program simply need to
send "LIST" to receive the entire program.