Subroutines Call by Value Values, as well as variables, can be passed by a CALL statement. The instruction: CALL a_routine(loc_1, 17.5, 121, "some string") is an acceptable call to a_routine. Undefined Arguments If the calling program omits an argument, either by leaving a blank in the argument list (e.g., arg_1, , arg_3) or by omitting arguments at the end of a list (e.g., arg_1, arg_2), the argument are passed as undefined. The subroutine receiving the argument list can test for this value using the DEFINED function and take appropriate action. Program Files Since linking and compiling are not required by eV+, main programs and subroutines always exist as separate programs.
The eV+ file structure allows you to keep a main program and all the subroutines it CALLs or EXECUTEs together in a single file so that when a main program is loaded, all the subroutines it calls are also loaded. (If a program calls a subroutine that is not resident in system memory, the error *Undefined program or variable name* will result.) See the descriptions of the STORE_ commands and the MODULE command in the eV+ Operating System User's Guide for details. For an example of creating a program file, see "Sample Editing Session" on page 85. Reentrant Programs The eV+ system allows the same program to be executed concurrently by multiple program tasks.
That is, the program can be reentered while it is already executing. This allows different tasks that are running concurrently to use the same general-purpose subroutine. To make a program reentrant, you must observe a few general guidelines when writing the program: l Global variables can be read but must not be modified. l Local variables should not be used. l Only automatic variables and subroutine arguments can be modified. In special situations, local variables can be used, and global variables can be modified, but then the program must explicitly provide program logic to interlock access to these variables.
The TAS real-valued function (defined in Table 6-4, "System Control Functions") may be helpful in these situations. (See the eV+ Language Reference Guide for details.) eV+Language User's Guide, v2.x, 18318-000 Rev A Page 31