Passing Arguments by Value and by Reference
In ViviFire, you can pass an argument to a procedure by value or by reference. This is known as the passing mechanism. It controls if the procedure can change the object that is the argument passed by the caller. The procedure declaration controls the passing mechanism for each parameter with the keyword ByRef.
Qualities of arguments and parameters
When you pass an argument to a procedure, know the many related qualities.
- Can the data be changed?
- Can the argument be changed?
- Is the argument passed by value or by reference?
- Is the argument's data type a value type or a reference type?
Selection of passing mechanism
Select the passing mechanism carefully for each argument.
Control the passing mechanism
The procedure's declaration controls the passing mechanism for each parameter. The caller cannot override the passing mechanism “by value”.
If a parameter is declared with ByRef, then the caller can call by value if you write the argument between parentheses.
The default passing mechanism in ViviFire is by value.
When to pass by value
When to pass by reference