ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to get length in CLLE

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

  • How to get length in CLLE

    How to retrieve length of CL variable like %LEN in PRGLE.
    Is there any way.....Please suggest!!!
    Cheers...
    Nil

  • #2
    Re: How to get length in CLLE

    call an rpg with 2 parameters: MyClVar and MyClVarLen.
    in the rpg
    Code:
    MyClVarLen = %len(MyClVar)
    that should work
    Regards

    Kit
    http://www.ecofitonline.com
    DeskfIT - ChangefIT - XrefIT
    ___________________________________
    There are only 3 kinds of people -
    Those that can count and those that can't.

    Comment


    • #3
      Re: How to get length in CLLE

      Originally posted by kitvb1 View Post
      call an rpg with 2 parameters: MyClVar and MyClVarLen.
      in the rpg
      Code:
      MyClVarLen = %len(MyClVar)
      that should work
      Thanks for your reply here however I do not want to use RPGLE to get lenght.
      I want it in CL only.
      Is there any way to do it?
      Cheers...
      Nil

      Comment


      • #4
        Re: How to get length in CLLE

        All you need right here ... http://www.code400.com/forum/showthr...-of-the-string

        BTW - According to the test i just did it was far faster to type "How to get length in CLLE" into google than it was to open a new post in code400. And that's without the lag of waiting for answers ...
        Greg Craill: "Life's hard - Get a helmet !!"

        Comment


        • #5
          Re: How to get length in CLLE

          That reminds me an old trick I want to keep you informed of. I use it from time to time to retrieve the length of a CL var.

          I use RTVMSG along with message Id CPF9897 to retrieve the length provided that the variable is up to 512 bytes long. The length must be 5,0 field.

          Code:
                       DCL        VAR(&LEN) TYPE(*DEC) LEN(5)
                       DCL        VAR(&PARM) TYPE(*CHAR) LEN(512) VALUE('MyValue')
                       RTVMSG     MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&PARM) +   
                                    MSGLEN(&LEN)
          In this example, the CL will return 7 which is the contents length of &PARM field.

          However the Gary's suggestion above is certainly much better.
          Last edited by Mercury; November 23, 2010, 09:12 AM.
          Philippe

          Comment

          Working...
          X