View previous topic :: View next topic
|
Author |
Message |
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
Hi
Please explain me how to remove leading spaces in a variable.
ex
A = ' 124050'
Where A is x(18).
I want A shouls contain as 'welcom' with out any space in front oi it. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
rajesh_mbt,
Althoguh your given examples doesnt make sense... but hopefully this is what you are looking for:-
Code: |
INITIALIZE WS-LEN-LEAD-SPACE.
INSPECT WS-STRING TALLYING WS-LEN-LEAD-SPACE FOR LEADING SPACES.
COMPUTE WS-LEN-ACTUAL-STR = 18 - WS-LEN-LEAD-SPACE.
MOVE WS-STRING (WS-LEN-LEAD-SPACE+1: WS-LEN-ACTUAL-STR) TO WS-EDITED-STRING. |
Code above would remove leading spaces from the WS-STRING and WS-EDITED-STRING would contain rest of the data with spaces padded behind. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Would not a JUSTIFY LEFT work? |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
Would not a JUSTIFY LEFT work? |
Hey Bill... Would "JUST LEFT" strip the "spaces" ahead... I doubt ... |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yea, I think you're right...I guess I don't use justify enough to remember.... |
|
Back to top |
|
|
|