ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Trim a variable in CL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trim a variable in CL

    Hi,

    Could anyone tell me how do you trim the trailing blanks from a CL variable? Any BIF??

    TIA
    Regards,
    Ruma

  • #2
    Re: Trim a variable in CL

    Use *TCAT


    which joins two strings with the first string trimmed (without trailing blanks ), TCAT results in a string that has no embedded blanks no matter how many trailing blanks were found in the string
    Thanks,
    Giri

    Comment


    • #3
      Re: Trim a variable in CL

      Thanks Giri, but my problem is that i dont want to concatenate 2 strings, just remove the trailing blanks of a variable and send it as a parameter to some other program.
      Regards,
      Ruma

      Comment


      • #4
        Re: Trim a variable in CL

        Is this question hinting at another problem. Does this variable contain "garbage" when it reaches the called program....and is this parm Xtra long like 25 + Characters?
        If so then make this parameter the last in the plist.

        otherwise there is no need to trim the trailing blanks of a character field just clear it first
        and move your data into it.


        Jamie
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: Trim a variable in CL

          Hi Jamie,

          i am calling a standard program which already exists in the application so i cant change the sequence of the parameters. Also, it is only 10 char long.

          any ideas on how to fix the problem in the CL which i am making?

          Regards,
          Ruma
          Regards,
          Ruma

          Comment


          • #6
            Re: Trim a variable in CL

            Then we are back to giri post. if you are moving a constant into this field then use this:

            x = *blank

            chgvar &chr10 'ABCxxxxxxx'

            or

            chgvar &Chr10 'xxxxxxxxxx'
            CHGVAR VAR(%SST(&Chr10 1 3 )) VALUE('ABC')

            If possible lets post some of the code and let us know what is your true problem.

            Thank you
            Jamie
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment

            Working...
            X