WARLICHVN Posted July 20, 2009 Share Posted July 20, 2009 Hi everyone,Currently I have a problem with 1 tool I do.Problem found in "Array" and "String"Program will do the following:-Get data from a file "myname.txt", in file myname.txt have 3 Lines, I want to enter 3 lines to 3 rows each with a different column is part 1 how to stop with "|"Example line: TonyBrank | KingOpera | 01236I want information for the other 3 to 3 different columns.And how to read the information in that column.Example:Thanks! Link to comment Share on other sites More sharing options...
bo8ster Posted July 20, 2009 Share Posted July 20, 2009 Post your code of what you have tried so far. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
WARLICHVN Posted July 20, 2009 Author Share Posted July 20, 2009 (edited) #include<String.au3> #include <Array.au3> $Open = FileOpen("CC.txt",0) $Line = FileReadLine (FileOpen("CC.txt",0) , 0) $String = StringSplit($Line, "|") Local $avArray[3] $avArray[0] = "TonyBrank" $avArray[1] = "KingOpera" $avArray[2] = "01236" _ArrayDisplay($avArray, "$avArray set manually 1D transposed", -1, 1) How to share information with short hours "|" - Information from all myname.txt file for each row, column Example, have 3 lines will correspond to 3 rows 3 is the short way with "|" will have 3 columns, respectively. Edited July 20, 2009 by WARLICHVN Link to comment Share on other sites More sharing options...
WARLICHVN Posted July 20, 2009 Author Share Posted July 20, 2009 And how to read information from row1 with column 1 ; 2 ;3 | row 2 with column 1 ; 2 ;3 I don't know func to read Link to comment Share on other sites More sharing options...
Manjish Posted July 20, 2009 Share Posted July 20, 2009 When u want multiple columns and rows, you will need to define a 2D array. example, avarray[1][2] will have 1 row and two columns. I won't write the entire code, as you seem capable enuf to do so on your own. Here's the idea: 1) define an array in above fashion with say 3 columns and as many rows u want. 2) filereadline will read the line and stringsplit will split it by "|". The data in strinsplit array $string shud be used to place into columns of avarray (2d), like: for $i=1 to 100 $line=filereadline($file,$i) if $line="" then exitloop $string=stringsplit($line,"|") $avarray[$i][1]=$string[1] $avarray[$i][2]=$string[2] $avarray[$i][3]=$string[3] next Above is an untested code. Its just there to give u an idea to the correct solution. Hope this helps. [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
WARLICHVN Posted July 20, 2009 Author Share Posted July 20, 2009 (edited) Thank Manjish, that's good idea, i will recode now!!! Thank again And, 1 question is : How to read information from row, i don't know func to do it Edited July 20, 2009 by WARLICHVN Link to comment Share on other sites More sharing options...
Manjish Posted July 20, 2009 Share Posted July 20, 2009 there no read function as such.. if u know the row and column no. then just put it in as: array [r][c] that will tell u the value at row no. "r" and column no. "c" [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
WARLICHVN Posted July 20, 2009 Author Share Posted July 20, 2009 there no read function as such.. if u know the row and column no. then just put it in as: array [r][c] that will tell u the value at row no. "r" and column no. "c" How to, can you help me to example code ? Link to comment Share on other sites More sharing options...
Manjish Posted July 20, 2009 Share Posted July 20, 2009 How to, can you help me to example code ? in ur 1st post the value of array at row 0 and column 0 is "TonyBrank" so, $value=$avArray[0][0] In this case $value will be "TonyBrank". Like this you can read array values and store in other variables. [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
trung0407 Posted July 20, 2009 Share Posted July 20, 2009 (edited) #include<String.au3> #include <Array.au3> Global $tab[20][20] $Open = FileOpen("CC.txt",0) $x=0 While 1 $Line = FileReadLine ($Open) If @error Then ExitLoop $String = StringSplit($Line, "|") For $i=1 To UBound($String)-1 $tab[$x][$i-1] = $String[$i] Next $x+=1 WEnd Edited July 20, 2009 by trung0407 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