Hey Gambler, feel lucky today ?

If your betting on using KiXtart 2001 (RC3) - you can use the new SPLIT() function to automatically parse-out a string into array elements ... this example reads a CSV file and displays the third comma-delimited field :


code:

break on


$logfile = "D:\TEST.DAT" <-- change this


if open(1,$logfile,2) = 0
$line = readline(1)
while @error = 0
$array = split($line,",")
?"Third element = " $array[2]
$line = readline(1)
loop
$ = close(1)
endif


exit 1



Carefull - the SPLIT function will have you rolling snake-eyes if your CSV file contains unexpected lines - might have to make this code more robust ...

-Shawn