Shop OBEX P1 Docs P2 Docs Learn Events
Comparing two strings — Parallax Forums

Comparing two strings

ryfitzger227ryfitzger227 Posts: 99
edited 2013-12-18 14:44 in BASIC Stamp
I've been doing a lot of work in the propeller and its probably been over a year since I've done anything with the stamp. I'm doing something that should be pretty simple. I'm sending out a string of "A," from my computer via serial port. What I'm wanting the stamp to do is simple - check to see if the input equals "A," and then light an LED.

Here's what I have so far..
serialInput VAR Byte

Main:


SERIN 16, 16780, [STR serialInput\1]


IF serialInput(0) = "A" AND serialInput(1) = "," THEN
' IF serialInput = "A," '-- produces an error


HIGH 15


ENDIF

GOTO Main

This may look stupid, but it's the only thing I could think of! Haha! Any ideas?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-12-17 18:50
    You've got the basic idea although I think the SERIN parameter should be "STR serialInput\2" since you're expecting two characters. I don't have my Stamp Manual handy, so I may be wrong. You do have to do everything a character at a time other than the SERIN. Stamp Basic has no provision for copying or comparing strings as such.
  • stamptrolstamptrol Posts: 1,731
    edited 2013-12-18 07:03
    As Mike points out, there is no real string handling capability.

    But, you may be able to use the "WAIT" modifier of the SERIN command to watch for a string of up to 6 characters. See the Helpfile under SERIN.

    Cheers,
  • ryfitzger227ryfitzger227 Posts: 99
    edited 2013-12-18 13:04
    Mike Green wrote: »
    You've got the basic idea although I think the SERIN parameter should be "STR serialInput\2" since you're expecting two characters. I don't have my Stamp Manual handy, so I may be wrong. You do have to do everything a character at a time other than the SERIN. Stamp Basic has no provision for copying or comparing strings as such.

    I completely overlooked this! It works now. Thank you.
  • davejamesdavejames Posts: 4,047
    edited 2013-12-18 14:44
    I completely overlooked this! It works now. Thank you.

    I've marked your thread as "solved".
Sign In or Register to comment.