meme18 Posted November 1, 2023 Posted November 1, 2023 okay, i try to rewrite old autoit project from another guy. he saves things in ini file like this $profilename1input = GUICtrlRead($profilename1) IniWrite($IniFile, "profilename", "profilename1", $profilename1input) $profilename2input = GUICtrlRead($profilename2) IniWrite($IniFile, "profilename", "profilename2", $profilename2input) $profilename3input = GUICtrlRead($profilename3) IniWrite($IniFile, "profilename", "profilename3", $profilename3input) $profilename4input = GUICtrlRead($profilename4) IniWrite($IniFile, "profilename", "profilename4", $profilename4input) $profilename5input = GUICtrlRead($profilename5) IniWrite($IniFile, "profilename", "profilename5", $profilename5input) so i thought, no problem, easy just do bash like eval or array .... something like this. tried it now 30 mins and soon i will damage something. please help Local $profilename[5] $counter = 1 While $counter <= 5 $profilenameinput = GUICtrlRead($profilename[$counter]) IniWrite($IniFile, "profilename", "profilename" & $counter, $profilenameinput) $counter += 1 WEnd
Subz Posted November 1, 2023 Posted November 1, 2023 Not sure what you mean since $profileName[x] isn't associated with a control, so nothing for GuiCtrlRead to read, or do you mean something like: Local $profilename[5] = ["Profile1","Profile2","Profile3", "Profile4", "Profile5"] For $i = 0 To UBound($profilename) - 1 ConsoleWrite($profilename[$i] & @CRLF) IniWrite($IniFile, "profilename", "profilename" & $i, $profilename[$i]) Next meme18 1
meme18 Posted November 1, 2023 Author Posted November 1, 2023 (edited) thank you for your fast answer. i like to count the variable too. i dont know how to do that maybe array is wrong and i need evil eval.maybe does something like this work? Local $profilename[5] For $i = 0 To UBound($profilename) - 1 $profilename[$i] += ["profilename & $i"] ConsoleWrite($profilename[$i] & @CRLF) IniWrite($IniFile, "profilename", "profilename" & $i, $profilename[$i]) Next im very sorry, the syntax is weird for me Edited November 1, 2023 by meme18
meme18 Posted November 1, 2023 Author Posted November 1, 2023 2 minutes ago, Nine said: I would strongly suggest that you create your controls into an array instead of separate variables. But to answer your issue with a quick and dirty solution : Local $sProfile For $i = 1 To 5 $sProfile = GUICtrlRead(Eval("profilename" & $i)) IniWrite($IniFile, "profilename", "profilename" & $i, $sProfile) Next i swear i tried that 🤪okay, lets check again, but the array above? how can i do it with array?
Solution Nine Posted November 1, 2023 Solution Posted November 1, 2023 Sorry I deleted my post instead of editing it. Anyway, to create an array of controls, you would do something like this : GUICreate("") Local $aIDtest[5] For $i = 0 To UBound($aIDtest) - 1 $aIDtest[$i] = GUICtrlCreateInput("test " & $i, 10, 10 + $i * 30) Next GUISetState() Sleep(5000) meme18 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
meme18 Posted November 1, 2023 Author Posted November 1, 2023 (edited) @Nine@Subz many thx. got both working. i go with arrays. when i try this backwards with defining variables that should be reachable globally. how can i solve this? $program1 = Null $program2 = Null $program3 = Null $program4 = Null $program5 = Null i tried to use Assign but maybe im wrong again... For $i = 1 To 5 Assign ( "program" & $i ), "Null" ) Next Edited November 1, 2023 by meme18
Nine Posted November 1, 2023 Posted November 1, 2023 See help file Assign. There's a parameter forcing global scope. Xandy 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ioa747 Posted November 2, 2023 Posted November 2, 2023 13 hours ago, meme18 said: i tried to use Assign but maybe im wrong again... For $i = 1 To 5 Assign ( "program" & $i ), "Null" ) Next to: For $i = 1 To 5 Assign("program" & $i, "Null") Next meme18 1 I know that I know nothing
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