Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EVL and NVL
Message
From
19/05/2004 09:12:51
 
 
To
18/05/2004 21:04:17
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00905138
Message ID:
00905237
Views:
15
Hi Hilmar,
I think EVL() is most often used to substitute a value instead of an empty value. From VFP8 help:


Returns a non-empty value from two expressions.

You can use the EVL( ) function to return an appropriate substitute value instead of an empty value, such as False (.F.) or 0, from two expressions. You can also use this functionality to remove empty values from calculations or operations where empty values are not supported or relevant.

Note The Visual FoxPro Logical value, False (.F.), and the Numeric value of 0 also evaluate to empty.
EVL( eExpression1, eExpression2 )

Return Values
Character, Date, DateTime, Numeric, Currency, Logical, Object reference. EVL( ) returns eExpression1 if it does not evaluate to an empty value; otherwise, it returns eExpresssion2.


>Thanks. I don't have it, so it must be new in version 7 or 8.
>
>As a workaround, of course you can make your own version of nvl(), which you might call MyNvl() (using iif(), or if), but this will be less efficient than a built-in function.
>
>>evl() is the best function ever! Tests for empty value, eg
>>
>>procedure test
>>lparameter tcMsg
>>local cMsg
>>cMsg= evl(m.tcMsg, 'Hey you')
>>wait window m.cMsg
>>

>>
>>>I hadn't noticed this, since I don't use nvl() with function or that sort of stuff. But yes, this goes contrary to my expectations, and I had to test it myself in order to believe it! (VFP 6). And yes, iif() - like AND, and OR - only evaluates an expression if it is necessary to do so. I hadn't tested that previously, either.
>>>
>>>I tested nvl(). What does evl() do? It doesn't seem to be available in VFP 6.
>>>
>>>>Yikes!
>>>>Both these function evaluate the second parameter regardless. This goes against the "feel" of everthing else in the language (eg IIF())
>>>>
>>>>eg.
>>>>? nvl('x', temp())
>>>>
>>>>procedure temp
>>>>wait window 'hi'
>>>>

>>>>
>>>>will run temp!
>>>>I don't like it. :-(
>>>>It takes away a lot of the usefulness of the evl and nvl functions - which I otherwise just love.
>>>>
>>>>Hey MS - Any plans to change of "fix" this.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform