Jump to content

IniRead and IniWrite


bvr
 Share

Recommended Posts

I'm having problems getting this to work. I want to press save and save the whole file so I can bring it up later in the program. Right now I'm just trying to get it to save, I'll worry about the loading later.

Also when I close out of this secondary GUI and go back to the main one, I cannot press the "Add Job" button again to open up the secondary. 

Func Add_Job ()
   #include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\brandon\documents\koda_1.7.3.0\forms\add_job.kxf
$Form2 = GUICreate("Add Job", 615, 578, 232, 131)
$sIniFile = @ScriptDir & "\Storage.ini"
$Group1 = GUICtrlCreateGroup("Job Information", 8, 8, 601, 561)
$Label1 = GUICtrlCreateLabel("Date:", 32, 40, 30, 17)
$Date1 = GUICtrlCreateDate("2013/08/25 01:14:40", 64, 40, 186, 21)
$Label2 = GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
$Input1 = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
$Combo1 = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo1 = GUICtrlSetData(-1, "am") 
$Label3 = GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
$Input2 = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
$Combo2 = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlSetData(-1, "am") 
$Label4 = GUICtrlCreateLabel("First Name:", 40, 136, 57, 17)
$Input3 = GUICtrlCreateInput("First Name", 112, 136, 121, 21)
$Label5 = GUICtrlCreateLabel("Last Name:", 40, 168, 58, 17)
$Input4 = GUICtrlCreateInput("", 112, 168, 121, 21)
$Label6 = GUICtrlCreateLabel("Address:", 40, 200, 45, 17)
GUICtrlCreateInput("", 96, 200, 129, 21)
$Label7 = GUICtrlCreateLabel("City:", 240, 200, 24, 17)
$Input5 = GUICtrlCreateInput("", 280, 200, 153, 21)
$Label8 = GUICtrlCreateLabel("State:", 40, 232, 32, 17)
$Input6 = GUICtrlCreateInput("", 72, 232, 121, 21)
$Label9 = GUICtrlCreateLabel("Phone Number:", 40, 264, 78, 17)
$Input7 = GUICtrlCreateInput("", 280, 232, 105, 21)
$Label10 = GUICtrlCreateLabel("-", 176, 264, 7, 17)
$Input8 = GUICtrlCreateInput("", 120, 264, 41, 21)
$Label11 = GUICtrlCreateLabel("-", 248, 264, 7, 17)
$Input9 = GUICtrlCreateInput("", 192, 264, 41, 21)
$Label12 = GUICtrlCreateLabel("Email:", 40, 296, 32, 17)
$Input10 = GUICtrlCreateInput("", 264, 264, 41, 21)
$Label13 = GUICtrlCreateLabel("Money Made:", 40, 328, 69, 17)
$Lable14 = GUICtrlCreateLabel("Notes:", 40, 360, 35, 17)
$Label14 = GUICtrlCreateLabel("Zip:", 240, 232, 22, 17)
$Input11 = GUICtrlCreateInput("", 80, 296, 153, 21)
$Combo3 = GUICtrlCreateCombo("$5", 120, 328, 57, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlSetData(-1, "$10 | $15 | $20 | $25 | $30 | $35 | $40 | $45 | $50 | $60 | $65 | $70 | $75 | $80 | $85 | $90 | $95 | $100") 
$Edit1 = GUICtrlCreateEdit("", 24, 384, 577, 137)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Save", 24, 536, 75, 25)
$Button2 = GUICtrlCreateButton("Cancel", 112, 536, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
GUIDelete ( $Form2 )
Return
Case $Button1
IniWrite($sIniFile, "Add Job", "First Name" GUICtrlRead($Input3))
 
 
 
 
EndSwitch
WEnd
EndFunc
Link to comment
Share on other sites

  • Moderators

bvr,

And how useful do you think that function code will be given that the problem only appears after you have closed that GUI? You will need to post more code than that if you want help. Better still, reduce the code to create a small reproducer scrip to illustrate the problem - you often find the answer yourself at that point. ;)

But I would hazard a guess that you have a control in the main GUI ($Button1/2 perhaps?) whose ControlID is stored in a variable using the same name as one in the secondary - which you will have overwritten when creating the secondary and so which no longer refers to the same control once the secondary has been deleted. But that is just a guess - until we see more code we are just whistling in the dark. :whistle:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

; Author: Brandon M. Royer
; Program: Lawn Mowing Manager
; Date: 8/1/2013
;  Updated GUI 8/25/2013
;    Updated GUI, and added some functions 8/26/2013
 
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\brandon\documents\koda_1.7.3.0\forms\ylawncare.kxf
$Form1 = GUICreate("Yesterday's Lawn Care", 615, 410, 192, 124)
$sIniFile = @ScriptDir & "\Storage.ini"
$MenuItem2 = GUICtrlCreateMenu("&File")
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem3 = GUICtrlCreateMenu("&Help")
$Tab1 = GUICtrlCreateTab(8, 8, 601, 377)
$TabSheet1 = GUICtrlCreateTabItem("Job Manager")
$Group1 = GUICtrlCreateGroup("Jobs", 16, 40, 585, 329)
$List1 = GUICtrlCreateList("", 24, 64, 537, 253)
$Button1 = GUICtrlCreateButton("Add", 24, 336, 75, 25)
$Button2 = GUICtrlCreateButton("Edit", 112, 336, 75, 25)
$Button3 = GUICtrlCreateButton("Remove", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("Equipment Manager")
$Group2 = GUICtrlCreateGroup("Equipment", 16, 40, 585, 329)
$List2 = GUICtrlCreateList("", 24, 64, 537, 253)
$Button4 = GUICtrlCreateButton("Add Unit", 24, 336, 75, 25)
$Button5 = GUICtrlCreateButton("Edit Unit", 112, 336, 75, 25)
$Button6 = GUICtrlCreateButton("Remove Unit", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("Stastistics/Money")
$Group3 = GUICtrlCreateGroup("Stastistics", 16, 48, 569, 329)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button7 = GUICtrlCreateButton("Add Expense", 24, 344, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $Button1
Add_Job()
 
Case $GUI_EVENT_CLOSE
Exit
 
EndSwitch
WEnd
 
Func Add_Job ()
   #include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\brandon\documents\koda_1.7.3.0\forms\add_job.kxf
$Form2 = GUICreate("Add Job", 615, 578, 232, 131)
$sIniFile = @ScriptDir & "\Storage.ini"
$Group1 = GUICtrlCreateGroup("Job Information", 8, 8, 601, 561)
$Label1 = GUICtrlCreateLabel("Date:", 32, 40, 30, 17)
$Date1 = GUICtrlCreateDate("2013/08/25 01:14:40", 64, 40, 186, 21)
$Label2 = GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
$Input1 = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
$Combo1 = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo1 = GUICtrlSetData(-1, "am") 
$Label3 = GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
$Input2 = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
$Combo2 = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlSetData(-1, "am") 
$Label4 = GUICtrlCreateLabel("First Name:", 40, 136, 57, 17)
$Input3 = GUICtrlCreateInput("First Name", 112, 136, 121, 21)
$Label5 = GUICtrlCreateLabel("Last Name:", 40, 168, 58, 17)
$Input4 = GUICtrlCreateInput("", 112, 168, 121, 21)
$Label6 = GUICtrlCreateLabel("Address:", 40, 200, 45, 17)
GUICtrlCreateInput("", 96, 200, 129, 21)
$Label7 = GUICtrlCreateLabel("City:", 240, 200, 24, 17)
$Input5 = GUICtrlCreateInput("", 280, 200, 153, 21)
$Label8 = GUICtrlCreateLabel("State:", 40, 232, 32, 17)
$Input6 = GUICtrlCreateInput("", 72, 232, 121, 21)
$Label9 = GUICtrlCreateLabel("Phone Number:", 40, 264, 78, 17)
$Input7 = GUICtrlCreateInput("", 280, 232, 105, 21)
$Label10 = GUICtrlCreateLabel("-", 176, 264, 7, 17)
$Input8 = GUICtrlCreateInput("", 120, 264, 41, 21)
$Label11 = GUICtrlCreateLabel("-", 248, 264, 7, 17)
$Input9 = GUICtrlCreateInput("", 192, 264, 41, 21)
$Label12 = GUICtrlCreateLabel("Email:", 40, 296, 32, 17)
$Input10 = GUICtrlCreateInput("", 264, 264, 41, 21)
$Label13 = GUICtrlCreateLabel("Money Made:", 40, 328, 69, 17)
$Lable14 = GUICtrlCreateLabel("Notes:", 40, 360, 35, 17)
$Label14 = GUICtrlCreateLabel("Zip:", 240, 232, 22, 17)
$Input11 = GUICtrlCreateInput("", 80, 296, 153, 21)
$Combo3 = GUICtrlCreateCombo("$5", 120, 328, 57, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlSetData(-1, "$10 | $15 | $20 | $25 | $30 | $35 | $40 | $45 | $50 | $60 | $65 | $70 | $75 | $80 | $85 | $90 | $95 | $100") 
$Edit1 = GUICtrlCreateEdit("", 24, 384, 577, 137)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Save", 24, 536, 75, 25)
$Button2 = GUICtrlCreateButton("Cancel", 112, 536, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
GUIDelete ( $Form2 )
Return
Case $Button1
IniWrite($sIniFile, "Add Job", "First Name" GUICtrlRead($Input3))
 
 
 
 
EndSwitch
WEnd
EndFunc
Link to comment
Share on other sites

  • Moderators

bvr,

The crystal ball is working well today! Take a look at the <<<<<<<<<<< lines: :D

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

$Form1 = GUICreate("Yesterday's Lawn Care", 615, 410, 192, 124)
$sIniFile = @ScriptDir & "\Storage.ini"
$MenuItem2 = GUICtrlCreateMenu("&File")
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem3 = GUICtrlCreateMenu("&Help")
$Tab1 = GUICtrlCreateTab(8, 8, 601, 377)
$TabSheet1 = GUICtrlCreateTabItem("Job Manager")
$Group1 = GUICtrlCreateGroup("Jobs", 16, 40, 585, 329)
$List1 = GUICtrlCreateList("", 24, 64, 537, 253)
$Button1 = GUICtrlCreateButton("Add", 24, 336, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MsgBox($MB_SYSTEMMODAL, "ControlID",  "On creating main GUI:" & @CRLF & "$Button1 = " & $Button1) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button2 = GUICtrlCreateButton("Edit", 112, 336, 75, 25)
$Button3 = GUICtrlCreateButton("Remove", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("Equipment Manager")
$Group2 = GUICtrlCreateGroup("Equipment", 16, 40, 585, 329)
$List2 = GUICtrlCreateList("", 24, 64, 537, 253)
$Button4 = GUICtrlCreateButton("Add Unit", 24, 336, 75, 25)
$Button5 = GUICtrlCreateButton("Edit Unit", 112, 336, 75, 25)
$Button6 = GUICtrlCreateButton("Remove Unit", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("Stastistics/Money")
$Group3 = GUICtrlCreateGroup("Stastistics", 16, 48, 569, 329)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button7 = GUICtrlCreateButton("Add Expense", 24, 344, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            Add_Job()
            MsgBox($MB_SYSTEMMODAL, "ControlID",  "On returning to main GUI:" & @CRLF & "$Button1 = " & $Button1) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func Add_Job()
    $Form2 = GUICreate("Add Job", 615, 578, 232, 131)
    $sIniFile = @ScriptDir & "\Storage.ini"
    $Group1 = GUICtrlCreateGroup("Job Information", 8, 8, 601, 561)
    $Label1 = GUICtrlCreateLabel("Date:", 32, 40, 30, 17)
    $Date1 = GUICtrlCreateDate("2013/08/25 01:14:40", 64, 40, 186, 21)
    $Label2 = GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
    $Input1 = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
    $Combo1 = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo1 = GUICtrlSetData(-1, "am")
    $Label3 = GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
    $Input2 = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
    $Combo2 = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo2 = GUICtrlSetData(-1, "am")
    $Label4 = GUICtrlCreateLabel("First Name:", 40, 136, 57, 17)
    $Input3 = GUICtrlCreateInput("First Name", 112, 136, 121, 21)
    $Label5 = GUICtrlCreateLabel("Last Name:", 40, 168, 58, 17)
    $Input4 = GUICtrlCreateInput("", 112, 168, 121, 21)
    $Label6 = GUICtrlCreateLabel("Address:", 40, 200, 45, 17)
    GUICtrlCreateInput("", 96, 200, 129, 21)
    $Label7 = GUICtrlCreateLabel("City:", 240, 200, 24, 17)
    $Input5 = GUICtrlCreateInput("", 280, 200, 153, 21)
    $Label8 = GUICtrlCreateLabel("State:", 40, 232, 32, 17)
    $Input6 = GUICtrlCreateInput("", 72, 232, 121, 21)
    $Label9 = GUICtrlCreateLabel("Phone Number:", 40, 264, 78, 17)
    $Input7 = GUICtrlCreateInput("", 280, 232, 105, 21)
    $Label10 = GUICtrlCreateLabel("-", 176, 264, 7, 17)
    $Input8 = GUICtrlCreateInput("", 120, 264, 41, 21)
    $Label11 = GUICtrlCreateLabel("-", 248, 264, 7, 17)
    $Input9 = GUICtrlCreateInput("", 192, 264, 41, 21)
    $Label12 = GUICtrlCreateLabel("Email:", 40, 296, 32, 17)
    $Input10 = GUICtrlCreateInput("", 264, 264, 41, 21)
    $Label13 = GUICtrlCreateLabel("Money Made:", 40, 328, 69, 17)
    $Lable14 = GUICtrlCreateLabel("Notes:", 40, 360, 35, 17)
    $Label14 = GUICtrlCreateLabel("Zip:", 240, 232, 22, 17)
    $Input11 = GUICtrlCreateInput("", 80, 296, 153, 21)
    $Combo3 = GUICtrlCreateCombo("$5", 120, 328, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo3 = GUICtrlSetData(-1, "$10 | $15 | $20 | $25 | $30 | $35 | $40 | $45 | $50 | $60 | $65 | $70 | $75 | $80 | $85 | $90 | $95 | $100")
    $Edit1 = GUICtrlCreateEdit("", 24, 384, 577, 137)
    GUICtrlSetData(-1, "Edit1")
    $Button1 = GUICtrlCreateButton("Save", 24, 536, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    MsgBox($MB_SYSTEMMODAL, "ControlID",  "On creating secondary GUI:" & @CRLF & "$Button1 = " & $Button1) ; ~~~~~~~~~~~~~~~~~~~~~~~
    $Button2 = GUICtrlCreateButton("Cancel", 112, 536, 75, 25)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button2
                GUIDelete($Form2)
                Return
            Case $Button1
                ;IniWrite($sIniFile, "Add Job", "First Name" GUICtrlRead($Input3))
        EndSwitch
    WEnd
EndFunc   ;==>Add_Job
I added some MsgBoxes (~~~~~~~~~~~~~ lines) so that you can see what is happening. ;)

So I suggest you rename all the variables that contain ControlIDs for the secondary GUI so that you do not reuse the same names. Please ask if you have any further questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Renamed all the first Vars with "Main" in front of it to specify it is the Main GUI. I keep getting errors with the save function for the .ini Write, this piece of code.

IniWrite($sIniFile, "Add Job", "Add Job" GUICtrlRead($Input3))

 
Where I have the second "Add Job" is the problem. I'm not sure what is suppose to go there. Here is the updated code.
 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
 
$Form1 = GUICreate("Yesterday's Lawn Care", 615, 410, 192, 124)
$sIniFile = @ScriptDir & "\Storage.ini"
$MenuItem_File = GUICtrlCreateMenu("&File")
$MenuItem_Edit = GUICtrlCreateMenu("&Edit")
$MenuItem_Help = GUICtrlCreateMenu("&Help")
$Main_Tab1 = GUICtrlCreateTab(8, 8, 601, 377)
$Main_TabSheet1 = GUICtrlCreateTabItem("Job Manager")
$Main_Group1 = GUICtrlCreateGroup("Jobs", 16, 40, 585, 329)
$Main_List1 = GUICtrlCreateList("", 24, 64, 537, 253)
$Main_Button1 = GUICtrlCreateButton("Add", 24, 336, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
MsgBox($MB_SYSTEMMODAL, "ControlID",  "On creating main GUI:" & @CRLF & "$Button1 = " & $Main_Button1) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Main_Button2 = GUICtrlCreateButton("Edit", 112, 336, 75, 25)
$Main_Button3 = GUICtrlCreateButton("Remove", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_TabSheet2 = GUICtrlCreateTabItem("Equipment Manager")
$Main_Group2 = GUICtrlCreateGroup("Equipment", 16, 40, 585, 329)
$Main_List2 = GUICtrlCreateList("", 24, 64, 537, 253)
$Main_Button4 = GUICtrlCreateButton("Add Unit", 24, 336, 75, 25)
$Main_Button5 = GUICtrlCreateButton("Edit Unit", 112, 336, 75, 25)
$Main_Button6 = GUICtrlCreateButton("Remove Unit", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_TabSheet3 = GUICtrlCreateTabItem("Stastistics/Money")
$Main_Group3 = GUICtrlCreateGroup("Stastistics", 16, 48, 569, 329)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_Button7 = GUICtrlCreateButton("Add Expense", 24, 344, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Main_Button1
            Add_Job()
            MsgBox($MB_SYSTEMMODAL, "ControlID",  "On returning to main GUI:" & @CRLF & "$Button1 = " & $Button1) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Case $GUI_EVENT_CLOSE
            Exit
 
    EndSwitch
WEnd
 
Func Add_Job()
    $Form2 = GUICreate("Add Job", 615, 578, 232, 131)
    $sIniFile = @ScriptDir & "\Storage.ini"
    $Group1 = GUICtrlCreateGroup("Job Information", 8, 8, 601, 561)
    $Label1 = GUICtrlCreateLabel("Date:", 32, 40, 30, 17)
    $Date1 = GUICtrlCreateDate("2013/08/25 01:14:40", 64, 40, 186, 21)
    $Label2 = GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
    $Input1 = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
    $Combo1 = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo1 = GUICtrlSetData(-1, "am")
    $Label3 = GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
    $Input2 = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
    $Combo2 = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo2 = GUICtrlSetData(-1, "am")
    $Label4 = GUICtrlCreateLabel("First Name:", 40, 136, 57, 17)
    $Input3 = GUICtrlCreateInput("First Name", 112, 136, 121, 21)
    $Label5 = GUICtrlCreateLabel("Last Name:", 40, 168, 58, 17)
    $Input4 = GUICtrlCreateInput("", 112, 168, 121, 21)
    $Label6 = GUICtrlCreateLabel("Address:", 40, 200, 45, 17)
    GUICtrlCreateInput("", 96, 200, 129, 21)
    $Label7 = GUICtrlCreateLabel("City:", 240, 200, 24, 17)
    $Input5 = GUICtrlCreateInput("", 280, 200, 153, 21)
    $Label8 = GUICtrlCreateLabel("State:", 40, 232, 32, 17)
    $Input6 = GUICtrlCreateInput("", 72, 232, 121, 21)
    $Label9 = GUICtrlCreateLabel("Phone Number:", 40, 264, 78, 17)
    $Input7 = GUICtrlCreateInput("", 280, 232, 105, 21)
    $Label10 = GUICtrlCreateLabel("-", 176, 264, 7, 17)
    $Input8 = GUICtrlCreateInput("", 120, 264, 41, 21)
    $Label11 = GUICtrlCreateLabel("-", 248, 264, 7, 17)
    $Input9 = GUICtrlCreateInput("", 192, 264, 41, 21)
    $Label12 = GUICtrlCreateLabel("Email:", 40, 296, 32, 17)
    $Input10 = GUICtrlCreateInput("", 264, 264, 41, 21)
    $Label13 = GUICtrlCreateLabel("Money Made:", 40, 328, 69, 17)
    $Lable14 = GUICtrlCreateLabel("Notes:", 40, 360, 35, 17)
    $Label14 = GUICtrlCreateLabel("Zip:", 240, 232, 22, 17)
    $Input11 = GUICtrlCreateInput("", 80, 296, 153, 21)
    $Combo3 = GUICtrlCreateCombo("$5", 120, 328, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $Combo3 = GUICtrlSetData(-1, "$10 | $15 | $20 | $25 | $30 | $35 | $40 | $45 | $50 | $60 | $65 | $70 | $75 | $80 | $85 | $90 | $95 | $100")
    $Edit1 = GUICtrlCreateEdit("", 24, 384, 577, 137)
    GUICtrlSetData(-1, "Edit1")
    $Button1 = GUICtrlCreateButton("Save", 24, 536, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    MsgBox($MB_SYSTEMMODAL, "ControlID",  "On creating secondary GUI:" & @CRLF & "$Button1 = " & $Button1) ; ~~~~~~~~~~~~~~~~~~~~~~~
    $Button2 = GUICtrlCreateButton("Cancel", 112, 536, 75, 25)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
 
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button2
                GUIDelete($Form2)
                Return
            Case $Button1
                IniWrite($sIniFile, "Add Job", "Input3" GUICtrlRead($Input3))
        EndSwitch
    WEnd
EndFunc   ;==>Add_Job
Edited by bvr
Link to comment
Share on other sites

  • Moderators

bvr,

You are missing a comma after the "key" parameter - that is why you get an error. ;)

As to "what is suppose to go there" look at IniRead in the Help file - the structure of an ini file is explained under "Remarks". :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Cool it works, though I did think of something else. When I save it, its saved in the ini file which I can use to bring it back up to edit it. But...when I add new addresses and stuff, it will just change the one I already saved.

Link to comment
Share on other sites

  • Moderators

bvr,

Correct - you will need to use a section name that has not already been entered. I suggest that you use a numeric value - then you can use IniReadSectionNames to get the current list into an array and _ArrayMax to get the highest current value. Just add 1 and you have the next one ready to go. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

bvr,

Of course, that is why I suggested it. Just do as I proposed above each time you want to save a new job to the ini file. :)

Have a go at doing it yourself and see how you get on - you know where we are if you run into difficulties. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I will give it a try once I got the whole list saved. Running into problems with the "Time." I have the time in a combo box, and "pm/am" in a combo box beside it. Trying to figure out how to include both of them on the same line.

Link to comment
Share on other sites

  • Moderators

bvr,

Concatenate them with the & operator - something like this:

GUICtrlRead($Time) & GUICtrlRead($AM_PM)
By the way, as shown in that small snippet you might find it much easier to give sensible names to your controls - then you do not have to remember what $Input# actually holds. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Everything works except for the "am/pm." It shows "0" when it writes to the ini file.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
 
$Form1 = GUICreate("Yesterday's Lawn Care", 615, 410, 192, 124)
$sIniFile = @ScriptDir & "\Storage.ini"
$MenuItem_File = GUICtrlCreateMenu("&File")
$MenuItem_Edit = GUICtrlCreateMenu("&Edit")
$MenuItem_Help = GUICtrlCreateMenu("&Help")
$Main_Tab1 = GUICtrlCreateTab(8, 8, 601, 377)
$Main_TabSheet1 = GUICtrlCreateTabItem("Job Manager")
$Main_Group1 = GUICtrlCreateGroup("Jobs", 16, 40, 585, 329)
$Main_List1 = GUICtrlCreateList("", 24, 64, 537, 253)
$Main_Button1 = GUICtrlCreateButton("Add", 24, 336, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$Main_Button2 = GUICtrlCreateButton("Edit", 112, 336, 75, 25)
$Main_Button3 = GUICtrlCreateButton("Remove", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_TabSheet2 = GUICtrlCreateTabItem("Equipment Manager")
$Main_Group2 = GUICtrlCreateGroup("Equipment", 16, 40, 585, 329)
$Main_List2 = GUICtrlCreateList("", 24, 64, 537, 253)
$Main_Button4 = GUICtrlCreateButton("Add Unit", 24, 336, 75, 25)
$Main_Button5 = GUICtrlCreateButton("Edit Unit", 112, 336, 75, 25)
$Main_Button6 = GUICtrlCreateButton("Remove Unit", 200, 336, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_TabSheet3 = GUICtrlCreateTabItem("Stastistics/Money")
$Main_Group3 = GUICtrlCreateGroup("Stastistics", 16, 48, 569, 329)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Main_Button7 = GUICtrlCreateButton("Add Expense", 24, 344, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Main_Button1
            Add_Job()
        Case $GUI_EVENT_CLOSE
            Exit
 
    EndSwitch
WEnd
 
Func Add_Job()
    $Form2 = GUICreate("Add Job", 615, 578, 232, 131)
    $sIniFile = @ScriptDir & "\Storage.ini"
    $Group1 = GUICtrlCreateGroup("Job Information", 8, 8, 601, 561)
    $Label1 = GUICtrlCreateLabel("Date:", 32, 40, 30, 17)
    $Date = GUICtrlCreateDate("2013/08/25 01:14:40", 64, 40, 186, 21)
    $Label2 = GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
    $TimeStarted = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
    $TimeStart_amPM = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $TimeStart_amPM = GUICtrlSetData(-1, "am")
    $Label3 = GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
    $TimeFinished = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
    $TimeFinish_amPM = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $TimeFinish_amPM = GUICtrlSetData(-1, "am")
    $Label4 = GUICtrlCreateLabel("First Name:", 40, 136, 57, 17)
    $FirstName = GUICtrlCreateInput("", 112, 136, 121, 21)
    $Label5 = GUICtrlCreateLabel("Last Name:", 40, 168, 58, 17)
    $LastName = GUICtrlCreateInput("", 112, 168, 121, 21)
    $Label6 = GUICtrlCreateLabel("Address:", 40, 200, 45, 17)
    $Address = GUICtrlCreateInput("", 96, 200, 129, 21)
    $Label7 = GUICtrlCreateLabel("City:", 240, 200, 24, 17)
    $City = GUICtrlCreateInput("", 280, 200, 153, 21)
    $Label8 = GUICtrlCreateLabel("State:", 40, 232, 32, 17)
    $State = GUICtrlCreateInput("", 72, 232, 121, 21)
    $Label9 = GUICtrlCreateLabel("Phone Number:", 40, 264, 78, 17)
    $Zip = GUICtrlCreateInput("", 280, 232, 105, 21)
    $Label10 = GUICtrlCreateLabel("-", 176, 264, 7, 17)
    $PhoneDigit_One = GUICtrlCreateInput("", 120, 264, 41, 21)
    $Label11 = GUICtrlCreateLabel("-", 248, 264, 7, 17)
    $PhoneDigit_Two = GUICtrlCreateInput("", 192, 264, 41, 21)
    $Label12 = GUICtrlCreateLabel("Email:", 40, 296, 32, 17)
    $PhoneDigit_Three = GUICtrlCreateInput("", 264, 264, 41, 21)
    $Label13 = GUICtrlCreateLabel("Money Made:", 40, 328, 69, 17)
    $Lable14 = GUICtrlCreateLabel("Notes:", 40, 360, 35, 17)
    $Label14 = GUICtrlCreateLabel("Zip:", 240, 232, 22, 17)
    $Email = GUICtrlCreateInput("", 80, 296, 153, 21)
    $MoneyMade = GUICtrlCreateCombo("$5", 120, 328, 57, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    $MoneyMade = GUICtrlSetData(-1, "$10 | $15 | $20 | $25 | $30 | $35 | $40 | $45 | $50 | $60 | $65 | $70 | $75 | $80 | $85 | $90 | $95 | $100")
    $Notes = GUICtrlCreateEdit("", 24, 384, 577, 137)
    GUICtrlSetData(-1, "")
    $Secondary_SaveButton = GUICtrlCreateButton("Save", 24, 536, 75, 25) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $Secondary_CancelButton = GUICtrlCreateButton("Cancel", 112, 536, 75, 25)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
 
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Secondary_CancelButton
                GUIDelete($Form2)
                Return
Case $Secondary_SaveButton
IniWrite($sIniFile, "Add Job", "Date", GUICtrlRead($Date))
IniWrite($sIniFile, "Add Job", "Time Started", GUICtrlRead($TimeStarted) & GUICtrlRead($TimeStart_amPM))
IniWrite($sIniFile, "Add Job", "Time Finished", GUICtrlRead($TimeFinished) & GUICtrlRead($TimeFinish_amPM))
IniWrite($sIniFile, "Add Job", "First Name", GUICtrlRead($FirstName))
IniWrite($sIniFile, "Add Job", "Last Name", GUICtrlRead($LastName))
IniWrite($sIniFile, "Add Job", "Address",   GUICtrlRead($Address))
IniWrite($sIniFile, "Add Job", "City", GUICtrlRead($City))
IniWrite($sIniFile, "Add Job", "State", GUICtrlRead($State))
IniWrite($sIniFile, "Add Job", "Zip", GUICtrlRead($Zip))
IniWrite($sIniFile, "Add Job", "Phone Number", GUICtrlRead($PhoneDigit_One) & GUICtrlRead($PhoneDigit_Two) & GUICtrlRead($PhoneDigit_Three))
IniWrite($sIniFile, "Add Job", "Email", GUICtrlRead($Email))
IniWrite($sIniFile, "Add Job", "Money Made", GUICtrlRead($MoneyMade))
IniWrite($sIniFile, "Add Job", "Notes", GUICtrlRead($Notes))
GUIDelete($Form2)
Return
        EndSwitch
    WEnd
EndFunc   ;==>Add_Job
Edited by bvr
Link to comment
Share on other sites

  • Moderators

bvr,

Try it like this:

GUICtrlCreateLabel("Time Started:", 32, 72, 67, 17)
$TimeStarted = GUICtrlCreateInput("00:00", 112, 72, 49, 21)
$TimeStart_amPM = GUICtrlCreateCombo("pm", 168, 72, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($TimeStart_amPM, "am")
GUICtrlCreateLabel("Time Finished:", 32, 104, 72, 17)
$TimeFinished = GUICtrlCreateInput("00:00", 112, 104, 49, 21)
$TimeFinish_amPM = GUICtrlCreateCombo("pm", 168, 104, 41, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($TimeFinish_amPM, "am")
You were reassigning the $TimeStart/Finish_amPM variables to the return values from GUICtrlSetData lines and thus overwriting the actual ControlID value - thus you got no return when you tried to read the controls as you were not using their actual ControlIDs. ;)

Notice also that I have removed the variables storing the ControlID of the labels in that snippet - you never need to access them so why store them? Koda assigns all the ControlIDs by default - you actually only need those you are going to use elsewhere in the script, the rest can just be ignored and can be removed. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ok I got that working. Now to add multiple entries I would have to use an array? This is what I found in the help file but can't see how it can be added to my script

; Demonstrate creating a new section using an array as input.
Local $aData1 = IniReadSection($sIni, "Section1") ; Read in what we just wrote above.
For $i = 1 To UBound($aData1) - 1
    $aData1[$i][1] &= "-" & $i ; Change the data some
Next

IniWriteSection($sIni, "Section2", $aData1) ; Write to a new section.
Link to comment
Share on other sites

  • Moderators

bvr,

Go and re-read what I suggested - you have not done what I suggested. You need to use numeric values as the section names. Then IniReadSectionNames will pull these names into an array from which you extract the current max - then add 1 to get the next section value to use. ;)

I would add something like this at the top of your script:

Local $aSections = IniReadSectionNames($sIniFile)
Global $iCurrent_Max_Section = _ArrayMax($aSections)
If @error Then
    $iCurrent_Max_Section = 0 ; This sets the value to 0 if there are no existing sections
EndIf
Now the $iCurrent_Max_Section variable holds the current value of the highest section value. Then in the Add_Job function when you want to write a new section to the file, you just add 1 to that value and use it in the IniWrite statements:

Case $Secondary_SaveButton
    $iCurrent_Max_Section += 1 ; Increase the value for teh next section
    IniWrite($sIniFile, $iCurrent_Max_Section, "Date", GUICtrlRead($Date)) ; And use it to write the new section
    ; And so on
Now each job you add will have its own individual section value - and each one can contain the required keys without them being overwritten when you add a new job. :)

Does that make sense? If not then I am afraid you will have to wait until tomorrow afternoon for a more detailed explanation - unless someone else cares to step in while I am asleep and then on the golf course in the morning. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

 

Says Unknown Function name 

 _ArrayMax($aSections)

Because you need to add the line #include <Array.au3> at the top of your script. Open the help file for the function, you'll see examples of how to use it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

bvr,

Delighted that you got it working. Now when you start to read through the ini file you will see why I suggested numeric section names. ;)

By the way, can I just say what a pleasure it is to help someone who actually listens to the advice offered and is prepared to do some coding themselves. It makes a pleasant change from "write it for me" threads we so often get. :thumbsup:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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