View previous topic :: View next topic
|
Author |
Message |
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
In my program I am receiving a parm string of 10 characters.
I need to extract everything but the spaces and place that data into a field whos length is equal to the number of characters extracted.
Is there an easy way to do this?
Examples; (@ is a space)
'@@@@ABCD@@' result 'ABCD' length 4 no trailing or leading spaces
'@@@@AB@@@@' result 'AB' length 2 no trailing or leading spaces
'@@A@@@@@@@' result 'A' length 1 no trailing or leading spaces |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
This should come close.....
Code: |
working storage:
01 save.
05 save-size pic s9(4) comp.
05 save-area pic x occurs 100 times
depending on save-size.
linkage:
01 parm.
05 parm-size pic s9(4) comp.
05 parm-area pic x occurs 100 times
depending on parm-size.
procedure:
Perform varying x from 1 by 1 until x > parm-size
if parm-area(x:1) = space
continue
else
unstring parm-area(x:function length(parm-area + 1) - x)
into save-area delimited by spaces
count in save-length
end-unstring
end-fi
end-perform
|
|
|
Back to top |
|
|
jcbrowser
New User
Joined: 06 Oct 2005 Posts: 12
|
|
|
|
Thanks William, I will give that a try |
|
Back to top |
|
|
|