R. E. Cook
Contact Us 

Dr. Cook

RunningShoes Library for WinRunner 

Custom WinRunner Functions 
and Utilities,
to Your Specs

A Random Collection of WinRunner Solutions

Creating DLLs for WinRunner 
"DLLs Demystified" 
(Mercury Interactive's Worldwide Users Conference 2000)

Infinite loop: for() vs. while()


To drive an infinite loop, skip the condition, so WinRunner is not forced to evaluate it. An infinite loop will have another condition inside the loop to break the loop; why evaluate two conditions when only one matters? While speed is often not a concern in running a test script, it's still a good idea to develop the habit of writing efficient code.

The standard in C/C++ is a for loop with no condition:

for( ; ; )

WinRunner users often recommend using a condition that will always return TRUE to drive an infinite loop. One of the most common examples is this, with a while loop:


This certainly works. However, each time the while() executes, the condition must be evaluated. The for() executes more efficiently, because it has no condition to be evaluated.

Top of  This Page | R. E. Cook Home Page

Copyright R. E. Cook Consulting, 2000 - 2011.
All rights reserved.

The site is designed to look best when viewed with Internet Explorer 5.0 - 8.0. Results with other browsers will probably deviate from what is intended.

NOTE: This website refers to registered trademarks and service marks that are owned by other companies, including Mercury Interactive, WinRunner, TestDirector, TSL, Microsoft, Windows.