Onyinye Posted August 17, 2015 Posted August 17, 2015 I'm trying to Read read in a section of an ini with IniReadSection, then indirectly set GUI input boxes using inGUICtrlSetData using the variable name and data contained in the ini file. My ini file looks like this:[GuiDefaultsInput]$hGUIvariable1=123$hGUIvariable2=1$hGUIvariable3=2$hGUIvariable4=3All of the variables have already been defined using:Global $hGUIvariable1= GUICtrlCreateInput("test",10,350,100, 20)I want to, in a loop, set the inputbox data to what is predefined in the ini file.Here is a snippet of my code:;Assign input fields $aIniRead = IniReadSection($iniPath,"GuiDefaultsInput") For $i = 1 to $aIniRead[0][0] $result = GUICtrlSetData($aIniRead[$i][0],$aIniRead[$i][1]) If $result = 0 then ExitProgram("Error setting Ini values in ReadIni() for input boxes. Trying to set variable:" &$aIniRead[$i][0] &" to "& $aIniRead[$i][1]) NextI've also tried :$result = GUICtrlSetData(GUICtrlGetHandle($aIniRead[$i][0]),$aIniRead[$i][1])and$result = GUICtrlSetData(String($aIniRead[$i][0]),$aIniRead[$i][1])As well as various combinations of Eval() and Assign(). I feel like there is a command I'm missing to convert a String name to a variable name for somethting to evaluate.
water Posted August 17, 2015 Posted August 17, 2015 How many variables are we talking about? Is it always $hGUIvariable1 to 4? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Onyinye Posted August 17, 2015 Author Posted August 17, 2015 Its 4 right now, but I'll probably add up to 10. I realize I can just hard code each of them(that's what I have now), but I was trying to make the development easier for myself
water Posted August 17, 2015 Posted August 17, 2015 Up to 9 this works:#include <GUIConstantsEx.au3> GUICreate("Test", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1) Global $iIDs[4] $iIDs[0] = GUICtrlCreateInput("", 10, 5, 300, 20) $iIDs[1] = GUICtrlCreateInput("", 10, 30, 300, 20) $iIDs[2] = GUICtrlCreateInput("", 10, 55, 300, 20) $iIDs[3] = GUICtrlCreateInput("", 10, 80, 300, 20) _ReadIni() GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _ReadIni() Local $aIni = IniReadSection(@ScriptDir & "\test.ini", "GuiDefaultsInput") For $i = 1 To $aIni[0][0] $iIndex = StringMid($aIni[$i][0], 14, 1) - 1 If $iIndex >= 0 And $iIndex <= UBound($iIDs) - 1 Then GUICtrlSetData($iIDs[$iIndex], $aIni[$i][1]) Next EndFunc ;==>_ReadIni My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now