Changing from If..Then to Select Case


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Changing from If..Then to Select Case

    I agree with the others - IF THEN will be less code than SELECT CASE, however a couple of LOOKUP statements will be even less. I'm not sure if the mapping ever changes, but you could even track the mapping in Excel making updates easier. This is the sort of situation that LOOKUP (or LOOKUP2) was designed for.

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Default Re: Changing from If..Then to Select Case

    Thanks for your replies Henrik and Charlie.

    Yes the GOTO is only executed if the If Then is true. Doing it this way eliminates the End If statement for each line. At the time I tried this several different ways and this worked out fine. This system was designed back in 2005 and has been working fine since. I just recently had a situation where the printer output stopped working and since I cleared up the problem my brain juices told me to look into potential upgrades to the system so I am going over the code for the Master and Slaves to see if I can't make this any better. The system could go for months without any alarm activations so the speed of the system going through the IF Thens is really not a problem. I am only looking at less the a couple of seconds and that is nothing in this case. The only reason I though about the Select Case is I thought I read in a code optimization article that it used less code than the If Then hence the inquiry.

    I really appreciate all of the replies and for you folks taking the time to help me. I will let you know how things work out.

    Thanks again,

    BobK

Similar Threads

  1. About Select Case
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th February 2010, 12:54
  2. Select case...Just wondering....
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th December 2006, 00:23
  3. select case question
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th March 2006, 11:01
  4. Select Case syntax
    By keithdoxey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2005, 20:19
  5. Select Case
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th June 2005, 20:18

Members who have read this thread : 2

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