ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Leading Zeros

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

  • Leading Zeros

    I have an integer counter variable that I move to a character variable of the same size so that I can concatenate it into a message text string. Is there a way to get rid of the leading zeros when i convert from Int to Char?
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

  • #2
    Re: Leading Zeros

    When you use
    Code:
    eval  mycharfield  = %char(mydecimalfield)
    the leading *zeros will be removed.

    to keep them use
    Code:
    eval mycharfield = %editc(mydecimalfield:'X')
    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


    • #3
      Re: Leading Zeros

      BINGO was his NAMEO. Thanks a ton Jamie. So simple these things.
      Your future President
      Bryce

      ---------------------------------------------
      http://www.bravobryce.com

      Comment


      • #4
        Re: Leading Zeros

        *chants* Jamie for prez!
        Hail to the king, baby.

        Comment


        • #5
          Re: Leading Zeros

          OH Geeze .. here we go again...

          RED .. could you widen the door for Jamie's head again???

          Comment


          • #6
            Re: Leading Zeros

            How polite of you to reference his head rather than....
            Hail to the king, baby.

            Comment


            • #7
              Re: Leading Zeros

              Originally posted by jamief View Post
              When you use
              Code:
              eval  mycharfield  = %char(mydecimalfield)
              the leading *zeros will be removed.

              to keep them use
              Code:
              eval mycharfield = %editc(mydecimalfield:'X')
              One possible alternative to the %CHAR built-in function is to use the Z edit code:
              Code:
              eval mycharfield = %editc(mydecimalfield:'Z')
              This also removes leading zeros.
              "Time passes, but sometimes it beats the <crap> out of you as it goes."

              Comment

              Working...
              X