![background image](http://html1.mh-extra.com/html/omron/r88a-mcw151-drt-e/r88a-mcw151-drt-e_operation-manual_742243103.webp)
88
BASIC Programming
Section 5-2
GOTO and GOSUB. To define a label it must appear as the first statement on
a line and it must be ended by a colon (:). Labels can be character strings of
any length, but only the first 15 characters are significant.
Using Variables and
Labels
Each task has its own local labels and local variables. For example, consider
the two programs shown below:
These two programs when run simultaneously in different tasks and have
their own version of variable “a” and label “start”.
If you need to hold data in common between two or more programs, VR vari-
ables should be used, or alternatively, if a large amount of data is to be held,
the Table can be used.
To make a program more readable when using a VR variable, a named local
variable can be used as a constant in the VR variable. The constant, however,
must be declared in each program using the variable. In the example below,
VR(3) is used to hold a length parameter.
5-2-3
Mathematical Specifications
Number format
The MC Unit has two main formats for numeric values: single precision float-
ing point and single precision integer.
The single precision floating point format is internally a 32 bit value. It has an
8 bit exponent field, a sign bit and 23 bit fraction field with an implicit 1 as the
24th bit. Floating point numbers have a valid range of
to
.
Integers are essentially floating point numbers with a zero exponent. This
implies that the integers are 24 bits wide. The integer range is therefore given
from -16777216 to 16777215. Numeric values outside this range will be float-
ing point.
!WARNING
All mathematical calculations are done in floating point format. This implies
that for calculations of/with larger values the results may have limited accu-
racy. The user should be aware of this when developing the motion control
application.
Hexadecimal format
The MC Unit supports assigning and printing hexadecimal values. A hexadec-
imal number is inputted by proceeding the number by character $. Valid range
is from 0x0 to 0xFFFFFF. Example:
start:
FOR a = 1 to 100
MOVE(a)
WAIT IDLE
NEXT a
GOTO start
start:
a=0
REPEAT
a = a + 1
PRINT a
UNTIL a = 300
GOTO start
start:
GOSUB initial
VR(length) = x
...Body of program
initial:
length = 3
RETURN
start:
GOSUB initial
MOVE(VR(length))
PRINT VR(length)
...Body of program
initial:
length = 3
RETURN
5.9
±
10
39
–
⋅
3.4
±
10
38
⋅