[Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread Benoît Minisini
Hi,

I'm currently thinking about modifying/removing all Is() 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 Is() functions, and in which context?

-- 
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread Ron
On 24-11-2010 12:08, Benoît Minisini wrote:
 Hi,

 I'm currently thinking about modifying/removing all Is() 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 Is() 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.

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread richard terry
On Wednesday 24 November 2010 22:08:34 Benoît Minisini wrote:

Hi Benoit I use isDate() quite a lot, isNumber I think once

Regards
richard

 Hi,
 
 I'm currently thinking about modifying/removing all Is() 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 Is() functions, and in which context?
 

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread Bruce Bruen
On Wed, 24 Nov 2010 09:38:34 pm Benoît Minisini wrote:
 Hi,
 
 I'm currently thinking about modifying/removing all Is() 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 Is() functions, and in which context?

Benoît,

MAJOR PANIC!  I use IsNumber extensively to do quick checks on field parsing 
across heterogeneous databases.  Using the 80-20 rule I can parse text fields 
for junk appendices to an expected numeric. 
Code such as 

vItem=split(result!note, ,NULL,TRUE)[0]
   IF IsNumber(vItem) THEN RETURN Val(vItem)
' else begin parsing diabolical note structure
.

abounds.

Please reconsider this.

-- 
best regards
Bruce Bruen

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread Rolf-Werner Eilert
Am 24.11.2010 12:08, schrieb Benoît Minisini:
 Hi,

 I'm currently thinking about modifying/removing all Is() 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 Is() functions, and in which context?


I just checked it. As far as I remember and due to my search within my 
most important projects, I have only used IsNull so far.

In one project, I used it very often to manage Val() because Val() 
doesn't understand empty strings or strings without numbers. Wasn't it 
you or Fabien who once pointed me to this fact and gave me the tip to 
use IsNull for it?

In that project there are lots of places where wrong inputs could occur, 
so there are lots of IF IsNull(bla) THEN RETURN bullshit or IF NOT 
IsNull(bla) THEN RETURN Val(bla) ;-)

So from my point of view, if you let be Val() less critical, you my 
discard IsNull, otherwise leave it there or replace it by something useful.

Regards

Rolf


--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread Benoît Minisini
If I understand you right,
   If Not IsDigit(TextBox.Text) Then...
wouldn't be changed?

No. All IsXXX() functions that just test characters won't be changed.

-- 
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Removing / Modifying IsXXXX() functions in Gambas 3

2010-11-24 Thread Michael
Benoit,
The IsXXX functions confused me because when testing IsNumber(123) I 
got an error similar to Expected number got a string. It seems you 
needed to know the type before testing for it. I therefore do not use 
it. However I believe new versions of software should be backward 
compatible so I suggest giving the new functions a slightly different 
name. EG: IsNumeric.
Regards
Mike
On 24/11/10 22:08, Benoît Minisini wrote:
 Hi,

 I'm currently thinking about modifying/removing all Is() 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 Is() functions, and in which context?


--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user