Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp Case help — Parallax Forums

Basic Stamp Case help

Mike DMike D Posts: 3
edited 2005-07-01 14:48 in BASIC Stamp
GRR this is frustrating.· Im trying to run a remote program through my robot but when I run the program it says "Expected statements to follow previous 'CASE'".· It highlights Endselect when it says that but Im just confused.· Can anyone help me?

Comments

  • KenMKenM Posts: 657
    edited 2005-07-01 14:15
    Can·you post your program?

    In the modified code below, the variable is "gear" and depending on the state of gear I take some action. In this case I left only commented debug statements to make the example easy to follow.

    If gear is $C0 then do some stuff related to 1st gear
    If gear is $A8 then do some stuff related to 2nd gear

    etc.
     SELECT gear
    
        CASE $C0                 
        'DEBUG "1st gear ", CR
       
        CASE $A8
        'DEBUG "2nd gear ", CR
      
        CASE $D8
        'DEBUG "3rd gear ", CR
       
        CASE $F0
        'DEBUG "4th gear ", CR
       
        CASE $90
        'DEBUG "4th gear ", CR
       
     ENDSELECT
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ken

    Post Edited (KenM) : 7/1/2005 2:22:04 PM GMT
  • Mike DMike D Posts: 3
    edited 2005-07-01 14:22
    its a long program but


    'Version 030217
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    '
    ' WORKSHOP 4 - LAB 8
    '
    '
    ''''''''''''''''
    ' main routine '
    ''''''''''''''''
    DEBUG "Reset",CR

    DO WHILE 1 'loop forever
    GOSUB getcode 'get remote signal code
    DEBUG ?receive 'display which code was pressed
    'and then perform an action
    SELECT receive
    CASE 770
    'up button pressed
    FOR x = 0 TO 9
    PULSOUT 14, 750-150
    PULSOUT 15, 750+150
    PAUSE 20
    NEXT
    CASE 962
    'down button pressed
    FOR x = 0 TO 9
    PULSOUT 14, 750+150
    PULSOUT 15, 750-150
    PAUSE 20
    NEXT
    CASE 834
    'left button pressed
    FOR x = 0 TO 9
    PULSOUT 14, 750+150
    PULSOUT 15, 750+150
    PAUSE 20
    NEXT
    CASE 898
    'right button pressed
    FOR x = 0 TO 9
    PULSOUT 14, 750-150
    PULSOUT 15, 750-150
    PAUSE 20
    NEXT
    CASE 850
    'power button pressed
    END
    CASE 594
    'mute button pressed
    FREQOUT 1, 750, 1046 'C
    FREQOUT 1, 750, 1567 'G
    FREQOUT 1, 250, 1396 'F
    FREQOUT 1, 250, 1318 'E
    FREQOUT 1, 250, 1174 'D
    FREQOUT 1, 700, 2092 'C
    FREQOUT 1, 700, 1567 'G
    FREQOUT 1, 250, 1396 'F
    FREQOUT 1, 250, 1318 'E
    FREQOUT 1, 250, 1174 'D
    FREQOUT 1, 700, 2092 'C
    FREQOUT 1, 700, 1567 'G
    FREQOUT 1, 250, 1396 'F
    FREQOUT 1, 250, 1318 'E
    FREQOUT 1, 250, 1396 'F
    FREQOUT 1, 700, 1174 'D
    CASE 930
    ENDSELECT <---There is the problem
    LOOP
    ''''''''''''''''''''''''''''''''''''''''''''
    'subroutine for scanning for remote signal '
    ' do not change '
    ' '
    ' hook up IR receiver to pin 0 '
    ''''''''''''''''''''''''''''''''''''''''''''
    getcode:
    RECEIVE VAR Word
    COPY VAR Word
    IR_IN CON 0 'change this number
    IR_Pin VAR IN0 'and this number
    buffer VAR Word(4)
    x VAR Byte
    bitcount VAR Nib
    beats VAR Nib
    copy = receive
    wait_for_clear:
    IF IR_PIN = 0 THEN wait_for_clear
    IF IR_PIN = 0 THEN wait_for_clear
    IF IR_PIN = 0 THEN wait_for_clear
    IF IR_PIN = 0 THEN wait_for_clear
    IF IR_PIN = 0 THEN wait_for_clear
    wait_for_signal:
    IF IR_PIN = 1 THEN wait_for_signal
    buffer.BIT0(0) = ~IR_PIN
    buffer.BIT0(1) = ~IR_PIN
    buffer.BIT0(2) = ~IR_PIN
    buffer.BIT0(3) = ~IR_PIN
    buffer.BIT0(4) = ~IR_PIN
    buffer.BIT0(5) = ~IR_PIN
    buffer.BIT0(6) = ~IR_PIN
    buffer.BIT0(7) = ~IR_PIN
    buffer.BIT0(8) = ~IR_PIN
    buffer.BIT0(9) = ~IR_PIN
    buffer.BIT0(10) = ~IR_PIN
    buffer.BIT0(11) = ~IR_PIN
    buffer.BIT0(12) = ~IR_PIN
    buffer.BIT0(13) = ~IR_PIN
    buffer.BIT0(14) = ~IR_PIN
    buffer.BIT0(15) = ~IR_PIN
    buffer.BIT0(16) = ~IR_PIN
    buffer.BIT0(17) = ~IR_PIN
    buffer.BIT0(18) = ~IR_PIN
    buffer.BIT0(19) = ~IR_PIN
    buffer.BIT0(20) = ~IR_PIN
    buffer.BIT0(21) = ~IR_PIN
    buffer.BIT0(22) = ~IR_PIN
    buffer.BIT0(23) = ~IR_PIN
    buffer.BIT0(24) = ~IR_PIN
    buffer.BIT0(25) = ~IR_PIN
    buffer.BIT0(26) = ~IR_PIN
    buffer.BIT0(27) = ~IR_PIN
    buffer.BIT0(28) = ~IR_PIN
    buffer.BIT0(29) = ~IR_PIN
    buffer.BIT0(30) = ~IR_PIN
    buffer.BIT0(31) = ~IR_PIN
    buffer.BIT0(32) = ~IR_PIN
    buffer.BIT0(33) = ~IR_PIN
    buffer.BIT0(34) = ~IR_PIN
    buffer.BIT0(35) = ~IR_PIN
    buffer.BIT0(36) = ~IR_PIN
    buffer.BIT0(37) = ~IR_PIN
    buffer.BIT0(38) = ~IR_PIN
    buffer.BIT0(39) = ~IR_PIN
    buffer.BIT0(40) = ~IR_PIN
    buffer.BIT0(41) = ~IR_PIN
    buffer.BIT0(42) = ~IR_PIN
    buffer.BIT0(43) = ~IR_PIN
    buffer.BIT0(44) = ~IR_PIN
    buffer.BIT0(45) = ~IR_PIN
    buffer.BIT0(46) = ~IR_PIN
    buffer.BIT0(47) = ~IR_PIN
    buffer.BIT0(48) = ~IR_PIN
    buffer.BIT0(49) = ~IR_PIN
    buffer.BIT0(50) = ~IR_PIN
    buffer.BIT0(51) = ~IR_PIN
    buffer.BIT0(52) = ~IR_PIN
    buffer.BIT0(53) = ~IR_PIN
    buffer.BIT0(54) = ~IR_PIN
    buffer.BIT0(55) = ~IR_PIN
    buffer.BIT0(56) = ~IR_PIN
    buffer.BIT0(57) = ~IR_PIN
    buffer.BIT0(58) = ~IR_PIN
    buffer.BIT0(59) = ~IR_PIN
    buffer.BIT0(60) = ~IR_PIN
    buffer.BIT0(61) = ~IR_PIN
    buffer.BIT0(62) = ~IR_PIN
    buffer.BIT0(63) = ~IR_PIN
    receive = 0
    bitcount = 0
    cutoff CON 3 'length of pulse to count as 1
    FOR x = 1 TO 63
    buffer.BIT0(x) = ~buffer.BIT0(x)
    IF buffer.BIT0(x) <> 0 THEN
    IF buffer.BIT0(x-1) <> 1 THEN
    '0 to 1 transition (end of pulse)
    beats = (beats - cutoff) >> 15
    receive = (receive << 1) | beats
    bitcount = bitcount + 1
    ENDIF
    ELSE
    'pulse... count beats
    IF buffer.BIT0(x-1) <> 0 THEN
    beats = 0
    ENDIF
    beats = beats + 1 'add a beat
    ENDIF
    NEXT
    receive = ~(receive << (16 - bitcount & 15))
    receive = receive >> 6
    IF receive <> copy THEN getcode 'make sure code is received properly
    RETURN
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-01 14:25
    Hello,

    ·· According to your code, you have no commands following the last CASE statement, prior to the ENDSELECT.· You must have·instructions following any CASE statement, or·the command is·incomplete.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 7/1/2005 2:28:39 PM GMT
  • Mike DMike D Posts: 3
    edited 2005-07-01 14:37
    ...Wow I feel so stupid now but what could I do to fix that. (By the way thank you ,everyone, for your help.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-07-01 14:48
    Mike D -

    If it's not going to be used at the moment, and you want to leave the CASE 930 as a placeholder, just add a PAUSE 1 in there or some other harmless command, otherwise just delete it. A null CASE statement has no meaning.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 7/1/2005 2:51:21 PM GMT
Sign In or Register to comment.