Silvinho Posted November 19, 2007 Share Posted November 19, 2007 I am reading a file that count one column, and if I have two columns:Example Name Age Silvio 42 Mary 47 Run("CadCli.exe") $file = FileOpen("c:\temp\Familia.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop WinWaitActive("Cadastro de Clientes") ;here below, I am typing in a Delphi's Edit. Send($line) And if I want to read to other column of the txt file and to type in other Delphi's Edit? ControlClick("Cadastro de Clientes", "", "[CLASS:TButton; TEXT:Gravar; INSTANCE:2]") Send("{ENTER}") Wend FileClose($file) Link to comment Share on other sites More sharing options...
dani Posted November 20, 2007 Share Posted November 20, 2007 (edited) It isn't reading the 1st column with FileReadLine either, is it? It reads the whole line What you should do is the following: $Whole_Line = FileReadLine($File) $Columns = StringSplit($Whole_Line, " ") $First_Column = $Columns[1] $Second_Column = $Columns[2] As you can see, this assumes columns are seperated using a single space (" "). It's more convinient to use a rare character like the pipe ("|") or something. Edited November 20, 2007 by D4ni Link to comment Share on other sites More sharing options...
dani Posted November 20, 2007 Share Posted November 20, 2007 I don't know what else I can provide you in order to read columns? Can't you do anything with what I gave you? Instead of sending $line, you should be sending $First_Column and $Second_Column, wherever you want to put that data Link to comment Share on other sites More sharing options...
dani Posted November 20, 2007 Share Posted November 20, 2007 I'll just post an example, it works fine here. $File = "columns.txt" $Whole_Line = FileReadLine($File) MsgBox(0,"", $Whole_Line) $Columns = StringSplit($Whole_Line, "|") $First_Column = $Columns[1] $Second_Column = $Columns[2] MsgBox(0,"",$First_Column) MsgBox(0,"",$Second_Column) columns.txt: column1|column2 Link to comment Share on other sites More sharing options...
dani Posted November 20, 2007 Share Posted November 20, 2007 It all depends on your Familia.txt, obviously. Show me the contents please. Link to comment Share on other sites More sharing options...
dani Posted November 21, 2007 Share Posted November 21, 2007 OK, see. I am sending the file. Do you have some example using file excel?. thank you very muchSee there's the mistake. You have: Silvio Aulik | 42 Rosangela Zeni| 47 Pedro Zeni | 20 Snoopy | 08 Nininha | 06 Lord | 02 Whereas you should have: Silvio Aulik|42 Rosangela Zeni|47 Pedro Zeni|20 Snoopy|08 Nininha|06 Lord|02 You could have figured that out yourself, right I know the layout isn't great this way, and there probably is a pretty easy way to allow the layout you initially had, but this really is the easiest way. 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