|
Previous Top Next |
Prototype: | (STRING pLine, STRING pDelimiter, BYTE pRemoveQuotes=TRUE,<STRING pQuote>)!!,LONG,PROC |
pLine | The line to parse |
pDelimiter | Delimeter to search for |
pRemoveQuotes | If TRUE it removes the pQuote character from the first and last position in the word(s) |
pQuote | Quote character to look for and remove. Defaults to double quote (") |
Returns | Returns number of "words" parsed out of the pLine string. |
This method takes a string with a single line of delimited data and parses it into the Words queue. Please note the wrong spelling of delimited in the method name. In January 2016, we added a correctly spelled method, ParseDelimitedLine, that simply calls this method.
Example:
Given a file called Test.txt:
"Name","Title","FirstName","MI","LastName","Empty","Address","City","State"
"Mr. Terry Gilley","Mr.","Terry","","Gilley","","1425 N Field St Apt 1111","Austin","TX"
"Mr. John Davis","Mr.","John","","Davis","","1825 Adolph St","El Paso","TX"
Program
Map
End
Include('ITUtilityClass.inc'),ONCE
FN CString(1025)
ITS ITStringClass
I Long
Code
FN = 'Test.txt'
ITS.FileToString(FN)
ITS.ODS('File len: ' & Len(ITS.FileString))
ITS.StringToLines(ITS.FileString)
ITS.ODS('Lines: ' & Records(ITS.Lines))
Loop I = 1 To Records(ITS.Lines)
Get(ITS.Lines,I)
ITS.ODS('Line ' & Format(I,@n3) & ': ' & ITS.Lines.OL)
ITS.ParseDelimtedLine (ITS.Lines.OL, ',',,'"')
End
Would yield 3 lines and each line would be parsed into 9 words or records in the ITS.Words queue.
See also: