Welcome! Log In Create A New Profile

Advanced

W-Language IsNumeric(..)

Posted by Jimbo 
Jimbo
W-Language IsNumeric(..)
April 15, 2009 02:38PM
Hi,

recently, I mistook the W-Language command IsNumeric(..) as a function which is looking for a string being completely numeric. It is not! IsNumeric(..) simply looks whether Val(string) would return some / any numeric value. So, IsNumeric("71O00") will return True though there's a typo in it: a zero has been mistyped as an uppercase O.

Testing whether a string consists of numerics only or uppercase alpha characters only has to be done by your own functions, there's no W-Language function for it.

Test project: [www.windev.at]

Have fun!
Guenter
christoph
Re: W-Language IsNumeric(..)
April 15, 2009 05:25PM
Hi Guenter,

i think the zero / O is not the reason. If the first character is a letter then isnumeric = false, if the first character is a digit then isnumeric = true

isnumeric("123xyz") = true isnumeric("xyz123") = false
val("123xyz") = 123 val("xyz123") = 0

Have fun!
Christoph
BLS
Re: W-Language IsNumeric(..)
April 16, 2009 05:40PM
Jimbo san,
what about using regular expressions.. A simple example :
FUNCTION IsUnsignedInteger(LOCAL sNum is string)
RESULT MatchRegularExpression(sNum,  "[0-9]+" )

untested... Björn
Jimbo
Re: W-Language IsNumeric(..)
April 17, 2009 07:33AM
Quote
BLS
Jimbo san,
what about using regular expressions.. A simple example :
FUNCTION IsUnsignedInteger(LOCAL sNum is string)
RESULT MatchRegularExpression(sNum,  "[0-9]+" )

untested... Björn

Hey Bjoern, that's a very good idea! I'll try it!

Next problem is Upper(..) - I'll discuss that one today or tomorrow .. Upper("äöü") gives "AOU" as a result, not "ÄÖÜ" as it should. OK, there's a special case in German: "ß". It should be changed to "SZ" in Upper(..). Of course, Upper(..) currently works with all French accented characters. The "AOU"-result is already a 'repaired' version of Upper(..) .. omg! Upper(..) doesn't work since WD 5.5. I'll use a table-driven approach to give a chance to all languages.
Kind regards, Guenter


BLS
Re: W-Language IsNumeric(..)
April 18, 2009 02:02PM
JImbo san,
In case that you are interested in a ansi,utf8, ... string functions -upper() lower()- isnumeric() etc. library, let me know.
This lib. is written in D as DLL including a set a WD procedures which call these DLL functions.... contains also a ECMA conform. regex engine...

regex match
regex replace
+ outstanding regex stuff
takes about a week, have to wait for a D compiler update.
Björn
BLS
Re: W-Language IsNumeric(..)
April 18, 2009 02:29PM
Could not resist smiling smiley
the DLL also contains :
regex split
regexSplit() is used to split a string based on a regular expression and return the result as comma separated string.
---------------
invoking WD callback functions is also possible
Björn
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: