SELECT CASE for ranges of values


Closed Thread
Results 1 to 18 of 18

Hybrid View

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


    Did you find this post helpful? Yes | No

    Cool

    If you meant the size in terms of the words used,

    I had 103 words with "IF" statement and 110 words with "Select Case" statement.

    How did you have 2.5 times more words?
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    sayzer, You are right, it maybe smaller but you have only captured half of the cases. What are you going to do about the rest of the cases ie: < 165, > 176 but < 184, and > 192?

    Dave Purola,
    N8NTA

  3. #3


    Did you find this post helpful? Yes | No

    Default case is... confusing?

    Would you have to jump out to a common goto though, after each < completes its routine? otherwise it'll execute all the ones that apply (i.e. - if your number is 130, and you have a case <140, case <150, case <160, case <170, etc. ALL apply after case <130), or is the nature of the select case such that the first one that applies ONLY is executed?

    --------------Picster----------------

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,174


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    If you meant the size in terms of the words used,

    I had 103 words with "IF" statement and 110 words with "Select Case" statement.

    How did you have 2.5 times more words?
    Hi!

    With the F877 chip I got 43 and 114 for the two codes.

    What chip did you try?

    Generally you have to keep the if statements as "thin" as possible. An AND can be replaced by one more IF resulting in less words.

    Ioannis

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    picster, Yes you are correct. The first true instance in the case statement flow is the final test before the end select .

    Dave Purola,
    N8NTA

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


    Did you find this post helpful? Yes | No

    Cool

    Hi Ioannis,

    I compiled the code with F628A.

    Pls check this post at http://www.picbasic.co.uk/forum/showthread.php?t=3548

    From PIC to PIC "words used" changes as you may guess.


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

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,174


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    Hi Ioannis,

    I compiled the code with F628A.

    Pls check this post at http://www.picbasic.co.uk/forum/showthread.php?t=3548

    From PIC to PIC "words used" changes as you may guess.
    -------------
    Yes it changes indeed. But it is a little bizzare to have such differences for devices so similar (628-877).

    I put only the modefs include. Did you put any other? Other defines?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Question

    I did not include any modifier file.
    Just the code itself.

    Meanwhile, lets take your "select case" and compile it with
    16F628A
    16F877
    12C509A

    The result is:

    16F628A = 95 words
    16F8777 = 110 words
    12C509A = 123 words

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

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,174


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    ...
    The result is:

    16F628A = 95 words
    16F8777 = 110 words
    12C509A = 123 words

    How interesting!
    Especially for the smallest part that has the largest output!!!

    Ioannis

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 05:47
  2. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 09:10
  3. Write Onewire data toa I2C memory / read ASCI
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 67
    Last Post: - 16th November 2008, 20:19
  4. Crystalfontz LCD
    By jman12 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 9th February 2007, 16:04
  5. Interrupt/timer not really interrupting...
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd May 2005, 23:05

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