Chad,
The following code can be found at www.sqrtools.com. The code is by Tony DeLia
of Answer Think. I think it may do what you wish. Good luck
Ethan Kayes
Hewitt
In Chennia, India untill Sept 15.
Sample Input
"E",,,"Costs, Expense, Savings",334,01-JAN-90
"D",01-JAN-90,"Costs",,,,
"X",27-OCT-99,"A,B,C,,,embedded commas,,,","More,,,,,,",999,01-JAN-99
Main Routine - Parse Input Record into individual variables
!**********************************************************************
!* Process Main *
!**********************************************************************
begin-procedure Process-Main
let $c = ',' ! Comma
let $q = '"' ! Double Quotes
create-array name=PARmtx size=10 field=PARdata:char
while 1 = 1
read 1 into $rec:500
if #end-file = 1
break
end-if
clear-array name=PARmtx
let $rec = rtrim($rec,' ') || $c
let #len = length($rec)
let #q = 0
let #idx = 0
let #pos = 1
let $data = ''
while #pos <= #len
let $char = substr($rec, #pos, 1)
if $char = $q
let #q = #q + 1
else
if $char = $c
and mod(#q, 2) = 0
let PARmtx.PARdata (#idx) = $data
let #idx = #idx + 1
let $data = ''
else
let $data = $data || $char
end-if
end-if
let #pos = #pos + 1
end-while
let $I_code = PARmtx.PARdata (0)
let $I_date = PARmtx.PARdata (1)
let $I_cat = PARmtx.PARdata (2)
let $I_desc = PARmtx.PARdata (3)
let $I_amt = PARmtx.PARdata (4)
let $I_effdt = PARmtx.PARdata (5)
! Process Variables (Convert numerics, etc.)
display ' '
display ' Code: ' noline
display $I_code
display ' Date: ' noline
display $I_date
display ' Cat: ' noline
display $I_cat
display ' Desc: ' noline
display $I_desc
display ' Amt: ' noline
display $I_amt
display 'Effdt: ' noline
display $I_effdt
end-while
display ' '
end-procedure
!**********************************************************************
Sample Output - Displays
Code: E
Date:
Cat:
Desc: Costs, Expense, Savings
Amt: 334
Effdt: 01-JAN-90
Code: D
Date: 01-JAN-90
Cat: Costs
Desc:
Amt:
Effdt:
Code: X
Date: 27-OCT-99
Cat: A,B,C,,,embedded commas,,,
Desc: More,,,,,,
Amt: 999
Effdt: 01-JAN-99
From: "Slattery, Chad" <Chad.Slattery@CSCLAC.IRLGOV.IE> on 08/31/2000 02:20 PM
Please respond to sqr-users@list.iex.net
To: SQR-USERS@list.iex.net
cc:
Client:
Subject: Unstringing
Hi all, Does anyone know if its possible to do the following? Im opening a file for reading and unstringing a record into fields. The amount of fields could be quite large but I'll only need a set number of them for my task. My question is, is it possible to get a field from the record without having to take all the fields out first? eg, record 1 has 500 fields, I only need to get the 100th,200th,300th,400th and 500th field, is there a way I can do this without unstringing the 500 fields into variables? Im trying to use arrays as I will have to use the arguments dynamically later on in the program. TIA, Chad.Title: Unstringing
Hi all,
Does anyone know if its possible to do the following? Im opening a file for reading and unstringing a record into fields. The amount of fields could be quite large but I'll only need a set number of them for my task. My question is, is it possible to get a field from the record without having to take all the fields out first?
eg,
record 1 has 500 fields, I only need to get the 100th,200th,300th,400th and 500th field, is there a way I can do this without unstringing the 500 fields into variables?
Im trying to use arrays as I will have to use the arguments dynamically later on in the program.
TIA,
Chad.