Bug while Parsing with variable patterns

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Bug while Parsing with variable patterns

Mike Cowlishaw-2
This one is working correctly.  Remember that splitting a substring
up into words takes place after the substring has been identified in
the source string by using a pattern.  Hence in your example:

  parse data n first =(n) second

The first pattern is found (=(n)), and the string is split at that
point (position 10).  Then the 9 characters thus found are split
into the first word (placed in the variable 'n') and the remainder
(placed in the variable 'first').  So 'n' doesn't get the value 5
until after the pattern has been used.

If you used a pattern to separate off the first word (similar to
the example in NRL on page 129):

  parse data n ' ' first =(n) second

then the variable 'n' will get its new value before it is used in the
second pattern.  (This wouldn't work if there could be a blank before
the number.)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cowlishaw, IBM Fellow, IBM UK Laboratories
mailto:[hidden email]   [http://www2.hursley.ibm.com]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>