Please enable JavaScript to view this site.

A-Shell Development History

Navigation: Version 6.1/6.2, builds 1300-1428 > 1398 – 12 November 2014

Passing Arrays by Reference to Subroutines

Scroll Prev Top Next More

Language enhancement (compiler edit 733) - support passing arrays by reference to SBX routines. From the perspective of the calling program, the setup is similar to how you would pass an array by reference to a procedure or function (see edit 1389 below). For example:

In the calling program,

dimx myary(0),ST_MYSTRUCT,auto_extend   ! define array

...

xcall MYSBX,myary()    ! specify in arg list with empty ()

 

In the SBX receiving program, you have to specify another dimx statement to declare the surrogate receiving array. The name can be anything, but the array type should match what the caller is sending, and it must have the "byref" clause and an extent of -1:

dimx locary(-1),ST_MYSTRUCT,byref        ! define surrogate array

The array can then be received using the xgetargs statement:

xgetargs locary()

The specified local array will then become an alias for the passed array. As with functions and procedures, do not use xputarg to pass the array back. The local array is effectively the same array as the called array, so any changes to the local array are immediately reflected in the called array.

Notes

There are both compiler and runtime elements of this enhancement so in order to use it, you have to both compile with compiler edit 733+, and run with A-Shell edit 6.1.1398.0+