[futurebasic] Re: [FB] How to reinit array

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

From: Rick Brown <rbrown@...>
Date: Sun, 28 Feb 1999 09:50:47 -0600

MacMuse@... wrote:

> I'm sure there's a common way to reinitialize all flds of this array of
> records to 0 or null strs. but I can't remember or find info. As always your
> help is much appreciated.
>   DIM 30 myName$
>   DIM 15 someInfo$
>   DIM 15 moreInfo$
>   DIM element1%
>   DIM element2%
>   DIM element3%
> DIM myArray.myRec (720)
> I want to be able to reset all str$ to "" and all elements% to = 0 for each of
> the 720 reiterations of the array without a FOR - NEXT loop. Can I?

Yes.  There are two ways:

(1) If myArray is a _local_ array inside a LOCAL FN, then you can use the CLEAR
keyword in the LOCAL FN statement:
     CLEAR LOCAL FN myFunction(...)
However, this may not suit your needs, because (a) it clears _all_ local
variables & arrays, not just myArray; and (b) you may have a need to "reset" your
array at other points in the FN than just at the beginning.

(2) You can also do it this way:
     DEF LONGBLOCKFILL(@myArray(0), _myRec*(720+1), 0)

Hope this helps.
- Rick