<h1>Tech Notes</h1><h2>Passing Arrays to Local FNs</h2><p>You may want to create a small array in a local function that is accessed by another function. It doesn't make sense to copy the entire array to the new function then bundle it all back up and return it to the caller. That is why FB allows you to pass a reference to an array. The original data from the calling function is used, but it is actually accessible from the called function. Here is how it is done.</p>
<p>
<pre>
REM We will pass an array with 10 elements
_maxAryelem = 10
LOCAL FN average(myIntArray(_maxAryelem))
REM code goes here
END FN = average
LOCAL FN buildData
DIM dataArray(_maxAryelem)
FOR x = 1 TO 10
REM load data into array here
NEXT
REM Now call on the average function to
REM average these numbers
average = FN average(dataArray(0))
END FN
</pre>
</p>
<p>Note that the only dimensioned data is from the array named dataArray in <span class="pre">FN buildData</span>. The average function actually works form data created in the calling function.</p>