Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
From
31/05/2001 17:06:50
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00513446
Views:
13
Nadya --

>> The general guideline I use is this:
>>
>>1. If the loop is based on a specific number of operations, I use FOR..NEXT.
>>

>Jay, this loop uses a counter, that's why I used for next loop. All loops should be terminated, if user decides to esc, so I had to put exit in each inner loop, which uses for next construct. I asked this question here while ago and this was the advice I got, so I scaned through the code and did it.

As you say, you can do the same processing using a DO WHILE and a FOR..NEXT with an EXIT. In a sense, it's a different style but the same substance.

Your example addresses exception handling, rather than regular processing, so I think you could make a good argument either way.

But, as I use these guidelines, they're part of a larger approach to programming.

I find that logical values are very useful in a variety of ways:
1. They only have 2 values, so they're easy to master!
2. They help me think through the actual process that I'm programming.
3. When I use them, move the program towards self-documentation.

Now, regarding the particular instance of FOR..NEXT/DO WHILE.

A DO WHILE puts all conditions in the condition clause -- so it's clear what issues are being tested for. By looking at one line, I get a feel for what the whole routine does. On the other hand, in a FOR..NEXT situation with a variety of EXITS, I have to look through the entire routine to make sure that grasp what it's doing.

I think it makes a more readable program -- but, that's IMHO%).



>>2. If the loop is based on a specific condition, I use DO WHILE.
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform