Re: Read a username from text file and save that in string array llandale - Tue Sep 20 11:09:36 EDT 2011
Problem is that you must declare the array at the right size, meaning you must read the file and count then lines before declaring the array.
string NameFile =
"c:/Doors-Stuff/abc.txt" Stream str = read(NameFile)
if (
null str)
{errorBox(
"Cannot open file [" NameFile);halt
} string Line Skip skp = create()
// KEY: 'int' sequence; DATA: 'string' value
int Sequence = 0
while(!end str)
{ str >>Line put(skp, Sequence++, Line)
} close(str) string List[Sequence]
for Line in skp
do
{ Sequence = (
int key skp) List[Sequence] = Line
} delete(skp)
for (Sequence = 0; Sequence < sizeof(List); Sequence++)
{ print Sequence
"\t" List[Sequence]
"\n"
}
|