Page 1 of 1

UNSTRING into unknown number of tokens.

PostPosted: Tue Jan 24, 2012 3:28 pm
by vinodj
Hello,

I did UNSTRING of a source dataset like this : UNSTRING source_dsn delimited by "." INTO Q1, Q2, Q3

But now I want to UNSTRING it into unknown number of qualifiers. For that I declared an array (occurs 15 times) and did UNSTRING like this :

perform varying i from 1 by 1 until i<=15
UNSTRING source_dsn delimited by "." INTO Q(i)

But this will always give me the first qualifier, could somebody suggest me an approach as to how it could it be done?

Regards,
Vinod

Re: UNSTRING into unknown number of tokens.

PostPosted: Tue Jan 24, 2012 3:38 pm
by BillyBoyo
I assume that you mean the problem is that each UNSTRING in the loop is picking up the same piece of information, the first one.

Look up UNSTRING in the manuals, and consider especially POINTER. This should get you what you want, for the loop,

I'm not convinced there is a benefit to doing it that way over coding out UNSTRING with 15 values. One UNSTRING against an "average" of seven-and-a-half UNSTRINGs. TALLYING will give you number of fields populated.

Remember to initialise all receiving fields for the UNSTRING, else you'll get data left over from the previous UNSTRING (in your loop, you want the data left over for the POINTER in each iteration, but you must initialise to zero before entering the loop).