
Parsing Comma Delimited Data
Sorry I forgot to add at the end of the Loop "t#=instring(',',myfield,1,1)"
to refresh the location of the next comma
Also this is assuming there are no spurious commas within the data you want
to parse
Cheers
--
Ian Holdsworth
Senior Programmer / Assistant IT Manager
Response Analysis & Mailing Ltd
---------------------------------------------------
Direct Line: +44 (0) 20 8880 8866
Switch Board: +44 (0) 20 8880 8140
Fax: +44 (0) 0870 134 0987
Web Site: www.ram-ltd.co.uk
Quote:
> Tim
> try
> ============================================
> t#=instring(',',myfield,1,1)
> idx#=1
> loop while t#
> execute(idx#)
> field1=sub(myfield,1,t#)
> field2=sub(myfield,1,t#)
> field3=sub(myfield,1,t#)
> field4=sub(myfield,1,t#)
> field5=sub(myfield,1,t#)
> STOP('TOO MANY FIELDS'
> .
> MYFIELD=SUB(MYFIELD,T#+1,SIZE(MYFIELD))
> IDX#+=1
> END
> execute(idx#)
> field1=myfield
> field2=myfield
> field3=myfield
> field4=myfield
> field5=myfield
> STOP('TOO MANY FIELDS')
> .
> ============================================
> Cheers