Re: UNSTRING performance issue
- From: docdwarf@xxxxxxxxx ()
- Date: Tue, 29 Nov 2005 15:59:58 +0000 (UTC)
In article <1133276339.806234.154820@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Chris <ctaliercio@xxxxxxxxx> wrote:
>Given a delimited string of variable length (string-variable), suppose
>you are interested in the nth value in the string.
Question of definition, please. Given the comma-delimited string:
VAL1,,VAL2
.... are you calling VAL2 the second or third value in the string?
>
>I'm currently using the following solution:
>
>MOVE "," TO delimiter-variable
>MOVE 1 TO string-pointer
>
>PERFORM n TIMES
>
> UNSTRING
> string-variable DELIMITED BY delimiter-variable
> INTO
> string-field
> WITH POINTER
> string-pointer
> ON OVERFLOW
> SET unstring-error TO TRUE
> EXIT PERFORM
> END-UNSTRING
>
>END-PERFORM
Wow... someone has done their own homework!
>
>
>Obviously, the larger the string, the slower the performance of this
>command.
>
>I'm wondering if there is a faster way to do this that I am as yet
>unaware of?
Depends on the compiler/platform, of course... but off the top of my
pointy little head, to find the data following the nth delimiter:
Perform Varying Sub1 from 1 by 1
Until All-Done
If Variable(Sub1:1) = delimiter
Add 1 to Delims-Found
Evaluate True
When Delims-Found = n
Perform Varying Sub2 from Sub1 by 1
Until Variable(Sub2:1) = delimiter
Or Sub2 > (Length of Variable)
Continue
End-Perform
Subtract 1 from Sub2
If Sub2 > 0
Move Variable(Sub1:Sub2) To Another-Field
Else
PERFORM B1520-EMPTY-FIELD-RITUAL THRU B1520-EFR-EX
End-Evaluate
End-If
End-Perform
.... or something like that, the errors in my extemporaneous coding should
be obvious.
DD
.
- Follow-Ups:
- Re: UNSTRING performance issue
- From: Chris
- Re: UNSTRING performance issue
- References:
- UNSTRING performance issue
- From: Chris
- UNSTRING performance issue
- Prev by Date: Re: UNSTRING performance issue
- Next by Date: Re: UNSTRING performance issue
- Previous by thread: Re: UNSTRING performance issue
- Next by thread: Re: UNSTRING performance issue
- Index(es):
Relevant Pages
|