[Gambas-user] Dynamically changed arrays
ron
ronstk at ...239...
Tue Mar 16 17:46:46 CET 2004
On Tuesday 16 March 2004 17:25, Eilert wrote:
> Hi,
>
> Somewhere in the documentation I found the "Java-style" arrays. Is that
> a means of replacing my favourite "redim preserve"? I'll give you an
> example (uncomplete code):
>
> dim ls$()
>
> 'open a file with handle fptr
>
> do while not eof(fptr)
> line input #fptr, t$
> ctr = ctr + 1
> redim preserve ls$(ctr)
> ls$(ctr)=t$
> loop
>
> close #fptr
>
> Or something similar, I use this redim preserve always when I don't know
> how much data (mostly data lines or something like that) I will have to
> keep.
>
> From the hints in the docu I cannot possibly figure out how to use
> those Java-like arrays but it seems to be a way to use them for. Can
> someone help me?
>
> Regards
> Rolf
>
More easy
DIM t AS string
DIM fptr AS INTEGER
DIM ls AS string[]
OPEN FileName FOR READ AS #fptr
WHILE NOT Eof(fptr)
LINE INPUT #fptr, t
ls.add( t )
WEND
CLOSE #fptr
Ron
More information about the User
mailing list