BASIC commands
PROGRAMMING MANUAL
108
R
e
vi
si
o
n
1
.0
3.2.146 GLOBAL
/i
3.2.147 GOSUB..RETURN
/i
3.2.148 GOTO
/i
Type
System command
Syntax
GLOBAL ["name"[, vr_number]]
Description
Declares the name as a reference to one of the global VR varia-
bles. The name can then be used both within the program contain-
ing the
GLOBAL
definition and all other programs in the Trajexia
Studio project.
Note: The program containing the
GLOBAL
definition must be run
before the name is used in other programs. In addition, only that
program should be running at the time the
GLOBAL
is executed,
otherwise the program error will appear and the program will stop
when trying to execute this command. For fast startup the program
should also be the only process running at power-up.
Using
GLOBAL
with only the name will erase the specified global
variable. Using
GLOBAL
with no parameters will erase all
GLOBAL
declarations. This also happens when the TJ2-MC64 is
reset by switching the power off and back on, or by executing the
EX
command.
In programs that use the defined
GLOBAL
,
name
has the same
meaning as
VR(vr_number)
. Do not use the syntax:
VR(name)
.
A maximum of 256
GLOBAL
s can be declared.
The maximum length of the name of the
GLOBAL
is 32 characters.
Arguments
•
name
Any user-defined name containing lower case alpha, numeri-
cal or underscore characters.
•
vr_number
The number of the VR to be associated with
name
.
Example
GLOBAL "srew_pitch",12
GLOBAL "ratio1",534
ratio1 = 3.56
screw_pitch = 23.0
PRINT screw_pitch, ratio1
See also
LIST_GLOBAL
Type
Program control command
Syntax
GOSUB label
...
RETURN
Description
The
GOSUB
structure enables a subroutine jump.
GOSUB
stores the position
of the line after the
GOSUB
command and then jumps to the specified label.
Upon reaching the
RETURN
statement, program execution is returned to the
stored position.
Note: Subroutines on each task can be nested up to 8 levels deep.
Arguments
•
label
A valid label that occurs in the program. An invalid label will give a compi-
lation error before execution.
Labels can be character strings of any length, but only the first 15 charac-
ters are significant. Alternatively line numbers may be used as labels.
Example
main:
GOSUB routine
GOTO main
routine:
PRINT "Measured position=";MPOS;CHR(13);
RETURN
See also
GOTO
Type
Program control command
Syntax
GOTO label
Description
The
GOTO
structure enables a jump of program execution.
GOTO
jumps pro-
gram execution to the line of the program containing the label.