Shop OBEX P1 Docs P2 Docs Learn Events
Conditions Help please — Parallax Forums

Conditions Help please

Brian CarpenterBrian Carpenter Posts: 728
edited 2005-09-02 02:34 in BASIC Stamp
currently the code reads like this.· Thanks to help from this Forum.

SELECT X
CASE X <= 6500
· GOSUB UP
CASE X >= 6900
· GOSUB DOWN
CASE ELSE
· DEBUG CR, "······ ECenter"
· pw = 750
· S_Chan = cha
· S_Speed = rb
· GOSUB SendIt
ENDSELECT

But what if i wanted to make the ranges diferent.· For instance, i would like to say

if x >= 6900 but·Less than·7000 then A
if x >=·7000 then B
if x <= 6500 but grater than 6400 then C
if x<= 6400 then D

How would this be written?· Thanks guys
·would it be put into a lookup or lookdown table?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


It's Only A Stupid Question If You Have Not Googled It First!!

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-02 02:34
    I would do this:

    · SELECT x
    ··· CASE 0 TO 6400
    ····· ' task d
    ··· CASE 6401 TO 6500
    ······'·task c
    ··· CASE 6900 TO 6999
    ····· ' task·a
    ··· CASE >=7000
    ····· ' task·b
    ··· CASE ELSE
    ····· ' value out of range
    · ENDSELECT

    Note: I used x to match your code but using single-letter variables in programming is really bad form.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.