Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Who'd have thought....
Message
From
02/11/1999 10:57:26
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00285125
Message ID:
00285481
Views:
17
Jim-

>Partially correct, the FOR loop will execute at least once under all conditions. You cannot create a FOR loop that won't run once.

I often rely on a FOR loop to not execute, such as when I've called a function that returns a number (like ASCAN, or AFIELDS, whatever). For example, I made a prg called testy.prg with the following:
SET PROCEDURE TO testy.prg
x = doNothingMuch(0)

FUNCTION DoNothingMuch
LPARAMETER tnNumLoops
LOCAL lni

tnNumLoops = IIF( VARTYPE( tnNumLoops ) = "L", 0, tnNumLoops )

FOR lni = 1 TO tnNumLoops
  WAIT WINDOW "You asked for " + LTRIM( STR( tnNumLoops ) ) + "(" + LTRIM( STR( lni ) ) + ")"
NEXT lni
Previous
Reply
Map
View

Click here to load this message in the networking platform