Parameter types passed by value

The following data types and structures are passed by value to a function:

When passing a function parameter by value, the runtime system pushes a copy of the data on the stack. As result, inside the function, the local variable receiving the parameter value can be changed without affecting the variable used by the caller.

Passing a record

You can pass a RECORD structure as a function parameter with the dot star (.*) notation. In this case, the record is expanded and each member of the structure is pushed on the stack. The receiving local variables in the function can then be defined individually or with the same record structure as the caller. The next example illustrates this:
MAIN
  DEFINE rec RECORD
             a INT,
             b VARCHAR(50)
         END RECORD
  CALL func_r(rec.*)
  CALL func_ab(rec.*)
END MAIN

-- Function defining a record like that in the caller 
FUNCTION func_r(r)
  DEFINE r RECORD
             a INT,
             b VARCHAR(50)
         END RECORD
  ...
END FUNCTION

-- Function defining two individual variables 
FUNCTION func_ab(a, b)
  DEFINE a INT, b VARCHAR(50)
  ...
END FUNCTION

Passing a static array

It is possible to pass a complete static array as a function parameter, but this is not recommended. When passing a static array to a function, the complete array is copied on the stack and every element is passed by value. The receiving local variables in the function must be defined with the same static array definition as the caller:
MAIN
  DEFINE arr ARRAY[5] OF INT
  CALL func(arr)
END MAIN

-- function defining same static array as the caller 
FUNCTION func(x)
  DEFINE x ARRAY[5] OF INT
  ...
END FUNCTION

Note that dynamic arrays are passed by reference.