myspacee Posted July 28, 2014 Share Posted July 28, 2014 (edited) Hello, in these days i try to make a command line script that do some text substitution. (and other things) When configured tool run as command line, when /config switch is given, tool pass in configuration mode. I'm try to read a configuration file with _FileReadToArray, to give my users a visual method to modify parameters in in this file, in easy way. (without missing) After read this file with _FileReadToArray i must: - strinsplit using special char (four § split | 5 values) - present data to my users to let them choose one - pass select 'line' to an edit mask (to allow changes) - return back changes - give a button to save back modified fields/data to file. I start to read file then for/next every line for the subsequent split, but i don't know how present these data to user: #include <array.au3> #include <File.au3> Local $aRecords If Not _FileReadToArray("reg.ini", $aRecords) Then MsgBox(4096, "Error", " Error reading file to Array error:" & @error) Exit EndIf For $x = 1 To $aRecords[0] MsgBox(0, 'Record:' & $x, $aRecords[$x]) $oneRow = stringsplit($aRecords[$x],"§") Next post also (part) of my config file for parsing: </croce>§*§§[SIMBOLO]§[/SIMBOLO] </DataLoc>§*§§[DATA_OGGI]§[/DATA_OGGI] </DataR1>§*§§[DATA_MORTE]§[/DATA_MORTE] </DataR2>§*§§[DATA_ANNIVERSARIO]§[/DATA_ANNIVERSARIO] </Foto:65>©§1§@QUI_CODICE_PER_POSTPROCESSING§[FOTO_NORMALE_COLORI]§[/FOTO_NORMALE_COLORI] </Foto:90>©§1§§[FOTO_GRANDRE_COLORI]§[/FOTO_GRANDRE_COLORI] Can you help me with some code and ideas? Thank you, m. Edited July 28, 2014 by myspacee Link to comment Share on other sites More sharing options...
BrewManNH Posted July 28, 2014 Share Posted July 28, 2014 The latest version of AutoIt includes a _FileReadToArray that will do the string splitting for you. It returns a 2D array when you use the delimiter parameter, and the delimiter is in the lines. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
myspacee Posted July 28, 2014 Author Share Posted July 28, 2014 (edited) Thank you for reply, I can add this little part of code alone: #include <array.au3> #include <File.au3> Dim $oneDarray _FileReadToArray("reg.ini", $oneDarray) $columnsCounter = stringsplit($oneDarray[1],"§") Dim $twoDarray[$oneDarray[0] + 1][$columnsCounter[0] + 1] For $x = 1 to ($oneDarray[0]) $oneRow = stringsplit($oneDarray[$x],"§") For $y = 1 to ($columnsCounter[0]) $twoDarray[$x][$y] = $oneRow[$y] msgbox(0,"",$twoDarray[$x][$y]) Next Next but Ignore how build 'row selectable _ArrayDisplay GUI' to my users, and pass 'row' data to next step. m. EDIT: I Imagine a _arraydisplay with single row function. Edited July 28, 2014 by myspacee Link to comment Share on other sites More sharing options...
BrewManNH Posted July 28, 2014 Share Posted July 28, 2014 Don't use _ArrayDisplay, build your own listview and go from there. There are 100's of examples of how to do this in the forums here that should answer your questions. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
computergroove Posted July 29, 2014 Share Posted July 29, 2014 _ArrayDisplay is like msgbox but for arrays. What do you want to show the users of your script? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
myspacee Posted July 29, 2014 Author Share Posted July 29, 2014 (edited) Thank you your attention, post an image to explain better my needs: On the left we have MAIN window, copiled with first and second field of text file. When user select a row and press EDIT, second edit contains all 5 field and allow modification. When finish MAIN OK (on the left) overwrite old file with new (or modified) content. Adapt some code find, and build MAIN windows with first button capable to read selected row. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> #include <File.au3> #include <GUIListView.au3> Local $listview, $button, $item1, $item2, $item3, $item4, $item5, $msg GUICreate("INI", 640, 480, 0, 0, -1) $listview = GUICtrlCreateListView("col1|col2|col3|col4|col5 ", 10, 10, 600, 400) $button = GUICtrlCreateButton("EDIT", 75, 450, 70, 20) Dim $oneDarray _FileReadToArray("reg.ini", $oneDarray) $columnsCounter = stringsplit($oneDarray[1],"§") Dim $twoDarray[$oneDarray[0] + 1][$columnsCounter[0] + 1] $data_mined = "" For $x = 1 to ($oneDarray[0]) $oneRow = stringsplit($oneDarray[$x],"§") $data_mined = "" For $y = 1 to ($columnsCounter[0]) $twoDarray[$x][$y] = $oneRow[$y] $data_mined = $data_mined & $twoDarray[$x][$y] & "|" Next GUICtrlCreateListViewItem($data_mined, $listview) Next _GUICtrlListView_SetColumnWidth($listview, 0, $LVSCW_AUTOSIZE) GUISetState() Do $msg = GUIGetMsg() Select Case $msg = $button MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview))) EndSelect Until $msg = $GUI_EVENT_CLOSE Next step is pass these values to SUB gui, and allow edited data come back to listview. How substitute values in MAIN ? Sorry again, and thank you, m. Edited July 29, 2014 by myspacee 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