Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

while loop

Status
Not open for further replies.

Matta25

Technical User
Jan 6, 2004
82
US
I have this script:
copyfile micsfile1 miscfile2
while findfirst miscfile2
if not isfile "comport1.res"
(do process)
delfile miscfile2
else if not isfile :comport2.res"
(do process)
delfile miscfile2
end if
endwhile

Is there a way to tell the loop to only loop fo say 50 time?
Thanks
 
You could initialize an integer variable to 1 before the while loop, then at the end of the while loop increment the loop by using the ++ operator (say your variable was called iLoop, then the command would read iLoop++). Right after that, you would want these lines:

if iLoop == 50
exitwhile
endif

This code tells the script if iLoop is 50 (meaning it is the 50th execution of the while loop), then exit the while loop completely. Depending on what you are doing in the loop, you may need some additional cleanup code (such as closing files, etc.) in the above if clause.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top