TrickyDeath Posted July 24, 2015 Share Posted July 24, 2015 Hello everyone again,I tried to find out how to do my stuff, but i get stucked hard with it, until i found M23 great work "GuiListViewEx". c(:But, i have new problem. I have made a GUI with a ListView where the user can add / remove items on 2 column.When he/she finish with it, then the ListView all element moved into a 2D array, what i save with this:$ListView_Database = _GUIListViewEx_ReadToArray($ListView, 0)_FileWriteFromArray($sFileSaveDialog, $ListView_Database)This is work fine, but i wana read that file later into a 2D array with another program. Have no clue how to tellto the array, the "|" are separator lines, and it is separating 1st dim and 2nd dim.I guess the solution will come with stringformat, but not realy sure, maybe i said something silly.Tricky Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
water Posted July 24, 2015 Share Posted July 24, 2015 Dog ate your help file? _FileWriteFromArray tells you how to specify a delimiter. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
kylomas Posted July 24, 2015 Share Posted July 24, 2015 (edited) TrickyDeath,See _FileReadToArray in the Help file. A small example...#include <array.au3> #include <file.au3> ; create and populate test array local $aTest[10][5] for $i = 0 to ubound($aTest) - 1 for $j = 0 to ubound($aTest,2) - 1 $aTest[$i][$j] = 'Row ' & stringformat('%03i',$i) & ' Col ' & stringformat('%03i',$j) Next Next ; display the array _arraydisplay($aTest) ; write the array to a file _filewritefromarray(@scriptdir & '\test.txt',$aTest) ; display the file using the default program for the .TXT extention ;shellexecute(@scriptdir & '\test.txt') ; declare new array and read file to it local $aTest2 _FileReadToArray(@scriptdir & '\test.txt',$aTest2, $FRTA_NOCOUNT, '|') ; display the new array _arraydisplay($aTest2)kylomasedit: The 4TH parameter of _FileReadToArray is how you tell the function what character(s) separates the columns. Edited July 24, 2015 by kylomas code correction TrickyDeath 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Malkey Posted July 25, 2015 Share Posted July 25, 2015 ...I guess the solution will come with stringformat, but not realy sure, maybe i said something silly.....It looks like kylomas' 4th parameter of _FileReadToArray is the solution and not StringFormat. ....... $aTest[$i][$j] = 'Row ' & stringformat('%03i',$i) & ' Col ' & stringformat('%03i',$j) ........edit: The 4TH parameter of _FileReadToArray is how you tell the function what character(s) separates the columns.However, in kylomas' example, instead of concatenating strings and StringFormat functions, you can use only one StringFormat function.$aTest[$i][$j] = StringFormat('Row %03i Col %03i', $i, $j) Link to comment Share on other sites More sharing options...
TrickyDeath Posted July 25, 2015 Author Share Posted July 25, 2015 (edited) //to Water - That is ok, i saw that part, and it is work fine to write into a file. Like i said i had problem, to read it back into a 2D array where i could not see anything what is explaining how to do in help file. OMG i see now... Seams i am blind. o,OI look on help file and what i see there is:#include <File.au3>#include <Array.au3>#include <MsgBoxConstants.au3>Example()Func Example() ; Define a variable to pass to _FileReadToArray. Local $aArray = 0 ; Read the current script file into an array using the variable defined previously. If Not _FileReadToArray(@ScriptFullPath, $aArray) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. EndIf ; Display the array in _ArrayDisplay. _ArrayDisplay($aArray)EndFunc ;==>Example #include <File.au3>#include <Array.au3>#include <MsgBoxConstants.au3>Example()Func Example() ; Define a variable to pass to _FileReadToArray. Local $aArray = 0 ; Read the current script file into an array using the variable defined previously. ; $iFlag is specified as 0 in which the array count will not be defined. Use UBound() to find the size of the array. If Not _FileReadToArray(@ScriptFullPath, $aArray, 0) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. EndIf ; Display the array in _ArrayDisplay. _ArrayDisplay($aArray)EndFunc ;==>Example #include <File.au3>_FileReadToArray ( $sFilePath, ByRef $aArray [, $iFlag = 1] )I still do not see anything what is telling me about 2D array solution. Is it new stuff, or it was always like that?Do not see the 4th parameter in help file and, if i run your script i get error messages:warning: $FRTA_NOCOUNT: possibly used before declaration._FileReadToArray(@scriptdir & '\test.txt',$aTest2, $FRTA_NOCOUNT error: $FRTA_NOCOUNT: undeclared global variable._FileReadToArray(@scriptdir & '\test.txt',$aTest2, $FRTA_NOCOUNTFor me looks like, i have older version of AutoIT what is not supporting this 4th parameter... And in help file i see now the 4th parameter.#include <File.au3>_FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )BTW, since forum engine changed, how can i mark the post as there is the solution like before?P.S.: I do nto like this new search system in new forum.In my opinion, the older version was better. Problem solved! I had lill older version AutoIT what did not wanted to support the 4th parameter. With new version work fine. Edited July 25, 2015 by TrickyDeath Inserting new comments Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
water Posted July 25, 2015 Share Posted July 25, 2015 So you now know why it is a good idea to post the version of AutoIt you use with your question. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TrickyDeath Posted July 25, 2015 Author Share Posted July 25, 2015 Yes, and i should check more often the new updates. Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) 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