Jump to content

Need help with this loop


Queener
 Share

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]))
      EndIf
      Next

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

 

Outputs

[ChildMembers]
Senior2=Test
Senior_DOB2=Test

 

$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

[ChildMembers]

Senior1=Test

Senior_DOB=12/12/1960

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.")
Link to comment
Share on other sites

@Queener,

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)
GUISetBkColor(0xABCDEF)
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)
Next
Global $gSave = GUICtrlCreateButton('Save to Ini', 10, 380, 280, 25)
GUISetState(@SW_SHOW, $hGUI)
While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $gSave
            FileDelete('senior.ini')
            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]))
                EndIf
            Next
    EndSwitch
WEnd
GUIDelete($hGUI)

 

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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

Spoiler

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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

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.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

Au3Record.exe

Link to comment
Share on other sites

Queener,

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.

kylomas

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

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...