Jump to content

If query doesn't work


Recommended Posts

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)

image.png.8a43acb33c73c9cb9e8a9db87cbfc28f.png

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 by XGamerGuide
Link to comment
Share on other sites

$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

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 here
RegExp tutorial: enough to get started
PCRE 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...