Suppress leading zeros


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59

    Default Suppress leading zeros

    Is it possible to suppress leading zeros within a standard 7 segment multiplexed display routine (as sample MELABS http://melabs.com/resources/samples/pbp/7segment.pbp)?
    A pointer in the right direction would be appreciated

    Thanks

    Adrian

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Post

    Hi,

    suppose we have 4 digits ...

    IF Value < 1000 ... first digit = 0 ... so, do not show it ( or print blank ! )
    IF Value < 100 ... second digit = 0 ... so, do not show it
    IF Value < 10 ... Third digit = 0 ...

    or use a flag ...

    for digit 1 to 4

    IF Digit = 0 AND Flag = 0 then

    ... do not show it : Flag = 0

    ELSE

    ... Show it : Flag = 1

    ENDIF

    Next digit

    Alain
    Last edited by Acetronics2; - 24th June 2008 at 16:08.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,
    ...

    or use a flag ...

    for digit 1 to 4

    IF Digit = 0 AND Flag = 0 then

    ... do not show it : Flag = 0

    ELSE

    ... Show it : Flag = 1

    ENDIF

    Next digit

    Alain

    If the digit variable in this loop can only take values from 1 to 4, how can "IF Digit = 0 AND Flag = 0 then..." work?


    -------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59


    Did you find this post helpful? Yes | No

    Default

    You're a star..many thanks

    Adrian

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Talking

    Hi, Sayzer

    Would " If digit_value ... " help you to understand how this test is supposed to work ???

    I know PbP is case insensitive, "for digit 1 to 4" is not a PbP correct writing, only here to explain things ...but ... May I suppose you need further explanation ... ???

    Alain
    Last edited by Acetronics2; - 24th June 2008 at 21:52.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Can we suppress leading zero's in LCDOUT?
    By PICn-It in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2009, 16:09
  2. Leading 0's or BCD
    By RYTECH in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th December 2005, 01:06
  3. max7219 blank leading zeroes
    By lutherblissett in forum General
    Replies: 0
    Last Post: - 13th November 2005, 16:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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