Comparing Strings
Jeff_5_
Posts: 36
I am working with a Basic Stamp homework board.
I have declared
String1 VAR Byte(4)
String2 VAR Byte(4)
String3 VAR Byte(4)
String VAR Byte(7)
I have already written a function to read in and store String 1 String 2 and String 3. Now i want to read in String and compare it to String1 String2 and String 3. If string matches String1 or matches String 2 or matches String 3 then do some code.
String is 7 bytes long but i wont want to compare the first 4 bytes to String 1 String 2 and String 3
I tried this but it didn't work
Serin 1,84,[ STR String\7]
i=0
IF( (i<4) AND (String(i)=String1(i)) Then
some code
i=i+1
ELSE IF ( (i<4) AND (String(i)=String2(i)) Then
some code
i=i+1
ELSE IF ( (i<4) AND (String(i)=String3(i)) Then
some code
i=i+1
ENDIF
I have declared
String1 VAR Byte(4)
String2 VAR Byte(4)
String3 VAR Byte(4)
String VAR Byte(7)
I have already written a function to read in and store String 1 String 2 and String 3. Now i want to read in String and compare it to String1 String2 and String 3. If string matches String1 or matches String 2 or matches String 3 then do some code.
String is 7 bytes long but i wont want to compare the first 4 bytes to String 1 String 2 and String 3
I tried this but it didn't work
Serin 1,84,[ STR String\7]
i=0
IF( (i<4) AND (String(i)=String1(i)) Then
some code
i=i+1
ELSE IF ( (i<4) AND (String(i)=String2(i)) Then
some code
i=i+1
ELSE IF ( (i<4) AND (String(i)=String3(i)) Then
some code
i=i+1
ENDIF
Comments
IF (String1(0) = String2(0)) AND (String1(0) = String(0)) THEN They_are_equal
String1(1), String2(3), String3(0), String(6)
IF (String1(1) = String2(3)) AND (String3(0) = String(6)) AND (String1(1) = String3(0)) THEN They_are_equal
http://forums.parallax.com/album.php?albumid=38&attachmentid=79414
http://forums.parallax.com/album.php?albumid=38&attachmentid=79382
Jeff T.