Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking variables value sequence
Message
From
21/01/2008 14:48:12
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01283482
Message ID:
01283775
Views:
12
>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
LOCAL lcPriceList, lnNum, lnNdx, lnPrice1, lnPrice2
lcPriceList = "4.50, 7.00,3.00,10.00"
lnNum = OCCURS(lcPriceList,",")
IF lnNum > 1
  lnPrice1 = VAL(GETWORDNUM(lcPriceList,1,","))
  FOR lnNdx=2 TO lnNum
    lnPrice2 = VAL(GETWORDNUM(lcPriceList,lnNdx,","))
    IF lnPrice2 <= lnPrice1
      WAIT WINDOW "Price Error"
      EXIT
    ENDIF
    lnPrice1 = lnPrice2
  ENDFOR
ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform