edumanilha Posted February 3, 2020 Author Share Posted February 3, 2020 22 hours ago, mikell said: Sorry. My bad, I didn't provide explanations What my code does is : from a "test.txt" file containing this red station - 192.168.1.10 yellow station - 192.168.1.11 It first builds a "test.ini" file which content is [stations] red station=192.168.1.10 yellow station=192.168.1.11 Then using the IniReadSection function you can directly get a 2D array to use in the script #Include <Array.au3> #include <GUIConstants.au3> ; create the ini (for the example) $newtext = "[stations]" & @crlf & StringReplace(FileRead("test.txt"), " - ", "=") FileWrite("test.ini", $newtext) ; read to a 2D array $res = IniReadSection("test.ini", "stations") ; _ArrayDisplay($res) ; display GUICreate("QUAL ESTAÇÃO ?", 350, 50) Local $idCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($idCombo, _ArrayToString($res, "|", 1, -1, "|", 0, 0)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idCombo For $i = 1 to $res[0][0] If GuiCtrlRead($idCombo) = $res[$i][0] Then Msgbox(0,"", $res[$i][1]) Next EndSwitch Wend Thanks for the explanation...I think I'll try the init way...Because I separated the info into 2 ou 3 .txt files...And one .init file is more beautiful! Link to comment Share on other sites More sharing options...
edumanilha Posted February 3, 2020 Author Share Posted February 3, 2020 On 2/2/2020 at 11:45 AM, Subz said: As @mikell mentioned if you can use ini format then you can use the ini... functions [Instructions] Red Station = 192.168.1.10 Blue Station = 192.168.1.11 If you need to use that format then you can use RegExp or a number of other options, for example: I think I'll try .init! I dont NEED exactly...I just need two info and a separator... FILStations.au3 926 B · 2 downloads Link to comment Share on other sites More sharing options...
mikell Posted February 3, 2020 Share Posted February 3, 2020 3 hours ago, edumanilha said: I just need two info and a separator... ... and it is EXACTLY what a .ini file is made for edumanilha 1 Link to comment Share on other sites More sharing options...
iamtheky Posted February 3, 2020 Share Posted February 3, 2020 I agree it screams to be an .ini, but if you never use that section other than to read it to an array, is that dance more efficient than something like... #include<array.au3> local $a[0][2] _ArrayAdd($a , stringstripWS(FileRead("FilStations.txt") , 2) , 0 , "-") _ArrayDisplay($a) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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