File size check only runs once in a loop??

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
brad

File size check only runs once in a loop??

Post by brad » Fri Jun 25, 2004 8:17 pm

Hello,

Now another problem i'm having is that the filesize check that i'm using only checks the filesize only once in the loop. The loop is acutally 3 loops each varying its own variable, so the total loop is somthing like 600 iterations.

The problem i'm having is that sometime the program i'm using screws up and returns no data. To solve this problem the program must be restarted, and the same data must be ran again. I'll post the code in question, then the whole code for review.


// Parameters
CAPSOFF
Let>dstart=0
Let>dinc=.5
Let>dmax=1

Let>Rstart=5
Let>Rinc=12.5
Let>Rmax=42.5

Let>zstart=1
Let>zinc=1
Let>zmax=50

Let>range=Rstart
Repeat>range

Let>dist=dstart
Repeat>dist

Let>depth=zstart
Repeat>depth


SetFocus>PC SWAT - [PCSWAT1]
Wait>0.25
Let>total_range=%range%+%dist%
IfDirExists>C:\NAME REMOVED\%total_range%,runit,makeit
Label>makeit
CreateDir>C:\NAME REMOVED\%total_range%
Label>runit
SetFocus>PC SWAT - [PCSWAT1]
// ---------------------------------------------------------
// Opens the forward time series dialog box and then modifies the range/depth settings
Press ALT
Send Character/Text>g
Release ALT
Press Up
Press Right
Press Enter
WaitWindowOpen>Forward Time Series
SetFocus>Forward Time Series
MouseMoveRel>340,60
LClick
Wait>0.15
Press Backspace
// This next send character refers to the range to target.
Send Character/Text>%total_range%
Press Tab
Press Tab
Press Tab
Send>%depth%
Press Tab
Send>%depth%
Wait>0.15
MouseMoveRel>250,60
LClick
Wait>0.15
Press Backspace
Send>127000
Press Tab
Press Backspace
Let>min_time=%total_range%/1500
Let>min_time=%min_time%-0.004
Send>%min_time%
Wait>0.15
Press Enter
// ---------------------------------------------------------

SetFocus>PC SWAT - *

// ---------------------------------------------------------
// This is where we run the simulation
Wait>0.25
Press ALT
Send>r
Press Up * 5
Press Enter
Press Down
Press Right
Press Enter
WaitWindowOpen>PC SWAT
SetFocus>PC SWAT - *
Clo>PC SWAT
Clo>Progress
// ---------------------------------------------------------

SetFocus>PC SWAT - *
Wait>0.25
// ---------------------------------------------------------
// This is where we save the simulation data

Press ALT
Send>c
Release ALT
Press Up * 3
Press Enter
Press Down
Press Enter
Press Enter
WaitWindowOpen>Save As

Let>filename=C:\NAME REMOVED\%total_range%\%total_range%.%depth%.dat

//Delete the file if it already exists
IfFileExists>filename,fileexists
Goto>savefile

Label>fileexists
DeleteFile>filename

//Send the filename to the Save As dialog
Label>savefile
SetFocus>Save As

Send>C:\NAME REMOVED\%total_range%\%total_range%.%depth%.dat
Wait>0.25
Press Enter
// ---------------------------------------------------------
Wait>0.15
FileSize>%filename%,size
MessageModal>%size%
If>%size%start_sim
let>msg=%total_range%.%depth%
Let>MSG_STAYONTOP=1
msg>%msg%
Let>depth=depth+zinc
Until>depth,zmax

Let>dist=dist+dinc
Until>dist,dmax

Let>range=range+Rinc
Until>range,Rmax


// Closes the swat window and then re-opens it and reloads the file
SRT>open_swat
GoSub>focus_swat
Press ALT
Press F4
Release ALT
WaitWindowClosed>PC SWAT -*
Run Program>C:\Program Files\PCSWAT80\PCSWAT80.exe
WaitWindowOpen>PC SWAT -*
msg>Swat reopened
goto>runit
End>open_swat

// focus swat

SRT>focus_swat
SetFocus>PC SWAT - *
End>focus_swat


Now I've set the code to pause with a message modal and display the filesize of the last file in question, but it only processes the first iteration.

Here is the code i wrote for file size check:
FileSize>%filename%,size
MessageModal>%size%
If>%size%start_sim
let>msg=%total_range%.%depth%
Let>MSG_STAYONTOP=1
msg>%msg%

Plus the sub routines it calls:
// Closes the swat window and then re-opens it and reloads the file
SRT>open_swat
GoSub>focus_swat
Press ALT
Press F4
Release ALT
WaitWindowClosed>PC SWAT -*
Run Program>C:\Program Files\PCSWAT80\PCSWAT80.exe
WaitWindowOpen>PC SWAT -*
msg>Swat reopened
goto>runit
End>open_swat

// focus swat

SRT>focus_swat
SetFocus>PC SWAT - *
End>focus_swat


Oh and my mouse scroll wheel doesn't work in the script editor. What a pain. (its a M$ intellimouse explorer wireless)

Do you have the style template for editplus 2?? That would be very helpful as well. Thanks

Brad

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jun 25, 2004 9:20 pm

I seem to recall having to modify some FileSize> scripts to check for "File Not Found" before I checked for size. Before doing this, I had some sporadic errors.

Something like this:
Label>TestSize
FileSize>%filename%,size
If>%size%=File Not Found,NoFile
If>%size%NoFile
MessageModal>File named %filename% not found.%CRLF%We can try again.
Ask>Do you want to try again?,ReTry
If>%ReTry%=YES,TestSize

Label>End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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