Jump to content

Recommended Posts

Posted

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)

Posted (edited)

It isn't reading the 1st column with FileReadLine either, is it? It reads the whole line :P

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 by D4ni
Posted

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 :P

Posted

OK, see.

I am sending the file.

Do you have some example using file excel?.

thank you very much

See 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 :P 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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...