Printing leading zeros


+ Reply to Thread
Results 1 to 8 of 8

Thread: Printing leading zeros1114 days old

  1. #1
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,748
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Printing leading zeros

    Hello

    I have a print routine that is taking a value that's been scaled eg

    wValue1 = 99

    It needs to be descaled by div by 1000

    So I have this routine
    Print At 1,1, Dec (wValue1 / 1000),".",Dec (wValue1 // 1000)," "

    But its printing 0.99 when it should be 0.099

    I'm not sure how to get it to print the leading 0.

    Any ideas?

    Thanks Tim
    Tim

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,748
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Printing leading zeros

    Hi,

    Ok worked out a system

    wDisplayValueh = wValue1 / 1000
    wDisplayValuel = wValue1 // 1000
    Print At 1,9, Dec wDisplayValueh,"."
    If wDisplayValuel < 100 Then Print "0"
    Print Dec wDisplayValuel," "
    Tim

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,884
    Thumbs Up
    Received: 91
    Given: 34
    Total Downloaded
    4.60 GB

    0 Not allowed!

    Default Re: Printing leading zeros

    Hi Tim,
    I think you're only half way there. What about if the second result is <10.
    You need another line to do that and insert two zeroes.
    I also have a vague recollection that Proton supports what you're trying to do. I'm on my tablet and can't check.
    John

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,557
    Thumbs Up
    Received: 76
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: Printing leading zeros

    Had same problem and used similar approach: -


    Code:
    wDisplayValueh = wValue1 / 1000
    wDisplayValuel = wValue1 // 1000 
    Print At 1,9, Dec wDisplayValueh,"."
    If wDisplayValuel < 100 Then Print "0"
    If wDisplayValuel < 10 Then Print "0"
    Print Dec wDisplayValuel," "
    Regards

    Joseph

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,584
    Thumbs Up
    Received: 337
    Given: 161
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Printing leading zeros


    Print At 1, 1, Dec (wValue1 / 1000), ".", Dec3 (wValue1 // 1000), " "

    Dec3 will always output 3 ASCII characters, regardless of the value.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,557
    Thumbs Up
    Received: 76
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: Printing leading zeros

    You're right Les.

    The problem I had was different. Checked the code I did and I did not wanted the leading zero, but wanted that the digit remained on the same location on the LCD.

    E.g.: -

    Code:
    Select Var1
            Case > 999
            Print At 1,1, Dec Var1
            
            Case > 99
            Print At 1,,1, " " , Dec Var1
            
            Case > 9
            Print At 1,,1, "  " , Dec Var1
            
            Case Else
            Print At 1,,1, "   " , Dec Var1       
    EndSelect
    Regards

    Joseph

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,748
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Printing leading zeros

    Thanks every one Dec3 solved it.

    Tim
    Tim

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,884
    Thumbs Up
    Received: 91
    Given: 34
    Total Downloaded
    4.60 GB

    0 Not allowed!

    Default Re: Printing leading zeros

    Someone once said there's more than one way to skin a cat.
    I'm going to revisit one of my recent programs to use Les's option.
    John

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. 1-Wire oRead returns Zeros
    By mjturner in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 10th January 2016, 17:04
  2. [SOLVED !] printing with leading spaces
    By Puffeltje in forum Proton Plus Compiler v3
    Replies: 18
    Last Post: 26th October 2012, 04:00
  3. [SOLVED !] Leading zero's
    By ~ Sy ~ in forum The Lounge
    Replies: 2
    Last Post: 9th August 2009, 19:44
  4. [SOLVED !] Displaying Leading zero's
    By Alan in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 11th August 2007, 11:54
  5. Leading Edge Technology Pic programmer
    By stevene in forum The Lounge
    Replies: 9
    Last Post: 17th May 2006, 07:36

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts