Shop OBEX P1 Docs P2 Docs Learn Events
how to add a statment on " " — Parallax Forums

how to add a statment on " "

KARIM102KARIM102 Posts: 75
edited 2012-08-21 07:13 in BASIC Stamp
A var word


DO
SERIN 15 , 84, [WAIT(">"),A] ' Wait to recived SMS

IF A = "Light" THEN
' order to be make
HIGH 0
PAUSE 1000

why i can't use "light" as my commad? only one light is accepted? like "L"
could i use word like "light"???

reg

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2012-08-21 06:20
    What you could do is assign a token to "LIGHT"


    A var word
    
    LIGHT CON 1  ' Note: you can assign any value from 0 to 255 here
    
    DO
         SERIN 15 , 84, [WAIT(">"),A] ' Wait to recived SMS
    
         IF A = LIGHT THEN
              ' order to be make
              HIGH 0
              PAUSE 1000
         ENDIF
    
    LOOP
    
    
    
  • Mike GreenMike Green Posts: 23,101
    edited 2012-08-21 06:43
    The Stamps don't do arithmetic operations on strings (like "Light"). They will do arithmetic operations on single characters (like "L"). It is possible to receive a character string and store it in a byte array using SERIN and the STR formatter. Look at page 404 of the Stamp Manual for a description of this and some simple examples. Once you have a short string in a byte array, you can test each of the characters for some specific word like this:

    A VAR BYTE(6) ' 6 bytes long

    SERIN 15, 84, [WAIT(">"), STR A\6\13] ' A ">" then a 1 to 5 character word, then a carriage return
    IF A(0) = "L" and A(1) = "i" and A(2) = "g" and A(3) = "h" and A(4) = "t" and A(5) = 0 THEN

    The test for the last byte being zero is there because STR fills out the byte array with zeroes.
  • KARIM102KARIM102 Posts: 75
    edited 2012-08-21 07:13
    i got it now thx a lot, by the way u can trak the stamp lol
Sign In or Register to comment.