Shop OBEX P1 Docs P2 Docs Learn Events
AW: [basicstamps] Re: Select/Case — Parallax Forums

AW: [basicstamps] Re: Select/Case

ArchiverArchiver Posts: 46,084
edited 2003-03-20 17:13 in General Discussion
Hi Adrian,

first of all thanks very much for your help. As I read in your explanation I
think I understood the case / tcase right. But when I tried to make one
SELECT / ENDSELECT loop out of the single ones I am using now it just didn't
work though I used TCASE which should lead to exactly the same result.

I think when my program is all ready and tested I will try to recahnge it to
the one big loop, if it still doesn't work I might send you the code and you
could have a look if you find the mistake. I donot have to look at the port
after each SELECT CASE, that was not the reason why I switched to single
loops.

Thanx very much again and I will tell you about my progress.

Have a nice day, Uli


possibly your program uses more selects than are neccessary, it
depends on what you intend to do. Wich each new select you are
re-reading sensorport (which may be what you intend/need to do).

I assume sensorport ranges from 0 to 15, so you could simplify some
of your cases to a more efficient if statement:

select sensorport
case 1,3,5,7,9,11,13,15

could be replaced by

if sensorport.bit0 = 1 'all odd values

and

select sensorport
case 1,3,5,7,9,11,13,15

could be replaced by

if sensorport.bit0 = 0 'all even values

The difference between case and tcase is that after a case clause
execution continues after the endselect,
after a Tcase execution continues after the Tcase clause possibly
leading into a following case/tcase clause.

Example:

For x = 1 the following select executes actions_1 only, for x = 3
it executes actions_2.

select x
case 1
actions_1
case <5
actions_2
endselect

For x = 1 the following select executes actions_1 and actions2 as
x is = 1 and < 5 as well, for x = 3 it executes actions_2 only.

select x
tcase 1
actions_1
case <5
actions_2
endselect

regards
Adrian


To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





[noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.