marko001 Posted May 26, 2014 Posted May 26, 2014 Hi all guys, I'm trying to find a solution for the following: I have an Editbox $CH_Edit = GUICtrlCreateEdit("", 71, 40, 81, 353, BitOR($WS_VSCROLL,$ES_WANTRETURN)) $CH_Close = GUICtrlCreateButton("Save&Close", 70, 408, 75, 25) and I would like to pass to an array all the datas inside, row by row. i.e. if I have in the editbox John-Holder Frank-MCGregor Alex-Dentis I would like to have, once Button has been clicked, dm $names[100][2] ; fixed or it would be better dinamic based on the row of the editbox and $names[0][0]=John $names[0][1]=Holder $names[1][0]=Frank $names[1][1]=MCGregor $names[2][0]=Alex $names[2][1]=Dentis Can you please help me to solve this? Thanks in advance, Marco
UEZ Posted May 26, 2014 Posted May 26, 2014 (edited) Try something like this here: #include <Array.au3> $sText = "John-Holder" & @CRLF & _ "Frank-MCGregor" & @CRLF & _ "Alex-Dentis" $a = StringRegExp($sText, "(.+)\S*", 3) Global $aSplitted[UBound($a)][2] For $i = 0 to UBound($a) - 1 $aTmp = StringRegExp($a[$i], "(\w+)", 3) $aSplitted[$i][0] = $aTmp[0] $aSplitted[$i][1] = $aTmp[1] Next _ArrayDisplay($aSplitted) No error checks added! Br, UEZ Edited May 26, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
marko001 Posted May 26, 2014 Author Posted May 26, 2014 Hi UEZ and thanks, it works perfectly. Just one thing: I'm usual to store all datas in a settings.ini file IniWrite($_settings, "Datas", "Full Names", GUICtrlRead($ch_edit)) In this way it stores the datas in this way: [Datas] [...] Full Names=John-Holder Frank-MCGregor Alex-Dentis and this is an error since when I'll iniread(..) it will get just read into editbox the first name after the key. Shall I save the editbox content to a file and call it at _loadsettings()? Thanks, Marco
mikell Posted May 26, 2014 Posted May 26, 2014 Do you want the ini to look like this [Full Names] 1=John-Holder 2=Frank-MCGregor 3=Alex-Dentis or this [Data] Full Names=John-Holder,Frank-MCGregor,Alex-Dentis or else ?
marko001 Posted May 26, 2014 Author Posted May 26, 2014 Honestly it's important for me to iniread() and iniwrite() them so I can get them back. I will, when needed, store the values to the array[$x][$y]. Second solution seems more "space"-efficient since I have other keys in the .ini It's important I can retrieve them and store in the editbox. Thanks a lot, mate. Marco
Solution mikell Posted May 26, 2014 Solution Posted May 26, 2014 (edited) Here it is, very raw But maybe it's not the best way if you have a huge number of names to store #include <Array.au3> $_settings = "settings.ini" $sText = "John-Holder" & @CRLF & _ "Frank-MCGregor" & @CRLF & _ "Alex-Dentis" $names = StringReplace($sText, @crlf, ",") IniWrite($_settings, "Data", "Full Names", $names) $a = StringRegExp($sText, "(.+)\S*", 3) Global $aSplitted[UBound($a)][2] For $i = 0 to UBound($a) - 1 $aTmp = StringRegExp($a[$i], "(\w+)", 3) $aSplitted[$i][0] = $aTmp[0] $aSplitted[$i][1] = $aTmp[1] Next _ArrayDisplay($aSplitted) $get = IniRead($_settings, "Data", "Full Names", "") $names2 = StringReplace($get, ",", @crlf) Msgbox(0,"", $names2) Edit typo... Edited May 26, 2014 by mikell
marko001 Posted May 26, 2014 Author Posted May 26, 2014 Great, yes I used it in the past and honestly I forgot it. Thanks again dude, Marco
marko001 Posted May 26, 2014 Author Posted May 26, 2014 (edited) [sOLVED!] Err... I found that if I use an editbox to store datas $CH_Edit = GUICtrlCreateEdit("", 71, 56, 81, 313, BitOR($WS_VSCROLL,$ES_WANTRETURN)) GUICtrlSetData(-1, "") It doesn't recognize the @crlf so using stringreplace() it doesn't work. Any suggestion? Thanks, M. Edited May 26, 2014 by marko001
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