Staz Software
HomeFutureBasicSharewareOrderContact

Tech Notes

Passing Arrays to Local FNs

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.

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

Note that the only dimensioned data is from the array named dataArray in FN buildData. The average function actually works form data created in the calling function.

FutureBASIC

Demo

Order

Tour

Tech Notes

FAQ

Sample Code

Web Sites

Mailing List

System
Requirements

blank