Read a username from text file and save that in string array

Hi All,

I am having a text file containing names, i want a DXL script that will read this file and store all name in a string array.

Example

abc.txt

bonita
mark
james
enyuj
Coolvikas - Tue Sep 20 08:55:52 EDT 2011

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" 
}

  • Louie