Friedel2k 0 Posted August 19, 2021 Share Posted August 19, 2021 Dear all, i just can not solve it. I hope u can give me a right tip. I just want to import a ini file, for example: [printer] $pool_1=1 $pool_2=2 $pool_3=3 with the function IniRead and I want to use direct $pool_1 as var, and the var should have the value 1 and of course has the ini file later n entrys for N vars. I have tryed evey help / refference / forum, but Iam just not able to get it. Thanks for feedback! Link to post Share on other sites
Zedna 356 Posted August 19, 2021 Share Posted August 19, 2021 Look at IniReadSection() in helpfile. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
Friedel2k 0 Posted August 20, 2021 Author Share Posted August 20, 2021 Thank u ! I got it. Please one more question. Now I got the data in an array, but how to get these data into vars? Or to update existing vars? Thank you! Link to post Share on other sites
Zedna 356 Posted August 20, 2021 Share Posted August 20, 2021 (edited) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $pom $var = IniReadSection('opt.ini','printer') If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0][0] ;~ MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1]) $pom &= "Key"&$i&": " & $var[$i][0] & " Value"&$i&": " & $var[$i][1] & @CRLF Assign($var[$i][0], $var[$i][1]) ; create variable Next EndIf MsgBox(4096, "IniReadSection array", $pom) MsgBox(4096, "Variables", "$pool_1: " & Eval('$pool_1') & @CRLF & "$pool_2: " & Eval('$pool_2') & @CRLF & "$pool_3: " & Eval('$pool_3')) Edited August 20, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
Friedel2k 0 Posted August 20, 2021 Author Share Posted August 20, 2021 Thank you, but it seems not that this will generate var´s. And also not the values for the var´s. If I "ask" autoit vor the vars and or var / result there are no values. Or is there a other option to import vars from a text file with there values? Thank you. Link to post Share on other sites
Nine 1,503 Posted August 20, 2021 Share Posted August 20, 2021 You cannot have a variable starting with 2 $. You would need to remove the first $ from the array before creating the variables (or simply remove them from ini file). Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search content in 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 GIF Animation (cached) Screen Scraping Link to post Share on other sites
Zedna 356 Posted August 20, 2021 Share Posted August 20, 2021 (edited) Thanks Nine for good pointing! For this INI file: Quote [printer]pool_1=1pool_2=2pool_3=3 Works This my script: Note that you have to disable Au3Check if you have $ + name of dynamic variable mentioned directly in script (my last line) #AutoIt3Wrapper_Run_AU3Check=n Dim $pom $var = IniReadSection('opt.ini','printer') If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0][0] $pom &= "Key"&$i&": " & $var[$i][0] & " Value"&$i&": " & $var[$i][1] & @CRLF Assign($var[$i][0], $var[$i][1]) ; create variable Next EndIf MsgBox(4096, "IniReadSection array", $pom) MsgBox(4096, "Variables Eval", "$pool_1: " & Eval('pool_1') & @CRLF & "$pool_2: " & Eval('pool_2') & @CRLF & "$pool_3: " & Eval('pool_3')) MsgBox(4096, "Variables Direct", "$pool_1: " & $pool_1 & @CRLF & "$pool_2: " & $pool_2 & @CRLF & "$pool_3: " & $pool_3) ; <-- Au3Check must be disabled Edited August 20, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
Friedel2k 0 Posted August 24, 2021 Author Share Posted August 24, 2021 Thx a lot! Thats it! Works fine for me. Thank you all! Link to post Share on other sites
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