Thanks for your reply James
From what I've quickly read, that is more or less what the article that
Scott Klement alludes to in his reply
http://systeminetwork.com/article/how-read-csv-file-rpg
Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill
"James H. H.
Lampert"
<jamesl@touchtone To
corp.com> Midrange Systems Technical
Sent by: Discussion
midrange-l-bounce <midrange-l@xxxxxxxxxxxx>
s@xxxxxxxxxxxx cc
Subject
02/16/2010 04:52 Re: Parsing out a string
PM
Please respond to
Midrange Systems
Technical
Discussion
<midrange-l@midra
nge.com>
Of course, it's not all that difficult to write a recursive descent
parser in ILE RPG. And in your case, it wouldn't actually need the
recursion.
Pseudocoded:
For each record
Start with the cursor at the beginning of the record, and loop:
IF the cursor is on a quote
Advance the cursor one character position
Find the first quote after the cursor position
Field is between the cursor (incl) and the quote (excl)
Advance the cursor to the closing quote
Find the first comma or EOR after the cursor position
ELSE (the cursor isn't on a quote)
Find the first comma after the cursor position
Field is between the cursor (incl) and the comma or EOR (excl)
ENDIF
IF we found a comma, instead of EOR
Advance the cursor to one character position past that comma
Continue the line loop
ENDIF
Next record
And you can even use The Cycle as your record loop.
--
JHHL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.