I have develop a code with While loop. but I need to read a file line by line, and I have tried the sample but it did not work. Can anyone correct the script because the ReadLn gives me an error. I need to read a text file and put the field into a web form, and then do something come back and read the line 2 and so forth. Here is the code. Thanks for the help.
19284 19284 119284192849284//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dim line as global
ReadFile>C:\Users\nvbautr\Documents\test1.txt,strFileContents
Let>k=1
While>line<>##EOF##
//ReadLn>C:\Users\nvbautr\Documents\test1.txt,k,line
if>line<>##EOF##
MouseMove>352,465
LClick
Wait>2
SendText>line
SetFocus>Schedule Class Meetings - Internet Explorer
CapsOff
Press Enter
Wait>2
MouseMove>518,110
LClick
Press Tab
MouseMove>45,434
LClick
Endif
let>k=K+1
EndWhile
Read a text file
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Read a text file
You need to increment the line counter:
Let>k=k+1
But I would read a text file like this:
Let>k=k+1
But I would read a text file like this:
Code: Select all
ReadFile>filename,text
Separate>text,CRLF,lines
If>lines_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>line=lines_%k%
Until>k=lines_count
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Read a text file
Thanks for the answer, and I have tried, but it does not read the file line. If I provide the specifics maybe you will be able to help me further.
I have a form on a web page, where I have to put some information in order to search. The information is on a text file, here is the sample of the text
123456
234567
987456
234590
So, the script have to be able to read the text file and grab the field 12345, go to the active web page and plug it into the correct box and click search(that part is working fine), but when I run this macro I can't read 12345, it just give me line(the name of the field),then the next step once I click search is to do something, then go back to the original web page and grab the second line of the text file 234567 and do the process again, and then the third until the end. Here is the code I am using, thanks for helping.
19284 19284 119284192849284//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dim line as global
ReadFile>C:\Users\nvbautr\Documents\test1.txt,text
Separate>text,CRLF,lines
if>lines_count>0
Let>k=0
Repeat>k
let>k=k+1
Let>line=lines_%k%
MouseMove>352,465
LClick
Wait>2
SendText>line
SetFocus>Schedule Class Meetings - Internet Explorer
CapsOff
Press Enter
Wait>2
MouseMove>518,110
LClick
Press Tab
MouseMove>45,434
LClick
Until>k=lines_count
Endif
I have a form on a web page, where I have to put some information in order to search. The information is on a text file, here is the sample of the text
123456
234567
987456
234590
So, the script have to be able to read the text file and grab the field 12345, go to the active web page and plug it into the correct box and click search(that part is working fine), but when I run this macro I can't read 12345, it just give me line(the name of the field),then the next step once I click search is to do something, then go back to the original web page and grab the second line of the text file 234567 and do the process again, and then the third until the end. Here is the code I am using, thanks for helping.
19284 19284 119284192849284//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dim line as global
ReadFile>C:\Users\nvbautr\Documents\test1.txt,text
Separate>text,CRLF,lines
if>lines_count>0
Let>k=0
Repeat>k
let>k=k+1
Let>line=lines_%k%
MouseMove>352,465
LClick
Wait>2
SendText>line
SetFocus>Schedule Class Meetings - Internet Explorer
CapsOff
Press Enter
Wait>2
MouseMove>518,110
LClick
Press Tab
MouseMove>45,434
LClick
Until>k=lines_count
Endif
- CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Re: Read a text file
FIREFIGHTER
Re: Read a text file
Thanks for the help, it worked really well.
Can you help me to read a file that contains fields separated by comas, so I can read a line get the first field, transfer to a web form, then go back and read the next field, and so forth. thanks.
Can you help me to read a file that contains fields separated by comas, so I can read a line get the first field, transfer to a web form, then go back and read the next field, and so forth. thanks.