Specifications

50
3.2 Handling User Programs
3.2.1 User Programs in the Memory
The user area of the memory (memories) in the BHT can store more than one user program.
(For details about memories, refer to Appendix F, "Memory Area.")
If you have selected one of those programs as an execution program in the Setting menu of
System Mode, the BHT automatically runs the user program when powered on.
For the operating procedure of System Mode, refer to the BHT Users Manual.
3.2.2 Program Chaining
Program chaining, which is caused by the CHAIN statement as shown below, terminates a
currently running user program and transfers control to another program.
CHAIN "another.PD3"
To transfer the variables and their values used in the currently running user program to the
chained-to program along the program chain, use the
COMMON statement as follows:
COMMON a$(2),b,c%(3)
CHAIN "another.PD3"
The Interpreter writes these declared variable values into the "common variable area" in the
memory. To make the chained-to program refer to these values, use the COMMON statement
again.
COMMON a$(2),b,c%(3)
In BHT-BASIC, all of the name, type, definition order, and number of COMMON-declared vari-
ables used in the currently running program should be identical with those in the next program
(the chained-to program).
When compiling and linking more than one file to produce a user program, define all necessary
common variables in the main object (to be executed first). In other objects, declare common
variables required only in that object. If you link an object where common variables not defined
in the main object are newly defined, an error will result.
prog1.PD3
COMMON a(10),b$(3),c%
.
.
.
CHAIN "prog2.PD3"
prog2.PD3
COMMON a(10),b$(3),c%
.
.
.
Since the COMMON statement is a declarative statement, no matter where it is placed in a
source program, the source program will result in the same output (same object program), if
compiled.