Re: unstring empty string
- From: "Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx>
- Date: Fri, 27 Jul 2007 10:46:32 -0600
<46A9C297.6F0F.0085.0@xxxxxxxxxxxxxx>,On 7/27/2007 at 10:01 AM, in message
Frank Swarbrick<Frank.Swarbrick@xxxxxxxxxxxxxx> wrote:
Something unexpected (to me). Consider the following code, which is used
to
unstring key/value pair parameters and deal with them one by one.
WORKING-STORAGE SECTION.
01 WS-INIT-PARM.
05 PIC X OCCURS 0 TO 60 DEPENDING ON WS-INIT-PARM-LEN.
PROCEDURE DIVISION.
0010-CHECK-INITPARMS.
MOVE 1 TO PPTR
PERFORM WITH TEST AFTER UNTIL END-OF-PARMS
UNSTRING WS-INIT-PARM
DELIMITED BY ', ' OR SPACES OR ','
INTO PARM, COUNT IN PARM-LEN
WITH POINTER PPTR
NOT ON OVERFLOW
SET END-OF-PARMS TO TRUE
END-UNSTRING
PERFORM 0011-CHECK-PARM
END-PERFORM
EXIT.
0011-CHECK-PARM.
UNSTRING PARM DELIMITED BY '=' INTO PARM-NAME, PARM-VALUE
EVALUATE PARM-NAME
WHEN 'SYSTYPE'
MOVE PARM-VALUE TO PARM-SYS
WHEN 'ATMSYS'
MOVE PARM-VALUE TO PARM-ATMSYS
END-EVALUATE
EXIT.
For what it's worth, I was able to simplify this as follows:
0010-CHECK-INITPARMS.
MOVE 1 TO PPTR
PERFORM UNTIL PPTR > FUNCTION LENGTH(WS-INIT-PARM)
UNSTRING WS-INIT-PARM
DELIMITED BY ', ' OR SPACES OR ','
INTO PARM, COUNT IN PARM-LEN
WITH POINTER PPTR
END-UNSTRING
PERFORM 0011-CHECK-PARM
END-PERFORM
EXIT.
Not only do I avoid the annoying check for a length of zero (not present in
the example above), but I also got rid of the END-OF-PARMS flag.
I'm pretty happy with this now. Thanks for listening!
Frank
.
- Follow-Ups:
- Re: unstring empty string
- From: Richard
- Re: unstring empty string
- From: Louis Krupp
- Re: unstring empty string
- References:
- unstring empty string
- From: Frank Swarbrick
- unstring empty string
- Prev by Date: unstring empty string
- Next by Date: Re: Question regarding uniqueness
- Previous by thread: unstring empty string
- Next by thread: Re: unstring empty string
- Index(es):