Problem with separate command - second iteration bombs

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gjones0316
Newbie
Posts: 5
Joined: Tue Jul 26, 2005 3:24 am

Problem with separate command - second iteration bombs

Post by gjones0316 » Wed Jun 28, 2006 11:04 pm

My script is reading a delimited file (| is the delimiter, but it's the same if I use ;, etc.). I am using the Repeat/Until commands to iterate. The script works fine on the first iteration, but then crashes on the second. When it reads the next line, I am getting a Macro Scheduler error that reads "| not appropriate" - as if suddenly it doesn't like the delimiter.

Here is the script:

// C:\Program Files\MJT Net Ltd\Macro Scheduler\AcctgUnit.scp
// Recorded on Wednesday, June 28, 2006, at 03:35 PM

// Run program and wait for it to be active
Change Directory>C:\Program Files\Internet Explorer
Run Program>C:\Program Files\Internet Explorer\IEXPLORE.EXE
Wait>5

// Ensure it always opens with the same dimensions
MoveWindow>My Yahoo! - Microsoft Internet Explorer,-4,-4
ResizeWindow>My Yahoo! - Microsoft Internet Explorer,1032,742

// Focus the app
SetFocus>My Yahoo! - Microsoft Internet Explorer

//Recorded Events
Let>WW_TIMEOUT=5

Wait>1
Press Tab
Send>http://mysite
Wait>.5
Press Enter
WaitWindowOpen>Lawson Portal*


//Log in

Wait>3
Send>User1
Wait>0.28
Press Tab
Wait>1.63
Send>Password1
Wait>0.2
MouseMove>502,504
Wait>1.4
Press Tab
Wait>0.55
Press Enter
Wait>5.09
Press Tab
Wait>2.19
Press Shift
Press Tab * 8
Wait>0.06
Release Shift
Wait>2.63
Send>GL20
Wait>0.98
Press Enter
Wait>3.08

//Begin iteration
Let>k=0
Repeat>k
Let>k=k+1
MouseMove>864,165
Wait>1
Press Enter>
Wait>1
ReadLn>c:\temp\AcctgUnits.txt,%k%,DataLine
Wait>1
Separate>%DataLine%,|,DataField
Wait>1
Let>AUNumber=%DataField_1%
Let>AUDescription=%DataField_2%
Let>AULevel=%DataField_3%
MouseMove>531,239
Wait>.5
LClick
Wait>.5
Send>4321
Wait>0.38
Press Tab
Wait>0.04
Send>222222
Wait>1

//Click Inquire button
MouseMove>429,191
LClick
Wait>3

//Click on Accounting Unit field
MouseMove>530,260
Wait>1
LClick
Wait>1
Send>%AUNumber%
Wait>0.31
Press Tab
Wait>0.41
Send>%AUDescription%
Wait>1.09

//Click on Levels tab
MouseMove>308,295
Wait>1
LClick
Wait>2

//Click on Level 3 field
MouseMove>598,458
Wait>1
LClick
Send>%AULevel%
Wait>0.3
Press Tab
Wait>0.69

//Click on Add Button
MouseMove>267,195
Wait>1
LClick
Wait>4
GetDate>date
GetTime>time
WriteLn>c:\temp\AUSuccess.txt,result,%k%,%date%,%time%,%AUNumber%,%AUDescription%
Wait>1
//Loop back
Until>DataLine=##EOF##
Wait>1
CloseWindow>Lawson Portal*

gjones0316
Newbie
Posts: 5
Joined: Tue Jul 26, 2005 3:24 am

Version info

Post by gjones0316 » Wed Jun 28, 2006 11:05 pm

I am using 7.3.11.4

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Jun 28, 2006 11:58 pm

I think there is a potential problem with your script because it doesn't check for the EOF marker before it tries to extract the data. I suggest you restructure the loop like this example from the help which checks for end of file before it tries to process the line.

Let>k=1
Label>start
ReadLn>c:\temp\test.txt,k,line
If>line=##EOF##,finish

//do the processing here

Let>k=k+1
Goto>start
Label>finish

gjones0316
Newbie
Posts: 5
Joined: Tue Jul 26, 2005 3:24 am

Post by gjones0316 » Thu Jun 29, 2006 11:37 am

Me_again, I made the change you suggested, and the script works great now! Thank you!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts