Removing leading spaces from veriable

Post your questions on PL/I.

Moderator: Moderator Group

Post Reply
biswaranjan
Member
Posts: 20
Joined: Thu Aug 28, 2008 10:41 am

Removing leading spaces from veriable

Post by biswaranjan » Sat Aug 30, 2008 11:42 am

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.

MikeJ024
Member
Posts: 12
Joined: Wed Jun 18, 2008 1:36 pm

Post by MikeJ024 » Thu Sep 25, 2008 10:52 am

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

biswaranjan
Member
Posts: 20
Joined: Thu Aug 28, 2008 10:41 am

Post by biswaranjan » Tue May 12, 2009 10:33 am

Hi Mike,

Thank you for your help.

Regards,
Biswa.

JSchmitt
Member
Posts: 3
Joined: Wed Apr 28, 2010 9:34 pm

Post by JSchmitt » Wed Apr 28, 2010 9:44 pm

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

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others