Announcement

Collapse
No announcement yet.

Forced leading padded zeroes?

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

  • Forced leading padded zeroes?

    I am trying to format a result so that it contains leading zeroes, and save that to a text variable. If:

    Red = 3122:Kount=0
    Unread= Red - Kount
    Unread$ = using$("#,###,###",Unread)
    Print Unread$;" Not Read"


    Acutal Result:
    3,122 Not Read

    Preferred Result:
    0,003,122 Not Read

    Short of checking the length of Unread$ and then appending the correct number of zeroes in the front, is there a way to force the zeroes to appear using USING$ ? It shows up as nothing (i.e., correct according to format), which is correct functionally, but I would really appreciate the zeroes being padded in the front.

    Thank you.

    Robert

  • #2
    Hi,

    did not do much tests, but for this case it worked well:
    Code:
    UnreadText = FORMAT$(Unread, "0,000,000")
    I think for 7 and less digit numbers it should work without problem.


    Petr
    [email protected]

    Comment


    • #3
      We need FORMAT$ here:
      Code:
      Red = 3122:Kount=0
      Unread= Red - Kount
      'UnreadS = USING$("#,###,###",Unread)
      UnreadS = FORMAT$(Unread, "0,000,000")
      PRINT UnreadS;" Not Read"

      Comment


      • #4
        Code:
         
        W =  RIGHT$ (STRING$(fieldsize, "0") &  FORMAT$("#,", value), fieldsize)
        (It's less tortured with RSET$ but I can't recall if PB/DOS has an RSET$ ..USING function)
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X