6. Embedded QUEL for BASIC : BASIC Variables and Data Types : Variable and Type Declarations : Parameter Variables
 
Share this page                  
Parameter Variables
Variables can be declared by listing them as formal parameters to a subroutine or function definition, providing the sub, function, or def statement is preceded by the EQUEL ## mark. The syntax for a function statement is:
function type identifier [pass_mech
                   [(type identifier [(dimensions)] [str_length] [pass_mech]
                   {, [typeidentifier [(dimensions)] [str_length] [pass_mech]})]
The sub statement has the syntax:
sub identifier [pass_mech
     [(type identifier [(dimensions)] [str_length] [pass_mech]
     {, [typeidentifier [(dimensions)] [str_length] [pass_mech]})]
The def statement has the syntax:
def type identifier 
     [(type identifier {, [typeidentifier})]
Syntax Notes:
1. The type must be a BASIC type acceptable to EQUEL or a BASIC record. Unlike the rules for other EQUEL variable declarations, you can define the record to EQUEL after it appears in the parameter list. For example:
##   sub process_info (emp_rec emp)
##        record emp_rec
##             ...
##        end record emp_rec
2. The type is mandatory for EQUEL parameter declarations because EQUEL has no notion of a default type. The type need only be specified once when declaring a list of parameters of the same type.
3. The pass_mech (allowed on sub and function statements) may be by desc or by ref. However, the preprocessor does not verify that the formal parameter declaration is consistent with the passing mechanism. You should follow the VMS BASIC rules for parameter passing mechanisms.
4. The dimensions of an array specification are not parsed by the EQUEL preprocessor. Consequently, the preprocessor does not check bounds. Note also that an illegal dimension, such as a non-numeric value, will be accepted by the preprocessor, but will later cause BASIC compiler errors.
The following example illustrates the use of parameter variables:
##   def real newsal (integer grade, real oldsal, single      percent)
##   function string get_addr by ref (string ename = 20,      integer eno)
##   sub new_emps (integer deptno, string emplist (100) = 20 by ref)