Sign in to follow this  
Followers 0
Infinitex0

Chat Bot

11 posts in this topic

Hi, I am bored and am making a chat bot. right now it is in it's very very first stage. I want it to respond to a comment when I press enter, but for some reason it doesn't. Any ideas why?

#include <Misc.au3>
HotKeySet("F1", "terminate")


FileOpen("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 1)
While 1
$line1 = FileReadLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 1)
$name = FileReadLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 3)
If $line1 = "Hi I am Jon" And _IsPressed("0D") Then
    Send("Hello Jon")
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "Hello Jon")

ElseIf $line1 = "Hi I'm Jon" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I'm Chat Bot")

ElseIf $line1 = "How you doing Chat bot?" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I'm good")

;ElseIf $line1 = "" Then
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "Hey Jon, Where are you?")  
    
ElseIf $line1 = "hello chat bot, so where are you from?" Then
FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I was written in Georgia")  

ElseIf $line1 = "Goodbye" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "See ya")

ElseIf $line1 = "bye" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "bye")

ElseIf $line1 = "Hi" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hello")

ElseIf $line1 = "hey" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hey")
    
ElseIf $line1 = "yo" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hi")    

ElseIf $line1 = "hello" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hello, who are you")
;_IsPressed("0D")
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", $name & ", I do not have any record of that name in my databade")
EndIf
WEnd

Func terminate()
    Exit 0
    EndFunc

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Buh buh bump buh buh bump buh buh bump bump bump.

Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

Buh buh bump bu bu bump buh buh bump bump bump.

Little Drummerboy?

:)

Sorry, Nyquiled up, can't wrap my head around it at the moment.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Ehh i did like ...

Hotkeyset("{ENTER}" , "Snd")

Func Snd()
  Send("{TAB} {ENTER}")
  GUICtrlSetState($inputbox, $GUIACTIVATE)
EndFunc()

Or something like that i can't really remember

Share this post


Link to post
Share on other sites

Hi, I am bored and am making a chat bot. right now it is in it's very very first stage. I want it to respond to a comment when I press enter, but for some reason it doesn't. Any ideas why?

#include <Misc.au3>
HotKeySet("F1", "terminate")
FileOpen("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 1)
While 1
$line1 = FileReadLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 1)
$name = FileReadLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 3)
If $line1 = "Hi I am Jon" And _IsPressed("0D") Then
    Send("Hello Jon")
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "Hello Jon")

ElseIf $line1 = "Hi I'm Jon" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I'm Chat Bot")

ElseIf $line1 = "How you doing Chat bot?" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I'm good")

;ElseIf $line1 = "" Then
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "Hey Jon, Where are you?")  
    
ElseIf $line1 = "hello chat bot, so where are you from?" Then
FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I was written in Georgia")  

ElseIf $line1 = "Goodbye" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "See ya")

ElseIf $line1 = "bye" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "bye")

ElseIf $line1 = "Hi" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hello")

ElseIf $line1 = "hey" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hey")
    
ElseIf $line1 = "yo" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hi")    

ElseIf $line1 = "hello" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hello, who are you")
;_IsPressed("0D")
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", $name & ", I do not have any record of that name in my databade")
EndIf
WEnd

Func terminate()
    Exit 0
    EndFunc
I see no GUI, but let's see if this is what you want:

#include <Misc.au3>
HotKeySet("F1", "terminate")
FileOpen("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 1)
While 1
$line1 = FileReadLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 1)
$name = FileReadLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", 3)
If $line1 = "Hi I am Jon" And _IsPressed("0D") Then
    Send("Hello Jon")
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "Hello Jon")

ElseIf $line1 = "Hi I'm Jon" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I'm Chat Bot")

ElseIf $line1 = "How you doing Chat bot?" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I'm good")

;ElseIf $line1 = "" Then
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "Hey Jon, Where are you?")  
    
ElseIf $line1 = "hello chat bot, so where are you from?" Then
FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "I was written in Georgia")  

ElseIf $line1 = "Goodbye" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "See ya")

ElseIf $line1 = "bye" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "bye")

ElseIf $line1 = "Hi" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hello")

ElseIf $line1 = "hey" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hey")
    
ElseIf $line1 = "yo" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hi")    

ElseIf $line1 = "hello" Then
    FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", "hello, who are you")
;FileWriteLine("C:\Documents and Settings\Owner\My Documents\Chat Bot.txt", $name & ", I do not have any record of that name in my databade")
EndIf
while Not _IsPressed("0D")
Sleep(250)
wend
WEnd

Func terminate()
    Exit 0
    EndFunc

#)

Share this post


Link to post
Share on other sites

Would probably be better to just put the responses and statements in an .ini file so you can use inireadsection and compare them... that way the code isn't so... well ~~


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Would probably be better to just put the responses and statements in an .ini file so you can use inireadsection and compare them... that way the code isn't so... well ~~

Long-winded, i'd say.

#)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Yeah I think long-winded is a good way to put it. :mellow:

Now not to sound stoopid but how me to make a ini. :)

Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

start > run > notepad

type in

[section1]value1=someval

save as > somefile.ini

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

start > run > notepad

type in

save as > somefile.ini

Yes, using his example... let's set up a test.ini on our desktop. Then you'll put this in and save.

[Phrase_Response]Hello My Name Is John=Hello John, how may we help you today?

I have a headache=Now you sound like your sister :-x!

And using something like this after you parse for what was said, you'd check the ini for adiquet responses (this is really off the top of my head, and probably how I would approach it to begin with... Not saying it's the correct way!)
Local $a_Ini = IniReadSection(@DesktopDir & '\test.ini', 'Phrase_Response')
Local $s_StringFound = "I have a headache"

For $i_Count = 1 To $a_Ini[0][0]
    If StringInStr($a_Ini[$i_Count][0], $s_StringFound) Then
        MsgBox(0, 'Example', 'Phrase Found Was: ' & $a_Ini[$i_Count][0] & @CRLF & _ 
        'Response Is: ' & $a_Ini[$i_Count][1])
        ExitLoop
    EndIf
Next

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Check out here:

http://www.autoitscript.com/forum/index.ph...ndpost&p=131420

for an ini editor.

#)

EDIT: thought i may as well just post the working code here:

REQUIRES BETA.

$file = FileOpenDialog ( "Select INI to edit", "", "Configuration Files (*.ini)" , 8 )
If @error then
 MsgBox(0, "IniEditor", "ERROR: Failed to open file.")
 exit
EndIf
_EditIniDialog($file, "INI Editor")
Switch @error
Case 1
MsgBox(0, "IniEditor", "ERROR: Reading of section names of file failed. (ini may not exist)")
Case 2
MsgBox(0, "IniEditor", "ERROR: Reading of a section failed. (ini does exist)")
Case 3
MsgBox(0, "IniEditor", "ERROR: Copying/Saving/Opening File Failed. (ini does exist)")
EndSwitch
Exit

;===============================================================================
;
; Function Name:    _EditIniDialog()
; Description:    Opens a dialog to edit an INI file.
; Parameter(s):  $iniloc         - Path to the INI file
;                  $EIDtitle       - [optional] Title of the window. Default is "INI Editor"
;                  $DisallowSaveAs - [optional] If set to a non-zero value, it disables the save-as option (saving in
;                                    original location still allowed). (Default = 0)
;                  $DisallowEdit   - [optional] If set to a non-zero value, it disallows clicking any button except
;                                    for the Close button(save-as option still allowed unless previous option sets otherwise). (Default = 0)
; Requirement(s):   AutoIt
; Return Value(s):  Returns 1 if no error
;                  Returns 0 if there is an error
;                  @error = 1 - Unable to read section names of file (ini may not exist)
;                  @error = 2 - There was an error while reading a section (ini does exist)
;                  @error = 3 - Error while copying files (ini does exist)
; Author(s):        Alexander "TechDude" Wood (aka nfwu)   me@techdudeonline.tk
;
;===============================================================================
#include <File.au3>
#include <Misc.au3>
Func _DialogEditIni($iniloc, $EIDtitle = "INI Editor", $DisallowSaveAs = 0, $DisallowEdit = 0)
    If Not IsDeclared('WS_CLIPSIBLINGS') Then Global Const $WS_CLIPSIBLINGS = 0x04000000
    If Not IsDeclared('WS_OVERLAPPEDWINDOW') Then Global Const $WS_OVERLAPPEDWINDOW = 0x00CF0000
    If Not IsDeclared('WS_VISIBLE') Then Global Const $WS_VISIBLE = 0x10000000
;GUI
    Local $EditIniDialog = GUICreate(_Iif ($DisallowEdit == 0, $EIDtitle, $EIDtitle & "(Read-Only)"), 392, 323, (@DesktopWidth - 392) / 2, (@DesktopHeight - 323) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
;Labels
    GUICtrlCreateLabel("Section:", 10, 10, 100, 20)
    GUICtrlCreateLabel("Key/Value Pairs:", 10, 90, 110, 20)
;Section Ctrls
    Local $SectionCombo = GUICtrlCreateCombo("", 10, 30, 370, 21)
    Local $SectionNewButton = GUICtrlCreateButton("New Section", 10, 60, 110, 20)
    Local $SectionDelButton = GUICtrlCreateButton("Delete Section", 140, 60, 110, 20)
    Local $SectionEdiButton = GUICtrlCreateButton("Edit Section", 270, 60, 110, 20)
;Pairs Ctrls
    Local $PairList = GUICtrlCreateList("", 10, 110, 370, 123)
    Local $PairNewButton = GUICtrlCreateButton("New Pair", 10, 240, 110, 20)
    Local $PairDelButton = GUICtrlCreateButton("Delete Pair", 140, 240, 110, 20)
    Local $PairEdiButton = GUICtrlCreateButton("Edit pair", 270, 240, 110, 20)
;Save Buttons
    Local $SaveSavButton = GUICtrlCreateButton("Save", 10, 290, 110, 20)
    Local $SaveSasButton = GUICtrlCreateButton("Save As...", 140, 290, 110, 20)
    Local $SaveCloButton = GUICtrlCreateButton("Close", 270, 290, 110, 20)
;Data
    Local $SectionNames = IniReadSectionNames($iniloc)
    Local $SectionNamesList = ""
    Local $PairData
    Local $PairString = ""
    Local $tempfile = _TempFile ()
    Local $actualini = $iniloc
    If @error Then
        GUISetState(@SW_HIDE, $EditIniDialog)
        SetError(1)
        Return 0
    EndIf
    If Not FileCopy($iniloc, $tempfile) Then
        GUISetState(@SW_HIDE, $EditIniDialog)
        SetError(3)
        Return 0
    EndIf
    $iniloc = $tempfile
    $SectionNamesList = $SectionNames[1]
    For $i = 2 To $SectionNames[0]
        $SectionNamesList = $SectionNamesList & "|" & $SectionNames[$i]
    Next
    GUICtrlSetData($SectionCombo, $SectionNamesList, $SectionNames[1])
    $PairData = _DialogEditIni_Helper($iniloc, $SectionNames[1], $PairString)
    If @error Then Return 0
    GUICtrlSetData($PairList, $PairString)
    GUISetState(@SW_SHOW, $EditIniDialog)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg == $GUI_EVENT_CLOSE
                GUISetState(@SW_HIDE, $EditIniDialog)
                GUIDelete( $EditIniDialog )
                Return 1
            Case $msg == $SaveCloButton
                GUISetState(@SW_HIDE, $EditIniDialog)
                GUIDelete( $EditIniDialog )
                Return 1
            Case $msg == $SectionCombo
                $sec = GUICtrlRead($SectionCombo)
                $PairData = _DialogEditIni_Helper($iniloc, $sec, $PairString)
                If @error Then
                    SetError(2)
                    GUISetState(@SW_HIDE, $EditIniDialog)
                    GUIDelete( $EditIniDialog )
                    Return
                EndIf
                GUICtrlSetData($PairList, "")
                GUICtrlSetData($PairList, $PairString)
            Case Else
                If (Not $DisallowSaveAs) And ($msg == $SaveSasButton) Then
                    $file = FileSaveDialog($EIDtitle & " - Save .ini As...", ".", "Files (*.ini)", 1 + 16 + 2, $actualini)
                    If @error Then
                        MsgBox(262208, $EIDtitle, "Save Cancelled")
                    Else
                        If Not FileCopy($tempfile, $file) Then
                            GUISetState(@SW_HIDE, $EditIniDialog)
                            SetError(3)
                            GUIDelete( $EditIniDialog )
                            Return 0
                        EndIf
                        MsgBox(262208, $EIDtitle, "Ini [" & $file & "] Saved.")
                    EndIf
                ElseIf ($DisallowSaveAs) And ($msg == $SaveSasButton) Then
                    MsgBox(262160, $EIDtitle & " - Error", "The [Save As...] function has been disabled." & @CRLF & "You are not allowed to save the file in a location other than the original.")
                EndIf
                If Not $DisallowEdit Then
                    Select
                        Case $msg == $SaveSavButton
                            If Not FileCopy($tempfile, $actualini) Then
                                GUISetState(@SW_HIDE, $EditIniDialog)
                                SetError(3)
                                GUIDelete( $EditIniDialog )
                                Return 0
                            EndIf
                            MsgBox(262208, $EIDtitle, "Ini [" & $iniloc & "] Saved.")
                            SetError(0)
                            GUIDelete( $EditIniDialog )
                            Return 1
                        Case $msg == $SectionDelButton
                            $sec = GUICtrlRead($SectionCombo)
                            $iMsgBoxAnswer = MsgBox(262436, $EIDtitle, "Are you sure you want to delete the [Section]: " & $sec & "?")
                            Select
                                Case $iMsgBoxAnswer = 6;Yes
                                    IniDelete($iniloc, $sec)
                                    _DialogEditIni_Helper4($iniloc, $SectionNames, $SectionNamesList)
                                    GUICtrlSetData($SectionCombo, "")
                                    GUICtrlSetData($SectionCombo, $SectionNamesList, $SectionNames[1])
                                    $PairData = _DialogEditIni_Helper($iniloc, $SectionNames[1], $PairString)
                                    If @error Then
                                        SetError(2)
                                        GUISetState(@SW_HIDE, $EditIniDialog)
                                        GUIDelete( $EditIniDialog )
                                        Return 0
                                    EndIf
                                    GUICtrlSetData($PairList, "")
                                    GUICtrlSetData($PairList, $PairString)
                                Case $iMsgBoxAnswer = 7;No
                            EndSelect
                        Case $msg == $SectionNewButton
                            $sec = InputBox($EIDtitle, "Please enter the name of the new [Section]:")
                            IniWrite($iniloc, $sec, "DeleteMe", "TempValue")
                            _DialogEditIni_Helper4($iniloc, $SectionNames, $SectionNamesList)
                            GUICtrlSetData($SectionCombo, "")
                            GUICtrlSetData($SectionCombo, $SectionNamesList, $sec)
                            $PairData = _DialogEditIni_Helper($iniloc, $sec, $PairString)
                            If @error Then
                                SetError(2)
                                GUISetState(@SW_HIDE, $EditIniDialog)
                                GUIDelete( $EditIniDialog )
                                Return 0
                            EndIf
                            GUICtrlSetData($PairList, "")
                            GUICtrlSetData($PairList, $PairString)
                        Case $msg == $SectionEdiButton
                            $sec = GUICtrlRead($SectionCombo)
                            $sec2 = InputBox($EIDtitle, "Please enter the new name of the [Section]" & $sec & ":", $sec)
                            IniRenameSection ($iniloc, $sec, $sec2)
                            _DialogEditIni_Helper4($iniloc, $SectionNames, $SectionNamesList)
                            GUICtrlSetData($SectionCombo, "")
                            GUICtrlSetData($SectionCombo, $SectionNamesList, $sec2)
                            $PairData = _DialogEditIni_Helper($iniloc, $sec2, $PairString)
                            If @error Then
                                SetError(2)
                                GUISetState(@SW_HIDE, $EditIniDialog)
                                GUIDelete( $EditIniDialog )
                                Return 0
                            EndIf
                            GUICtrlSetData($PairList, "")
                            GUICtrlSetData($PairList, $PairString)
                        Case $msg == $PairNewButton
                            $sec = GUICtrlRead($SectionCombo)
                            $key = InputBox($EIDtitle, "Please enter the [Key] of the new [Pair]:")
                            $pair = InputBox($EIDtitle, "Please enter the [Value] of the new [Pair]:")
                            IniWrite($iniloc, $sec, $key, $pair)
                            _DialogEditIni_Helper4($iniloc, $SectionNames, $SectionNamesList)
                            GUICtrlSetData($SectionCombo, "")
                            GUICtrlSetData($SectionCombo, $SectionNamesList, $sec)
                            $PairData = _DialogEditIni_Helper($iniloc, $sec, $PairString)
                            If @error Then
                                GUISetState(@SW_HIDE, $EditIniDialog)
                                SetError(2)
                                GUIDelete( $EditIniDialog )
                                Return 0
                            EndIf
                            GUICtrlSetData($PairList, "")
                            GUICtrlSetData($PairList, $PairString)
                        Case $msg == $PairDelButton
                            $sec = GUICtrlRead($SectionCombo)
                            $pair = _DialogEditIni_Helper3($PairList, $PairData)
                            IniDelete($iniloc, $sec, $PairData[$pair][0])
                            $PairData = _DialogEditIni_Helper($iniloc, $sec, $PairString)
                            If @error Then
                                GUISetState(@SW_HIDE, $EditIniDialog)
                                MsgBox(262192 + 64, $EIDtitle, "NOTE: If you tried to delete the last value in a section, do not do so." & @CRLF & "It will not work. Instead, delete the section." & @CRLF & "@ERROR = 2")
                                SetError(2)
                                GUIDelete( $EditIniDialog )
                                Return 0
                            EndIf
                            GUICtrlSetData($PairList, "")
                            GUICtrlSetData($PairList, $PairString)
                        Case $msg == $PairEdiButton
                            $sec = GUICtrlRead($SectionCombo)
                            $pair = _DialogEditIni_Helper3($PairList, $PairData)
                            IniDelete($iniloc, $sec, $PairData[$pair][0])
                            $key = InputBox($EIDtitle, "Please enter the new [Key] of the [Pair]:", $PairData[$pair][0])
                            $value5 = InputBox($EIDtitle, "Please enter the new [Value] of the [Pair]:", $PairData[$pair][1])
                            IniWrite($iniloc, $sec, $key, $value5)
                            _DialogEditIni_Helper4($iniloc, $SectionNames, $SectionNamesList)
                            GUICtrlSetData($SectionCombo, "")
                            GUICtrlSetData($SectionCombo, $SectionNamesList, $sec)
                            $PairData = _DialogEditIni_Helper($iniloc, $sec, $PairString)
                            If @error Then
                                GUISetState(@SW_HIDE, $EditIniDialog)
                                SetError(2)
                                GUIDelete( $EditIniDialog )
                                Return 0
                            EndIf
                            GUICtrlSetData($PairList, "")
                            GUICtrlSetData($PairList, $PairString)
                    EndSelect
                ElseIf $msg == $SectionDelButton Or $msg == $SectionDelButton Or _
                        $msg == $SectionEdiButton Or $msg == $PairNewButton Or _
                        $msg == $PairDelButton Or $msg == $PairEdiButton Or $msg == $SaveSavButton
                    MsgBox(262160, $EIDtitle & " - Error", "You are in (Read-Only) Mode." & @CRLF & "You are not allowed to edit the data")
                EndIf
        EndSelect
    WEnd
    GUIDelete( $EditIniDialog )
EndFunc ;==>_DialogEditIni
Func _DialogEditIni_Helper($file, $sec, ByRef $string)
    Local $data = IniReadSection($file, $sec)
    If @error == 2 Then
        SetError(0)
        Return ""
    ElseIf @error == 1 Then
        SetError(2)
        $string = "Error : Code 2|File:" & $file & "|Section:" & $sec
        Return 0
    EndIf
    $string = _DialogEditIni_Helper2($data[1][0], $data[1][1])
    For $i = 2 To $data[0][0]
        $string = $string & "|" & _DialogEditIni_Helper2($data[$i][0], $data[$i][1])
    Next
    Return $data
EndFunc ;==>_DialogEditIni_Helper
Func _DialogEditIni_Helper2($v1, $v2)
    Return $v1 & " - " & $v2
EndFunc ;==>_DialogEditIni_Helper2
Func _DialogEditIni_Helper3($PairList, $PairData)
    $pairval = GUICtrlRead($PairList)
    For $i = 1 To $PairData[0][0]
        If $pairval == _DialogEditIni_Helper2($PairData[$i][0], $PairData[$i][1]) Then
            Return $i
        EndIf
    Next
EndFunc ;==>_DialogEditIni_Helper3
Func _DialogEditIni_Helper4($iniloc, ByRef $SectionNames, ByRef $SectionNamesList)
    $SectionNames = IniReadSectionNames($iniloc)
    $SectionNamesList = $SectionNames[1]
    For $i = 2 To $SectionNames[0]
        $SectionNamesList = $SectionNamesList & "|" & $SectionNames[$i]
    Next
EndFunc ;==>_DialogEditIni_Helper4
Edited by nfwu

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  
Followers 0