[Gambas-user] isNull()
Fabien Bodard
gambas.fr at ...626...
Thu Nov 25 09:40:59 CET 2010
Le 25 novembre 2010 00:31, Benoît Minisini
<gambas at ...1...> a écrit :
>> I use IsNull extensively, is that going to be removed?
>>
>> richard
>>
>
> No. I use it extensively too.
>
> Here is the result of my thought:
>
> - You can know the datatype of a variant with the TypeOf() function. You don't
> have to use the current IsXXXX() functions.
>
> - But you often need to know if a string can be converted to a number, an
> integer, a float, a date.
>
> - You normally want to know that for localized strings get from the outside
> (i.e. the user). For non-localized strings, they are intern to your program,
> so you should know what you are doing.
>
> So:
>
> IsNull(x) -> kept its behaviour.
> IsInteger(x) -> If Val(x) returns an integer
> IsFloat(x) -> If Val(x) returns a float
> IsDate(x) -> If Val(x) returns a date
hum ... isBinary ?
but how do you test if it's not ?
i imagine it is taht :
Function isFloat(Value as variant) as Float
dim fValue as Float
fValue = Val(Value)
if not error then return fValue
end
but in the other side i need to test it :/ again
if isFoat(Value) then print isFloat(Value)
in fact there is not fabulous soluce as we need two thing, known if a
convertion is possible with this datatype and then get the value.
the only one soluce i see is the C way... with a byref value
Function isFloat(Value as variant, Byref Ret as Float) as Boolean
dim fValue as Float
fValue = Val(Value)
if not error then
Ret = fValue
Return True
endif
return
end
Dim fRet as Float
If IsFloat(Value, ByRef fRet) then Print fRet
>
> They should be enough. But I could add:
>
> IsLong(x) -> If Val(x) returns a Long
> IsSingle(x) -> If Single(x) returns a Single.
>
> Regards,
>
> --
> Benoît Minisini
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Fabien Bodard
More information about the User
mailing list