"WAIT" modifier with multiple choices - how to?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default "WAIT" modifier with multiple choices - how to?

    ps you can use case = "A" to make it more readable
    Thanks for the tip, Richard

    Using a 16F630 for this project, I'm quite limited in program size.

    I tried something like this too:
    Code:
    IF InString[0] = 65 AND InString[1] = 65 AND InString[2] = 65 THEN Blinks = 1
    IF InString[0] = 66 AND InString[1] = 66 AND InString[2] = 66 THEN Blinks = 2
    IF InString[0] = 67 AND InString[1] = 67 AND InString[2] = 67 THEN Blinks = 3
    But, if I recall well, this code is around 80 words larger than the nested IF..THEN conditions.

    And as far as I can remember, SELECT CASE is also quite word consuming. I'll still give it a try later...
    Roger

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: "WAIT" modifier with multiple choices - how to?

    The AND in the If statement is really memory hungry.

    Ioannis

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: "WAIT" modifier with multiple choices - how to?

    Long ago, our member Melanie posted this great test program parsing strings and executing commands from a terminal through serial port, with no interrupts in a fast closed loop. It had great structure and expanding possibilities.

    Have a look here for the comms1.bas program: http://www.picbasic.co.uk/forum/show...=2078#post2078

    Ioannis

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: "WAIT" modifier with multiple choices - how to?

    also, might need a real chip though. 64 bytes for serial work is a challenge
    16f1825 or 16f18326 vs 16f630 price difference trivial performance and resources difference enormous , just saying.

    an asm routine can do a string compare much more efficiently if you have a chip with two fsr's but the old clunkers
    don't have that either. its a difficult path with meagre resources.
    all good fun though.

    Code:
    InString VAR BYTE[4]
    InString[3]=1
    ARRAYREAD InString, 4, ncb, [WAIT ("AAA"),Blinks]
    goto ncx
    ncb:
    InString[3]=2
    ARRAYREAD InString, 4, ncc, [WAIT ("BBB"),Blinks]
    goto ncx
    ncc:
    InString[3]=3
    ARRAYREAD InString, 4, ncd, [WAIT ("CCC"),Blinks]
    goto ncx
    ncd:
    Blinks=0
    ncx:
    other option is a if elseif chain , not sure anymore which used least ram,flash
    Last edited by richard; - 3rd January 2022 at 10:15.
    Warning I'm not a teacher

Similar Threads

  1. How to do the "SerIN" and "SerOut " for the usb ?
    By vicce67 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th March 2015, 02:01
  2. Replies: 0
    Last Post: - 14th November 2013, 03:32
  3. Replies: 3
    Last Post: - 15th October 2012, 08:06
  4. Multiple "AND"'s in select case?
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st January 2010, 19:10
  5. Replies: 1
    Last Post: - 16th February 2005, 20:05

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