ENTER
Public Program Entry Point
This directive is used in a public program to mark the point at which CALL parameters are passed to the public program.
Syntax
Section titled “Syntax”ENTER [variable-list]variable-list- is a list of numeric and/or string variables to be received from the CALLing program.
Remarks
Section titled “Remarks”Only one ENTER directive may be executed in a public program, but it can appear anywhere in the public program. If more than one execution of an ENTER occurs in a public program, an ERR=36 results.
Public programs do not require an ENTER directive if no variable-list is to be passed.
The variable names do not have to be the same in the ENTER directive and its CALLing directive, but they must match in order sequence and type (see EXAMPLES).
Variables used in the public program which do not appear in the variable-list of the ENTER directive are available to the public program only and are not affected by the CALLing program.
Variables used in the CALLing program which do not appear in the variable-list of the ENTER directive are not available to the public program and are not affected by the public program.
Numeric and string arrays used in the CALL/ENTER linkage must use the ALL option to pass the full array if the CALLing program expects the public program to change the data in the array. Single element array values may be passed to the public program, but changes made within the public program are not sent back to the CALLing program.
Final values for variables named in the variable-list of the ENTER directive are passed back to the CALLing program’s corresponding variables when the public program EXITs unless the CALL directive contains a constant or single array element in that position in its value-list.
If an ENTER directive is executed in a program that is RUN rather than CALLed, an
ERR=36 results.
If the value-list in the CALL directive does not match the ENTER directive in sequence and type, an ERR=36 or ERR=42 results.
ENTER followed by no variable-list shares all its variables with the CALLing program, and vice versa. The CALLed program can be thought of as a CALLable overlay.
An ERR=36 occurs if the caller tries to pass arguments through the CALL statement to a public program with an ENTER statement that has no variable-list.
An ERR=38 occurs if the program has created any of its own data prior to the ENTER. This applies only to an ENTER with no variable-list passed.
Examples
Section titled “Examples”CALL "PUBLIC1", A$, B, C[ALL], D%, "ABC", 17038, G[1,2,3]
00100 ENTER A1$, B1, C1[ALL], D1%, E1$, F1, G1The PUBLIC1 public program receives the values from the CALLing program in its variable-list as follows:
| A1$ | will have the string value of | A$ | |
| B1 | will have the numeric value of | B | |
| C1[ALL] will have all elements of numeric array | C | ||
| D1% | will have the integer value of | D% | |
| E1$ | will have the string constant value of | "ABC" | |
| F1 | will have the numeric constant value of | 17038 | |
| G1 | will have the value of the numeric array entry | G[1,2,3] |
When PUBLIC1 executes an EXIT directive and returns to the CALLing program the corresponding values are passed back to the CALLing program for its A$, B, C[ALL], and D%.
| PROGBASE | PUBLIC2 | |
|---|---|---|
| 00100 LET A=1, B$=“HELLO” | 00100 ENTER | |
| 00200 CALL “PUBLIC2” | 00200 LET B=5, A$=“XXXX” | |
| 00300 PRINT A, B, A$, B$ | 00300 PRINT A, B, A$, B$ 00400 A=A+1, B$=B$+” THERE” 00500 EXIT |
Running PROGBASE yields the following output:
1 5XXXXHELLO
2 5XXXXHELLOTHERE
See also
Section titled “See also”From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF