Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I return to the top of a DO CASE?
Message
From
27/04/1998 22:25:11
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00095239
Message ID:
00095282
Views:
26
>>>>How do I LOOP back to the top of a DO CASE while I am still
>>>>in the DO CASE?
>>>I don't know if I exactly understand the problem but...You do realize that the only case statement that is executed is the first one that returns .T. so if you can order the case statements so that they are in the order you want the to execute might help.
>>---
>>Hi Sammie
>>I want to return to the top of the DO CASE like I do in the DO WHILE .T.... there I use LOOP. Is there a LOOP for DO CASE?
>
>"DO CASE" is not a looping structure, thus no loop statement.
>
>Here is the syntax from the VFP Help file:
>Syntax
>
>DO CASE
> CASE lExpression1
> Commands
> [CASE lExpression2
> Commands
> ...
> CASE lExpressionN
> Commands]
> [OTHERWISE
> Commands]
>ENDCASE
>
>You will need to add extra logic or another CASE expression to do what you are trying to accomplish.

I think you may use wrong logic. You want the program testing all the cases
one by one, if out of above case do other job! So, using a stand simple non-nested if..endif statement with a flag to carry out of above case is done!!
PassFlag = .F.
IF lExpression1
  Commands
  PassFlag = .T.
EndIF
IF lExpression2
  Commands
  PassFlag = .T.
EndIF
IF lExpression3
  Commands
  PassFlag = .T.
EndIF
IF lExpression4
  Commands
  PassFlag = .T.
EndIF
* OUT OF Above CASES!!
IF PassFlag = .F.
  * do otherwise coding here!!
ENDIF
Or you can use this, but more hard to understand!
PassFlag = -1
do while PassFlag <> 0
do case
case lExpression1 And PassFlag < 1
   commands
   PassFlag = 1  && Preventing to run this part when 2nd loop
   LOOP          && Back to Do While again
case lExpression2 And PassFlag < 2
   commands
   PassFlag = 2  && Preventing to run this part when 2nd loop
   LOOP          && Back to Do While again
case lExpression3 And PassFlag < 3
   commands
   PassFlag = 3  && Preventing to run this part when 2nd loop
   LOOP          && Back to Do While again
...
OtherWise
  PassFlag = 0  && 
EndDo
2nd Version is Poor because it do (1+2+3+...+n)*2 comparasion + .and. gate logic
The performance is poor but you need to modify less coding!

1st Version is Perfect because it do n+1 comparasion.
I suggest you to use 1st version. More easy to maintain and fast in performance

2nd Version is only a concept to work as you desire but surely not good even work! if you can find any method or logic better than it. Tell me! ^_^;
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform