Quick Question: Comparing Strings in PBASIC
hottnikks36
Posts: 8
Hey friendly people.. just a quick question,
I got two byte arrays, each containing some ASCII values (thus some characters), with 0 in the last array index.
Is there a quicker way to compare the two strings then doing
If ((arrayA[noparse][[/noparse]0] = arrayB[noparse][[/noparse]0]) AND (arrayA = arrayB) AND.. etc etc) THEN
'do something
ELSE
'do something else
?
Thanks for your help..
I got two byte arrays, each containing some ASCII values (thus some characters), with 0 in the last array index.
Is there a quicker way to compare the two strings then doing
If ((arrayA[noparse][[/noparse]0] = arrayB[noparse][[/noparse]0]) AND (arrayA = arrayB) AND.. etc etc) THEN
'do something
ELSE
'do something else
?
Thanks for your help..
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
i = 0
doItAgain:
if arrayA<>arrayB then noMatch
if arrayA = 0 then allMatched
i = i + 1
goto doItAgain
noMatch: ' mismatch at character position i
allMatched: ' arrayA and arrayB are equal and the same length
How about a loop like:
i = 0
doItAgain:
if arrayA{i}<>arrayB{i} then noMatch
if arrayA{i} = 0 then allMatched
i = i + 1
goto doItAgain
noMatch: ' mismatch at character position i
allMatched: ' arrayA and arrayB are equal and the same length