[Gambas-user] Why is val() so roundabout?

Eldon Eller eeller at ...826...
Wed Jun 22 21:13:08 CEST 2005


I cannot speak for Benoit, but it seems like a good idea to me. There is a 
distinct difference between zero and nothing. For example, suppose you are 
calculating the average of a bunch of numbers, and that one or more of them are 
missing. In that case, you want to skip them, not just stuff in zeros.

Perhaps Benoit has a better answer. Mine is strictly an amateur opinion.

Eilert wrote:
> This is a good idea, although it takes yet another function to 
> implement. Checking with IsNull() is a way I didn't see.
> 
> But why did Benoit implement val() this way? I don't see any sense in 
> it, but there might be one (I'm not a professional programmer after all).
> 
> Rolf
> 
> 
> Rob schrieb:
> 
>> On Tuesday 21 June 2005 11:54, Eilert wrote:
>>
>>> One thing that really is uncomfortable in Gambas is that val() does
>>> not only return Zero when there is nothing to do, but Null.
>>
>>
>>
>> In some other language (might have been VB, might not have), I got 
>> around this by writing a ValNoNull sub, something like this:
>>
>> PUBLIC FUNCTION ValNN(instring as String) as Float
>>
>>   IF IsNull(val(instring)) THEN
>>     RETURN 0
>>   ELSE
>>     RETURN val(instring)
>>   ENDIF
>>
>> END
>>
>> Rob
>>
>>
>>
>>
>> -------------------------------------------------------
>> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
>> from IBM. Find simple to follow Roadmaps, straightforward articles,
>> informative Webcasts and more! Get everything you need to get up to
>> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 




More information about the User mailing list