Subject: | |
From: | |
Reply To: | |
Date: | Sat, 19 Oct 2002 07:47:02 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
That is an interesting solution, but it SCREAMS out for optimization :)
Instead of "reversing in place", I'd reverse the names to a third field
thusly:
MOVE FUNCTION REVERSE (WS-FIRSTNAME) TO WS-WORKFIELD
INSPECT WS-WORKFIELD TALLYING SP-COUNT FOR LEADING SPACES
COMPUTE FN-LEN = <workfield_length> - SP-COUNT
MOVE FUNCTION REVERSE (WS-LASTNAME) TO WS-WORKFIELD
INSPECT WS-WORKFIELD TALLYING SP-COUNT FOR LEADING SPACES
COMPUTE LN-LEN = <workfield_length> - SP-COUNT
MOVE SPACES TO DISPLAY-NAME.
MOVE WS-FIRSTNAME (1:FN-LEN) TO DISPLAY-NAME.
ADD 1 TI FN-LEN.
MOVE WS-LASTNAME (1:LN-LEN) TO DISPLAY-NAME(FN-LEN:LN-LEN).
[note: <workfield_length> is a constant, derived from whatever you set the
PIC clause for WS-WORKFIELD to in the first place]
Of course, at today's processor speeds, flipping a 30-byte character string
around "an extra time" probably doesn't matter (it certainly doesn't matter
if all you're doing is processing one name/field for display on a screen --
it *might* matter if you were processing a billion names for a
report/mailing list...)
> -----Original Message-----
> From: Schlosser, Robert J
>
> Raghu
>
> With the FUNCTIONS available when the POST85 compiler
> directive is invoked you can do the following:
>
> MOVE FUNCTION REVERSE (WS-FIRSTNAME) TO WS-FIRSTNAME.
> INSPECT WS-FIRSTNAME TALLYING SPACE-COUNT FOR LEADING SPACES.
> MOVE FUNCTION REVERSE (WS-FIRSTNAME) TO WS-FIRSTNAME.
> SUBTRACT SPACE-COUNT FROM {len of ws-firstname) GIVING FN-LEN.
> MOVE FUNCTION REVERSE (WS-LASTNAME) TO WS-LASTNAME.
> INSPECT WS-LASTNAME TALLYING SPACE-COUNT FOR LEADING SPACES.
> MOVE FUNCTION REVERSE (WS-LASTNAME) TO WS-LASTNAME.
> SUBTRACT SPACE-COUNT FROM {len of ws-lastname) GIVING LN-LEN.
> MOVE SPACES TO DISPLAY-NAME.
> MOVE WS-FIRSTNAME (1:FN-LEN) TO DISPLAY-NAME.
> ADD 1 TI FN-LEN.
> MOVE WS-LASTNAME (1:LN-LEN) TO DISPLAY-NAME(FN-LEN:LN-LEN).
>
>
> For those special cases, a space in the first name
> field should give you the starting point
> to parse them out and move them to the correct places.
>
[...]
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|