Why not using the statement below?
IF PulseLength > 165 AND PulseLength < 176 THEN
OutValue=0
ELSE
IF PulseLength > 184 OR PulseLength < 192 THEN OutValue=1
ENDIF
----------------------
Why not using the statement below?
IF PulseLength > 165 AND PulseLength < 176 THEN
OutValue=0
ELSE
IF PulseLength > 184 OR PulseLength < 192 THEN OutValue=1
ENDIF
----------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Because the above compiles almost 2.5 times longer!Originally Posted by sayzer
Ioannis
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
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
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----------------
Hi!Originally Posted by sayzer
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
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
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
Yes it changes indeed. But it is a little bizzare to have such differences for devices so similar (628-877).Originally Posted by sayzer
I put only the modefs include. Did you put any other? Other defines?
Ioannis
Bookmarks