Looping Test - Works Sometimes

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

kriemer
Pro Scripter
Posts: 57
Joined: Fri Oct 30, 2009 2:59 pm

Post by kriemer » Wed Mar 23, 2011 5:12 pm

I don't know how I lost it in the code I copied but I have a wait statement just before the "//"Kill" RunProject.exe" portion of the script.

I apologize for this error and wasting peoples time on the code which was not accurate.

Correct code follows:
//Variables
Let>loopcounter=-1
GetDate>vToday
Let>Missing1=FAILED On Loop 0 - Retry:%CRLF%
Let>Missing2=Files Missing:%CRLF%
Let>Path=Z:\VWR
Let>RuntimeHr=0.03
Let>RunTimeMin=RunTimeHr*60
Let>RunTimeSec=RunTimeMin*60
Let>LoopMax=1
Let>LoopTill=LoopMax+1
Let>LogFileLines=-100
Let>SizeLogFile=50000
Let>LogFile=%Path%\Log\VWR.Log

/*=============================================*/

//Delete VWR Output Files
DeleteFile>%Path%\Output\R*.*
DeleteFile>%Path%\Output\Y*.*
DeleteFile>%Path%\Output\Interactive*.*
Wait>10

//Trim VWR Log File to Last "n" Lines - Note: Tail.exe is saved in "C:\Windows\addins\" Directory
FileSize>%Path%\Log\VWR.Log,LogFileSize
If>LogFileSize>%SizeLogFile%
Let>RP_WAIT=1
Run>cmd.exe /c C:\Windows\addins\tail.exe %LogFileLines% "%Path%\Log\VWR.Log">"%Path%\Log\VWR TEMP.Log"
DeleteFile>%Path%\Log\VWR.Log
RenameFile>%Path%\Log\VWR TEMP.Log,%Path%\Log\VWR.Log
Let>RP_WAIT=0
endif

Repeat>loopcounter

Label>TestForProcessComplete
ProcessExists>RunProject.exe,vProc_var
If>vProc_var=True
Wait>0.1
Goto>TestForProcessComplete
EndIf


//Close Message Window
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
endif>

//Test If Files Exist
IfFileExists>%Path%\Output\R_Estimates_a\R_Estimates_a_data_1.csv,,Skip
IfFileExists>%Path%\Output\R_Estimates_b\R_Estimates_b_data_1.csv,,Skip
IfFileExists>%Path%\Output\R_Estimates_c\R_Estimates_c_data_1.csv,,Skip

//Log and Exit Script If ALL Files Exist After "0" Try
if>loopcounter=0
Timestamp>LogFile,%vToday%, COMPLETED With No Errors - Yippie!!! %CRLF%
Exit>0
endif

//Log and Exit Script If ALL Files Exist After 1st -> "LoopMax" Retry
if>loopcounter>0
Timestamp>LogFile,%vToday%, COMPLETED With Errors!!! - Succeeded On Loop #%loopcounter% %CRLF%%Missing1%
Exit>0
endif

//Log and Exit Script If File(s) FAILED After "LoopMax" Retry
Label>Skip
if>loopcounter=LoopMax
Timestamp>LogFile,%vToday%, FAILED After %LoopMax% Retries!!! %CRLF%%Missing2%
MessageModal>FAILED After %LoopMax% Retries!!! %CRLF%%Missing2%
Exit>0
endif

Let>loopcounter=loopcounter+1
Let>Runcounter=loopcounter+1

//Time Calculation & Screen MessageBox - All Attempts
VBEval>DateAdd("s", %RunTimeSec%, now),LoopEndTime
Let>MSG_STAYONTOP=1
Message>Loop Run Time: %RunTimeHr% Hour(s) / %RunTimeMin% Min(s) %CRLF%Loop Completion: %LoopEndTime% %CRLF%Attempt No.: %Runcounter% of %LoopTill%

//Test & Run VWR Scrapes
IfFileExists>%Path%\Output\R_Estimates_a\R_Estimates_a_data_1.csv
//Do nothing
else
run>"C:\Program Files\VWR\RunProject.exe" "%Path%\Projects\R Estimates a.rip"
if>loopcounter>0
Let>Missing1=%Missing1%(%loopcounter%)R Estimates a %CRLF%
endif>
if>loopcounter=LoopMax
Let>Missing2=%Missing2%- R Estimates a %CRLF%
endif
endif

IfFileExists>%Path%\Output\R_Estimates_b\R_Estimates_b_data_1.csv
//Do nothing
else
run>"C:\Program Files\VWR\RunProject.exe" "%Path%\Projects\R Estimates b.rip"
if>loopcounter>0
Let>Missing1=%Missing1%(%loopcounter%)R Estimates b %CRLF%
endif
if>loopcounter=LoopMax
Let>Missing2=%Missing2%- R Estimates b %CRLF%
endif
endif

IfFileExists>%Path%\Output\R_Estimates_c\R_Estimates_c_data_1.csv
//Do nothing
else
run>"C:\Program Files\VWR\RunProject.exe" "%Path%\Projects\R Estimates c.rip"
if>loopcounter>0
Let>Missing1=%Missing1%(%loopcounter%)R Estimates c %CRLF%
endif>
if>loopcounter=LoopMax
Let>Missing2=%Missing2%- R Estimates c %CRLF%
endif
endif

//Pause Loop
wait>RunTimeSec


//"Kill" RunProject.exe
VBSTART
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process where name = 'RunProject.exe'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
VBEND

//Loop Script "n" Times
Until>loopcounter=LoopTill
Very sorry again,

EDIT!!!

Is it possible that have a long string name in the test area can somehow confuse the script from executing properly?

This line:
"IfFileExists>%Path%\Output\R_Estimates_\R_Estimates_c_data_1.csv,,Skip" is actually longer in the actual script; ~110 characters. I have truncated the path name and the script seems to execute properly now. Strange???


Again, Thank you all.

k

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Mar 24, 2011 3:28 am

So are you satisfied with the way things are working now? As a generality, I don't believe string length even in the hundreds of thousands of characters will affect a script but there is a path length limit imposed by Microsoft

kriemer
Pro Scripter
Posts: 57
Joined: Fri Oct 30, 2009 2:59 pm

Post by kriemer » Thu Mar 24, 2011 4:02 pm

After a dozen consecutive runs with no failures (I hate saying that as it is typically the tipping point where things go wrong), I can say I'm happy with the working of the script. Hopefully I won't have to come back with a new request for help.

I don't think it is the MS path string limit (255 characters) as that was not near to being reached and the "IfFileExists>" group of tests which address the same string in the lower portion of the script worked.

I do wish I could understand the issue behind this "fix", but have come to reconcile myself with my considerable limitations.

Again, I thank you all for your help.

k

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