Jump to content
Sign in to follow this  
BananaFredSoft

IniRead problems

Recommended Posts

BananaFredSoft

This script always reads "Default". I don't know what is wrong with it, because I have checked and everything is right, the sections and keys are named correctly, and the Ini actually exists with the right data...

Any help is greatly appreciated! Sorry for bothering!

Global $lr = ""
Global $lastsentuser = ""
While 1
    $lrbefore = $lr
    $lastsentuser = IniRead($d & ".chat", "Chat", "Last Sent User", "")
    If $lastsentuser not = $uname Then
        $lr = IniRead($d & ".chat", "Chat", "Last Sent-", "default")
    EndIf
    If $lr not = $lrbefore Then
        GUICtrlDelete($LastRecived)
        $LastRecived = GUICtrlCreateLabel($lastsentuser & " says:" & $lr, 8, 36)
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $TextPut
            $LastSent1 = GUICtrlRead($TextPut)
            IniWrite($d & ".chat", "Chat", "Last Sent-", $LastSent1)
            IniWrite($d & ".chat", "Chat", "Last Sent User", $uname)
            GUICtrlDelete($LastSent)
            $LastSent = GUICtrlCreateLabel("Last Sent:" & $LastSent1, 8, 16, 90, 30)
        
        Case $Send
            $LastSent1 = GUICtrlRead($TextPut)
            IniWrite($d & ".chat", "Chat", "Last Sent-", $LastSent1)
            IniWrite($d & ".chat", "Chat", "Last Sent User", $uname)
            GUICtrlDelete($LastSent)
            $LastSent = GUICtrlCreateLabel("Last Sent:" & $LastSent1, 8, 16, 90, 30)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
PsaltyDS

Using 'NOT =' causes problems. Stick with '<>' instead.

This also has two debug displays to insert temporarily to see if you are getting expected values:

While 1
    $lrbefore = $lr
    $lastsentuser = IniRead($d & ".chat", "Chat", "Last Sent User", "")
    MsgBox(64, "Debug", "IniRead " & $d & ".chat" & @CRLF & "[Chat]" & @CRLF & "Last Sent User=" & $lastsentuser)
    If $lastsentuser <> $uname Then
        $lr = IniRead($d & ".chat", "Chat", "Last Sent-", "default")
        MsgBox(64, "Debug", "IniRead " & $d & ".chat" & @CRLF & "[Chat]" & @CRLF & "Last Sent-=" & $lr)
    EndIf
    If $lr <> $lrbefore Then
        GUICtrlDelete($LastRecived)
        $LastRecived = GUICtrlCreateLabel($lastsentuser & " says:" & $lr, 8, 36)
    EndIf

    ;... etc.

WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
BananaFredSoft

Hmmm... I used <> and it still returns the default, but I think I'm getting closer. I'll report back on whether I succeeded later.

Using 'NOT =' causes problems. Stick with '<>' instead.

This also has two debug displays to insert temporarily to see if you are getting expected values:

While 1
    $lrbefore = $lr
    $lastsentuser = IniRead($d & ".chat", "Chat", "Last Sent User", "")
    MsgBox(64, "Debug", "IniRead " & $d & ".chat" & @CRLF & "[Chat]" & @CRLF & "Last Sent User=" & $lastsentuser)
    If $lastsentuser <> $uname Then
        $lr = IniRead($d & ".chat", "Chat", "Last Sent-", "default")
        MsgBox(64, "Debug", "IniRead " & $d & ".chat" & @CRLF & "[Chat]" & @CRLF & "Last Sent-=" & $lr)
    EndIf
    If $lr <> $lrbefore Then
        GUICtrlDelete($LastRecived)
        $LastRecived = GUICtrlCreateLabel($lastsentuser & " says:" & $lr, 8, 36)
    EndIf

    ;... etc.

WEnd

:)

Share this post


Link to post
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
Sign in to follow this  

×