XGamerGuide Posted May 5, 2021 Share Posted May 5, 2021 (edited) Hey, I have a problem with a comparison. I don't understand why two equal values result in False. I have some experience as a programmer but it doesn't make sense. MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content) I am sending my whole function here: Func listRemove($id, $gid, $content) ; listRemove ( ID , GUICtrl ID , Content ) ; Removes something from a list. Returns 0 if the operation was successful. Returns 1 if the ID is invalid. Returns 2 if nothing is selected. Returns 3 if the object was not found. Requires listGet(). If FileExists(@TempDir & "\autoit_lists\" & $id) Then If $content = "" Then Return(2) EndIf Local $i = 0 Local $end = "" Local $jz = "" Local $err = True While $i < listGet($id, 0) $i += 1 $jz = listGet($id, $i) If $jz = $content Then $err = False Else $end &= $jz & @CRLF MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content) EndIf WEnd If $err Then Return(3) Else FileDelete(@TempDir & "\autoit_lists\" & $id) FileWrite(@TempDir & "\autoit_lists\" & $id, $end) Return(0) EndIf Return($end) Else Return(1) EndIf EndFunc Edt: I run the function with the following values: listRemove($list, $List1, GUICtrlRead($Input2)) Whatever is in $Input2 it doesn't work. Edited May 5, 2021 by XGamerGuide Link to comment Share on other sites More sharing options...
Trong Posted May 5, 2021 Share Posted May 5, 2021 try MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz == $content) Regards, Link to comment Share on other sites More sharing options...
Earthshine Posted May 5, 2021 Share Posted May 5, 2021 (edited) Use == vip beat me to it Edited May 5, 2021 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
XGamerGuide Posted May 5, 2021 Author Share Posted May 5, 2021 It still does not work Link to comment Share on other sites More sharing options...
Trong Posted May 5, 2021 Share Posted May 5, 2021 DEBUG: Local $jz = 'zzz' Local $content = 'zzz' MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content ) MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content ? 'TRUE' : @CRLF & '$jz(' & StringLen($jz) & ')=' & Binary($jz) & @CRLF & '$content(' & StringLen($content) & ')=' & Binary($content) & ' ') Regards, Link to comment Share on other sites More sharing options...
ajag Posted May 5, 2021 Share Posted May 5, 2021 $jz = "zzz" $content = "zzz" MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content) $jz = "zzz" & @CRLF $content = "zzz" MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content) try and see... Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
jchd Posted May 5, 2021 Share Posted May 5, 2021 If $jz = $content Then $err = False Else $end &= $jz & @CRLF MsgBox(0, "'" & $jz & "' '" & $content & "'", $jz = $content) EndIf The boolean result of the comparison is made inside the Else branch of If $jz = $content Then, so when you get there you can be sure that $jz <> $content. I wonder why you expect something else than False. It's enough for one of the string to contain a ZWJ (Zero Width Joiner) or a ZWSP (Zero Width SPace) or any Unicode codepoint which doesn't represent as a glyph, and strings display identically but are actually distinct. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JockoDundee Posted May 5, 2021 Share Posted May 5, 2021 Where’s the function listget()? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
XGamerGuide Posted May 12, 2021 Author Share Posted May 12, 2021 Quote Where’s the function listget()? Func listGet($id, $value) ; listGet ( ID , value ) ; Reads a specific list. If the list is empty, 0 is returned. Use value 0 to get the length of the list or another number to read out a certain value. Returns 1 if the ID is invalid. You can also read lists from other scripts. If Not FileExists(@TempDir & "\autoit_lists\" & $id) Then Return(1) EndIf Local $array = StringSplit(FileRead(@TempDir & "\autoit_lists\" & $id), @CR) If IsArray($array) Then Return($array[$value]) Else Return(0) EndIf EndFunc Quote try and see... Thanks that helped Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now