Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Syntax for IF STATEMENTS
Message
From
04/02/2003 21:00:05
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
04/02/2003 20:48:21
Henry Ravichander
RC Management Systems Inc.
Saskatchewan, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00749162
Message ID:
00749184
Views:
26
>Hi Hilmar:
>
>>You already are using IF statements. What is it you want to accomplish? Reduce the code? Use a single nested IIF()?
>>
>Thank you for your response. I was having trouble with using the word AND in each of the statements. VFP did not like that, therefore unsure whether and can be used at all in an IF statement.

Ah, I see now.
if age => 55 and < 65
Sergey already gave you a cleaner version of your code, I will now explain, for future reference, the correct syntax you were looking for.

You are confusing with other programming languages, or systems like Excel, who permit this syntax.

The problem here is that each side of the AND statement has to be a valid statement. The left part, age => 55 is valid, although it is more customary to write this as age >= 55. The right side, < 65 is not valid - what are you comparing 65 with? I know what you mean, but VFP doesn't understand this.

The correct version is as follows:
if age >= 55 and age < 65
An expression like age >= 55 and age < = 65 can be simplified as between(age, 55, 65), but no equivalent simplification exists if one side uses greater-or-equal, and the other side only less-than, for instance.

HTH, Hilmar.
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