New topic: Problems comparing strings
<http://forums.realsoftware.com/viewtopic.php?t=46930> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message DanSandbergUCONN Post subject: Problems comparing stringsPosted: Wed Feb 13, 2013 9:38 am Joined: Fri Dec 21, 2007 9:50 am Posts: 218 Hi All - I seem to always have problems with strcomp(a, b, 1)=0 versus a=b. Sometimes one works and the other doesn't and vice versa. My solution has been to introduce the following global function, myStrSame:dim retval as boolean = false if StrComp(stringA, stringB, 0)=0 then retval= true if strcomp(stringa,stringb,1)=0 then retval= true if stringa=stringb then retval=true return retval This has worked in my program until now. I am looking for an element inside of a string array that is equal to the string "Stop". To debug the problem I am using the following code: if mystrsame(PositionsLong(i,j+2),"Stop") then //DO SOME STUFF else MsgBox "Couldn't find the Stop part because PositionsLong(i,j+2) = "+PositionsLong(i,j+2) end if I run the program and eventually get a message box saying "Couldn't find the Stop part because PositionsLong(i,j+2)=Stop" I feel like I'm going insane. Is this a documented compiler error (I'm running an old version, 2007R4) or is there something particular about the word "Stop" that affects the comparison? Have I made a mistake somewhere? Any insight would be greatly appreciated. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
