[futurebasic] Re: [FB] None (should have been Passing Arrays)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: "Pete" <furbies@...>
Date: Wed, 19 May 1999 10:44:46 +1000
> Can you pass an array from say a beginning program file to an ".INCL" file?
> If so, could someone help me out on the syntax?  Thanks for your help.
>
> More explanation:
> In my main program file I have a variable, dim names$(50), and I read names
> from a text file into names$.  Now I want to pass the whole array names$ to an
> ".INCL" file which has a variable, dim thenames$(50), declared in it.  Is that
> possible?  I thought you could just say fn gettingnames(names$) in my main
> program file and a fn gettingnames(thenames$) in my .INCL file, but this don't
> seem to work.
>
> Thanks if anyone can help,
> Doug Hull

Staz's Tech Note Number 15 Below

(Quoted without permission)

Pete...

It would be just like programmers to
shorten "the year 2000 problem" to "Y2K" --
exactly the kind of thinking that created this
situation in the first place. - Steven C. Meyer



[15] Passing Arrays

We recently discovered (quite by accident) that FutureBASIC II had been
programmed to pass arrays from one local function to the next. As it turns
out, the code was built in but never documented. The following example shows
how to handle arrays between functions.

COMPILE 0, _dimmedVarsOnly
END GLOBALS
LOCAL FN doArray1(d(5))
 PRINT d(2)
 PRINT d(3)
 PRINT d(5)
END FN
LOCAL FN doArray2(b(5,5))
 PRINT b(2,2)
 PRINT b(3,4)
 PRINT b(5,1)
END FN
LOCAL FN doPassArrays
 DIM b(5)
 b(2) = 222
 b(3) = 333
 b(5) = 555
 FN doArray1(b(0))
 DIM a(5,5)
 a(2,2) = 11
 a(3,4) = 22
 a(5,1) = 33
 FN doArray2(a(0,0))
END FN
'-------- Main ----------
WINDOW #1, "", (0,0)-(550,400)
FN doPassArrays
PRINT
DO
UNTIL LEN(INKEY$)
END
'---- end of program ----