``

prev Menu next

PROGRAM, CHAIN
A PROGRAM statement declares a program name and parameters, which are used by CHAIN statements.
A CHAIN statement transfers the control to another program and terminates the program itself.
PROGRAM statements
`PROGRAM Program_Name
PROGRAM Program_Name(variable, variable，variable，･･･ ，variable)
` The naming rule for Program_Name is same as that for numeric variables.
Example.
`PROGRAM ABC(a,s$)`
When arrays are written as parameters, they are written followed by parentheses and commas of the number of the dimension minus 1.
Example.
`PROGRAM SAMPLE(A(),B(,),C(,,))`
A is a 1-dimensional array, B 2-dimensional, C 3-dimensional.
A PROGRAM statement must be written in the first line of a program.
When a CHAIN statement has launched this program, the values that the CHAIN statement has handed over are substituted for the parameters.
A PROGRAM statement can be used for a program that is not necessarily written by BASIC to launch the program and hand over some parameters.
Exceptions
extype4301 Parameter mismatch
extype4302 Mismatched dimension of array parameter

CHAIN statements
`CHAIN File_Name
CHAIN File_Name WITH ( expression，expression，…，expression )
` File_Name is a string expression whose value shall be the name of the file that stores a BASIC program.
The values of expressions written in the WITH-clause shall be the parameters for the PROGRAM statement.
Expressions are numerical expressions, string expressions or arrays.
Arrays are written without parentheses.
Example 1.
`CHAIN "FRACTAL\DRAGON.BAS"`
Example 2.
`CHAIN "A:\ABC.BAS" WITH (12,"Quiz")`
Example 3.
`DIM A(10),B(3,3),C(2,3,4)
CHAIN "A:\SAMPLE.BAS" WITH(A,B,C)
`

(Note)
Although the program name that is written in the PROGRAM statement can differ from the name of the file which stores the program, the argument of a CHAIN statement is not a program name but a file name.

Refer to command line parameters