Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - String Functions

Author
Message
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Jul 2012 23:40 Edited at: 3rd Jul 2012 23:43
Following on from my previous thread containing functions enabling you to format strings in according to various needs (such as converting a keycode into the name of the key, or a string representation of a boolean value).

I am posting some more string functions on this page.

IsNumeric( text$ )

Returns true if the text is a number

IsAlphabetic( text$ )

Returns true if the text contains characters from A to Z

IsAlphaNumeric( text$ )

Returns true if the text contains characters from A to Z or numbers

Example:


Replace [Fast Len] with [Len] if you do not have Matrix1 utilities installed. This principle applies to similar alternative functions such as [Fast Lower$] and [Lower$].



Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Jul 2012 21:08
You can simplify those functions:




"You're not going crazy. You're going sane in a crazy world!" ~Tick
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Jul 2012 14:59 Edited at: 9th Jul 2012 15:14
Thanks Phaelax, I like how you formatted the code; many will find it best to keep the code as concise as possible.

One difference out of personal preference is that I do not like using single line IF THEN statement in DBPRO (In the same way I do not like single line if statements in Visual Basic), although slower and more wordy, I just find it more comfortable to read and amend; sometimes I like to short circuit, but again this is just personal.

Another difference is that your IsNumeric function returns false if the number is zero; but zero is a number.

Print isNumeric("0.0"); returns 0 (false)

Also

Print isNumeric("32.2.2"); returns 1 (true), but I would see this as not a valid decimal number, wouldn't you say?


The way you created the Alpha Numeric function would be better, it seems.

To all, please do not hesitate to check out the other string functions here

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jul 2012 04:37
I guess VAL was a little less accurate than I thought.

"You're not going crazy. You're going sane in a crazy world!" ~Tick

Login to post a reply

Server time is: 2024-03-28 14:44:31
Your offset time is: 2024-03-28 14:44:31