Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many CASEs in DO CASE?
Message
From
01/06/2006 23:35:35
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01126584
Message ID:
01126659
Views:
18
I would guess execution can be slowed down (especially if it is executed many times), because there is no way for VFP to optimize, and directly jump to a specific case. It has to test every case individually. Perhaps a hierarchical search can improve speed, something like this:
case nVar < 10
  do case
  case nVar = 1
    ...
  case nVar = 2
    ...
case nVar < 20
  do case
  case nVar = 11
    ...
  case nVar = 12
    ...
...
>Is there a limit on number of CASEs can be in a DO CASE?
>
>If your DO CASE involves a large number of CASEs (say several hundred), is it faster to do CASE on a numeric comparison or a character? For example:
>
>
>nVar = 3
>do case
>   case nVar = 1
>
>   case nVar = 2
>* and so on
>endcase
>
>* vs.
>cVar = "3"
>do case
>   case nVar = "1"
>
>   case nVar = "2"
>* and so on
>endcase
>
>
>Thank you.
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