Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DO or If
Message
From
09/09/2004 22:03:31
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
09/09/2004 21:46:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00940916
Message ID:
00940917
Views:
18
>I think I'm close, I need to do a check before continue on to next step, if I use a Do while I get into a loop I can't get out of and if I use IF it continues on.
>
>I have a start date that needs to greater than the end date so here are the ways of written:
> Thanks
>
>if startdate > enddate then
> messagebox("whatever...)
>endif
>
>do while startdate > enddate
> messagebox("whatever...)
> loop
> exit
>enddo
>
LOOP or EXIT will go to the beginning, or after the end, of a DO WHILE, but not of an IF. You can have IF within DO WHILE:
do while (some condition)
  aaa
  bbb
  ccc
  if (some other condition)
    exit && or loop
  endif
  ddd
  eee
  fff
enddo
Here, EXIT will go after the ENDDO, and DO WHILE will go back to the DO WHILE immediately.

In some cases, when you have more complicated logic (for example, nested DO WHILEs), you may need to set flags (logical variables), which you check later.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform