Confused on an IF...THEN decimal # check


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    thanks mackrackit. the BoardAdd is stored in EEPROM 0, with a min value of 001 to a max value of 254. I hope that answers what your trying to ask me?

    Thanks,
    C

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kevlar129bp View Post
    I hope that answers what your trying to ask me?
    That is what little or no sleep does for me, makes me babbble more than usual.

    If 254 is the max then how could this ever happen?
    Code:
     
    IF (boardadd = 000) OR (boardadd > 254) THEN
    As Duncan says "I will get my hat now".
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Sorry, I guess I should have noted that this routine checks to make sure you don't try to write an address to EEPROM that is >254 or is =0. So, if a user enters "A280" for example, I want that to be invalid. I hope that helps explain my goal?

    Just tried it in the sim...
    I entered "A300" and it returned with,
    "Board received A044
    Board address set to 44"

    Hopefully you can see what I mean?

    Thanks again,
    C

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Ok... Go ahead and change it to a WORD. 44 is what you are getting when it rolls over.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    On that note, a word sized var won't flow over into EEPROM 1 will it? I'de like to avoid that if I could.

    Thanks again,
    C

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    It should not. Your code is making the max 254. The WORD size just lets something bigger, like 300 be seen as 300.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks Dave! I get where your goin' with that now. I'm going to give it a run. Thanks so much for your help!

    C

Similar Threads

  1. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  2. Help for decimal conversion
    By eva in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th March 2007, 18:20
  3. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  4. 16bit variable and degrees conversion
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd May 2005, 17:27
  5. Convert a word variable to decimal
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th December 2004, 20:02

Members who have read this thread : 0

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