Please Help How Simplifies my code


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Please Help How Simplifies my code

    You're welcome, but there's no need to SHOUT all the time ;-)

    SELECT CASE might give you "neater" code but I've found it usually produces larger code than IF-THEN constructs and in this particular case I don't think Select Case is of any use to you.

    Another thing that might be worth a try is to do the extract the values from the array into temporary variables first, then run your comparisons. Something like:
    Code:
    TempA = DataIn[2]
    TempB = DataIn[3]
    TempC = DataIn[4]
    TempD = DataIn[5]
    TempC = DataIn[6]
    GOSUB A
    GOSUB B
    'And so on
     
    A:
      If TempA = xx THEN
        If TempB = xx THEN
    'and so on

    I'm sure there are more you can do depending on exactly what it is you're trying to achieve.

    /Henrik.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Please Help How Simplifies my code

    Are you sure this is not the reason for the slow code?
    Code:
    HSERIN [WAIT($07,$06), str DATAIN\7]
    After all, no matter how you code the checks, the pic will not take a noticable time to process that. If it compiled to 1000 lines of code, @4Mhz clock it would only take 1mSec

    What clock speed?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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