RATS 11
RATS 11

TYPE  datatype   list of names

TYPE declares the data types of PROCEDURE or FUNCTION parameters and return value. Use LOCAL for local variables used only within the procedure and DECLARE for global variables.

Parameters

datatype

Data type type you want to assign to the listed parameter names. This can be any of the basic and aggregate data types that RATS supports. By default, parameters for a PROCEDURE are type INTEGER, called by value, while those for a FUNCTION are type REAL, called by value.

list of names

The formal parameters of the procedure which are to have this type. Put * in front of a name if you want it to be called by address. Otherwise, it will be called by value.

Pass By Value or By Address

RATS allows you to pass data to procedures or functions either by value or by memory address. Calls by value are the default. To make a parameter called by address, put * in front of its name. For instance, in
 

procedure bjfore depvar start end forecast

type series depvar *forecast

type integer start end

 

the parameters DEPVAR and FORECAST are type SERIES, with DEPVAR called by value and FORECAST by address. START and END are INTEGER called by value.


Use calls by value for any parameter which is input to the procedure, and will not be reset by the procedure. When you EXECUTE the procedure, the actual parameter can be any constant, variable or expression of the correct type. If, however, you use a variable name not previously declared, you will get an error.

 

Use a call by address for any parameter which is set by the procedure, such as the FORECAST series in @BJFORE. When you EXECUTE the procedure, the actual parameter must be a variable, array or series element of the correct type. If not previously declared, it will be declared as a global variable with the required type.

Using the Parameters

Within a procedure, you can use the parameter names just like any other variable with its type. However, you cannot use parameters called by value on the left side of an equal sign—such a value is treated like a constant. For parameters passed by address, refer to the parameter by name alone, not “*name” as in the C language.

 


Copyright © 2025 Thomas A. Doan