[Gambas-user] load file content in an array

Amon Forstmann amon at ...715...
Fri Jul 8 17:33:04 CEST 2005


Thanks for your help Rob & Juan,

I'll try both methods.

Amon

Am Freitag, den 08.07.2005, 01:30 -0400 schrieb Rob:
> On Thursday 07 July 2005 16:59, Amon Forstmann wrote:
> > is it possible to load the content of a file in an array?
> > For each line of that file a new array entry?
> 
> Sure.
> 
> dim f as file
> dim s as string
> dim sa as new string[]
> 
> ' If memory use isn't a problem....
> 
> sa = split(File.Load("filename.txt"), "\n")
> 
> ' If it's a big file or you're short of memory....
> ' I'll use 1.9.11 syntax, even though I can't test it yet ;)
> 
> f = open("filename.txt") for read
> do while not eof(f)
> 	line input #f, s
>         sa.add(s)
> loop
> 
> You should consider all of the above to be pseudo-code, but it should 
> help you understand the various ways of doing what you want.
> 
> Rob
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
> core and dual graphics technology at this free one hour event hosted by HP, 
> AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list