Parsing comma delimited string

stepone

Registered User.
Local time
Today, 06:21
Joined
Mar 2, 2004
Messages
97
Hi folks,

Looking for help here. I have written a routine to read in lines from a text file. The values in there are comma-delimited. I read them in one at a time using textfile.readline, which works fine.

I have written two functions, Head and Tail, which split a string around the first comma. My code to read in each line then looks like this ;

If Left(mystring, 3) = "307" Then
mystring = tail(mystring)
mystring = tail(mystring)
strbillCost = head(mystring)
mystring = tail(mystring)
strtaxCost = head(mystring)
mystring = tail(mystring)
strtotalDiscount = head(mystring)
mystring = tail(mystring)
strpreDiscountCost = head(mystring)
mystring = tail(mystring)
mystring = tail(mystring)
streventSubclass = head(mystring)
mystring = tail(mystring)
streventClass = head(mystring)
endif

This seems to work okay, but it is slow, and I wondered if there was a more efficient way of doing it. E.g. is it possible to set up some sort of mask which the text line can be matched against to populate the variables ?

Thanks for your help,
Peter. :)
 
Hello all - dont worry, I found a bit of code explaining the SPLIT function which seems to do what I want.

Thanks,
Peter
 

Users who are viewing this thread

Back
Top Bottom