Jump to content

Need help with this loop

Recommended Posts

For $x = 0 To 13
        If GUICtrlRead($InputStatus[$x]) = "Senior" Then
      IniWrite($xfile, "ChildMembers", $xfileSeniorKey & $x + 1, GUICtrlRead($inputname[$x]))
      IniWrite($xfile, "ChildMembers", $xfileSeniorDOB & $x + 1, GUICtrlRead($InputDate[$x]))

Correct me if I'm wrong, but doesn't this loop supposed to write each status field that contain the string "Senior" into the ini file? When I run this code; it picked the last row into the ini only which it ignores the rest. So for example:

Textbox 1 = Senior Name

Textbox 2 = Senior Name

DOB Text 1 = 12/12/1960

DOB Text 2 = 12/12/1950

Status Textbox 1= Senior

Status Textbox 2 = Senior





$xfileSeniorKey and $xfileDOB is only a variables of string to test.

$xfileSeniorKey = "Senior"

$xfileDOB = "Senior_DOB"

So when it writes to ini, it would look something like




Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post

Link to post
Share on other sites


you are not making it easy for anyone to help you. if you take the 5 minutes it takes to post a simple runnable reproducer, you may find your issue very easily, because this one works for me flawlessly:

#include <GUIConstantsEx.au3>
Global $hGUI = GUICreate('Example', 300, 410)
GUICtrlCreateLabel('Name:', 10, 5, 80, 20)
GUICtrlCreateLabel('Date:', 110, 5, 80, 20)
GUICtrlCreateLabel('Type:', 210, 5, 80, 20)
Global $agName[14], $agDate[14], $agType[14]
For $i = 0 To 13
    $agName[$i] = GUICtrlCreateInput('Name#' & ($i + 1), 10, ($i + 1) * 25, 80, 20)
    $agDate[$i] = GUICtrlCreateInput(($i + 1) & '/12/1975', 110, ($i + 1) * 25, 80, 20)
    $agType[$i] = GUICtrlCreateInput('Senior', 210, ($i + 1) * 25, 80, 20)
Global $gSave = GUICtrlCreateButton('Save to Ini', 10, 380, 280, 25)
GUISetState(@SW_SHOW, $hGUI)
While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $gSave
            For $i = 0 To 13
                If GUICtrlRead($agType[$i]) = 'Senior' Then
                    IniWrite('senior.ini', 'ChildMembers', 'Name' & ($i + 1), GUICtrlRead($agName[$i]))
                    IniWrite('senior.ini', 'ChildMembers', 'Date' & ($i + 1), GUICtrlRead($agDate[$i]))


Edited by orbs

Share this post

Link to post
Share on other sites

Exactly my thoughts, kinda hard to get the whole picture without the rest of it.


Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples


Share this post

Link to post
Share on other sites


When using an INI file with incremental keys you need to find the highest key for the starting increment for successive runs.  Otherwise you will be writing over existing values.

If this is a frequently run or a high volume app you might consider SQLite.  It is not much harder than INI files for simple structures.


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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