Jump to content

Iniwrite radio with a button


Recommended Posts

I want to save changed radios after click button. Those instructions doesnt work cuz in ini file there are "1" only - for every first radio of the group. Please help.

There are some fragments of the script:

GUIStartGroup()
$Radio1 = GUICtrlCreateRadio("1", 389, 88, 33, 25)
$Radio2 = GUICtrlCreateRadio("2", 429, 88, 33, 25)
$Radio3 = GUICtrlCreateRadio("3", 469, 88, 33, 25)
$Radio4 = GUICtrlCreateRadio("4", 509, 88, 33, 25)

Case $msg = $Button2
    $file = filesavedialog("Select Settings File", @ScriptDir, "Ini files (*.ini)", 2, "My Settings.ini")

    If not @Error Then

If GUICtrlRead($Radio1) = $GUI_CHECKED Then
    IniWrite($file, "options", $Radio1, 1)
ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
    IniWrite($file, "options", $Radio2, 1)
ElseIf GUICtrlRead($Radio3) = $GUI_CHECKED Then
    IniWrite($file, "options", $Radio3, 1)
ElseIf GUICtrlRead($Radio4) = $GUI_CHECKED Then
    IniWrite($file, "options", $Radio4, 1)
EndIf
EndIf
Edited by m4tius
Link to comment
Share on other sites

You were writing the value "1" for each radio control.

IniWrite($file, "options", $Radio1, 1) is going to write "1"

so is

IniWrite($file, "options", $Radio2, 1). These will both write "1" since that is the "value" you supplied for all of them.

#include <GuiConstantsEx.au3>
GuiCreate('test', 600, 150)
$Button2 = GUICtrlCreateButton("Button2", 0, 0, 100, 20)
GUIStartGroup()
$Radio1 = GUICtrlCreateRadio("1", 389, 88, 33, 25)
$Radio2 = GUICtrlCreateRadio("2", 429, 88, 33, 25)
$Radio3 = GUICtrlCreateRadio("3", 469, 88, 33, 25)
$Radio4 = GUICtrlCreateRadio("4", 509, 88, 33, 25)
GUISetState()


While 1
    Sleep(10)
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $file = FileSaveDialog("Select Settings File", @ScriptDir, "Ini files (*.ini)", 2, "My Settings.ini")
            If Not @error Then
                If GUICtrlRead($Radio1) = $GUI_CHECKED Then
                    IniWrite($file, "options", 'selected', 1)
                ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
                    IniWrite($file, "options", 'selected', 2)
                ElseIf GUICtrlRead($Radio3) = $GUI_CHECKED Then
                    IniWrite($file, "options", 'selected', 3)
                ElseIf GUICtrlRead($Radio4) = $GUI_CHECKED Then
                    IniWrite($file, "options", 'selected', 4)
                Else
                    IniWrite($file, "options", 'selected', 0)
                EndIf
            EndIf
    EndSwitch
WEnd
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...