by Richard Russell, April 2009
The main BBC BASIC for Windows documentation explains that whilst scalar variables are (by default) passed to functions and procedures by value arrays and structures are passed by reference. However this somewhat simplifies exactly what happens, and this article attempts to provide additional detail that may be of value to 'advanced' users.
It is somewhat more accurate to say that all parameters are passed by value unless the RETURN keyword is used in the function/procedure definition. The complication with arrays and structures is that what is passed 'by value' is not the actual array or structure, but a pointer (in the case of an array it's a pointer to the array descriptor; in the case of a structure it's a pair of pointers, to the format and to the data). Details of these pointer formats can be found in the Format of data in memory section of the manual.
So although the pointer(s) are passed by value, the data itself is effectively passed by reference. This means if you modify the data of a structure or array within the FN/PROC it will remain changed on exit, but if you modify the pointer(s) they will be restored on exit.
In particular this explains why the manipulation of the structure pointer described in the article Passing substructures to procedures does not affect the structure outside of the FN/PROC. Because the pointer is passed by value it is automatically restored on exit.