Page 1 of 1

Removing leading spaces from veriable

Posted: Sat Aug 30, 2008 11:42 am
by biswaranjan
Hi,

I want to remove leading spaces from a veriable.In PL1 how I can do that?

Ex: A= ' A BC'

I want O/P as 'A BC'

Regards
Biswa.

Posted: Thu Sep 25, 2008 10:52 am
by MikeJ024
hi,
you can use the substr builtin function to do this as follows using your example above:
a = substr(a,2,4);
substr(variable,starting pos, length)
if you have a variable # of leading spaces add the verify fuction as follows:
a = substr(a,verify(a,' '),4) this will find the first nonblank char.
hope this helps
MikeJ024

Posted: Tue May 12, 2009 10:33 am
by biswaranjan
Hi Mike,

Thank you for your help.

Regards,
Biswa.

Posted: Wed Apr 28, 2010 9:44 pm
by JSchmitt
MikeJ024 wrote:hi,
you can use the substr builtin function to do this as follows using your example above:
a = substr(a,2,4);
substr(variable,starting pos, length)
if you have a variable # of leading spaces add the verify fuction as follows:
a = substr(a,verify(a,' '),4) this will find the first nonblank char.
hope this helps
MikeJ024
If you are using Enterprise PL/1 for z/OS, you may have a look to the TRIM builtin function.

Best Regards:

Jochen Schmitt