Onyinye Posted August 17, 2015 Share 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. Link to comment Share on other sites More sharing options...
water Posted August 17, 2015 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Onyinye Posted August 17, 2015 Author Share 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 Link to comment Share on other sites More sharing options...
water Posted August 17, 2015 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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