Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking variables value sequence
Message
From
20/01/2008 21:43:53
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
20/01/2008 18:48:53
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01283482
Message ID:
01283513
Views:
13
>>I have
>>
>>price1, price2, price3, price4
>>
>>They must be filled by the user in growing sequence as in the example below:
>>
>>5.00, 7.00,8.50,10.00
>>
>>or
>>
>>1.00, 100.00,1000.00,5000.00
>>
>>etc
>>
>>It must be wrong if any variable is not according to the rule, as below:
>>
>>4.50, 7.00,3.00,10.00
>>
>>The message ("price 3 is incorrect") must be shown
>>
>>Seems simple task, but I tried using < and > and could not
>>achieve a satisfatory result
>
>IF Price2 > Price1 AND Price3 > Price2 AND Price4 > Price3
>  * Everything is OK
>
>ELSE
>  DO CASE
>  CASE NOT Price2 > Price1
>    =MESSAGEBOX( "Price 2 is incorrect" )
>
>  CASE NOT Price3 > Price2
>    =MESSAGEBOX( "Price 3 is incorrect" )
>
>  CASE NOT Price4 > Price3
>    =MESSAGEBOX( "Price 4 is incorrect" )
>
>  ENDCASE
>
>ENDIF
>
Or use an OTHERWISE instead of the IF: if none of the error conditions is correct, then everything is OK.
DO CASE
CASE NOT Price2 > Price1
  =MESSAGEBOX( "Price 2 is incorrect" )
CASE NOT Price3 > Price2
  =MESSAGEBOX( "Price 3 is incorrect" )
CASE NOT Price4 > Price3
  =MESSAGEBOX( "Price 4 is incorrect" )
OTHERWISE
  * Everything is OK
ENDCASE
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