[Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3
Ron
ron at ...1740...
Wed Nov 24 12:18:32 CET 2010
On 24-11-2010 12:08, Benoît Minisini wrote:
> Hi,
>
> I'm currently thinking about modifying/removing all IsXXXX() functions in
> Gambas 3.
>
> They mainly test the datatype of their expression. So, either the datatype is
> known at compile time, and there should be no need of testing it ; either you
> are using a Variant, and you can use TypeOf() to get the datatype of the
> value.
>
> I will replace them by some functions that will test if a value can be
> converted safely from a string by using localization. This is what most users
> expected from these functions.
>
> For exemple, in french localization:
>
> IsDate("13/2/20") -> True
> IsNumber("3,34") -> True
> IsInteger("3,34") -> False
> IsNumber("3.34") -> False
>
> Internally, they will use Val() and see if the conversion works.
>
> I will kept most of the name, so there will be a big incompatibility between
> Gambas 2, current Gambas 3, and final Gambas 3.
>
> What do you think about that?
>
> Who is using the IsXXXX() functions, and in which context?
>
I use these in my project, a lot less than expected at first:
Bluetooth.module: IF IsInteger(Val(sRSSI)) THEN
Bluetooth.module: iRSSI = IsInteger(Val(sRSSI))
Events.module: IF rResult!rerunenabled = TRUE AND IF
IsDate(rResult!lastrun) THEN
Events.module: IF IsBoolean(sValue) THEN sValue = Main.DisplayBool(sValue)
Events.module: IF IsBoolean(sCond) THEN sCond = Main.DisplayBool(sCond)
Events.module: ELSE IF IsBoolean(vResult) THEN
JSON.module: IF NOT IsLetter(sCar) THEN RETURN sCar
JSON.module: IF NOT IsLetter(sCar) THEN
JSON.module: IF IsNull(vNumber) THEN Error.Raise("Incorrect number")
JSON.module: ELSE IF sCar = "-" OR IF IsDigit(sCar) THEN
Mail.module: IF IsString(Main.GlobalVar["Minute"]) THEN
Main.GlobalVar["Minute"] = Val(Main.GlobalVar["Minute"])
Main.module: IF NOT IsNull(vValue) THEN
Main.module: IF IsNumber(Val(tv[k, col].Text)) THEN
Main.module: IF IsNumber(Val(gv[k, col].Text)) THEN
Main.module:PUBLIC FUNCTION IsTime(sString AS String) AS Boolean
Main.module:PUBLIC FUNCTION IsBool(sStr AS String) AS Boolean
CDenon.class: IF IsInteger(sValue) THEN
CDenon.class: IF IsInteger(sValue) THEN
CDenon.class: IF IsNull(Val(sZonecat)) THEN
CRFXComRX.class: IF IsDigit(Hex(RecBuf[4])) AND IF
IsDigit(Hex(Lsr(RecBuf[3], 4))) THEN
CSqueezeServer.class: ELSE IF IsLetter(sCar) OR IF IsDigit(sCar) OR
IF InStr("*-._", sCar) THEN
FConditionEditor.class: IF NOT
(Main.IsBool(Events.EvalFormula(taFormula.Text))) THEN
FConditionEditor.class: IF IsBoolean(vVal) THEN
FDebug.class: IF IsBoolean(vValue) THEN
FTriggerEditor.class: IF IsBoolean(Main.GlobalVar[cmbVariables.Text])
THEN
FTriggerEditor.class: ELSE IF NOT
IsNumber(Main.GlobalVar[cmbVariables.Text]) THEN
FTriggerEditor.class: IF IsNumber(Val(txtDeviceValue.Text)) THEN
Regards,
Ron_2nd.
More information about the User
mailing list