Restored from previous forum. Originally posted by wayne1.
;IsDigit() checks if its a digit returns 1 if it is 0 if not
;chara = character to check
Procedure.b IsDigit(chara.s)
chara = mid(chara, 1, 1);
isIt.b=0:character.b=asc(chara)
If character >= 48 And character = 97 And character = 65 And character = 65 And character = 97 And character = 65 And character = 97 And character = 48 And character <=57:isIt=1:EndIf
ProcedureReturn isIt
EndProcedure
;IsSpace() checks if character is a space character returns 1 if it is 0 if not
;chara = character to check
Procedure.b IsSpace(chara.s)
chara = mid(chara, 1, 1);
isIt.b= 0:character.b=asc(chara)
If character = 32:isIt = 1:EndIf
ProcedureReturn isIt
EndProcedure
;IsPunct() checks character if it is any keyboard character other than alphabetic
;or numeric or space returns 1 else returns 0
;chara = character to check
;NOTE This procedure requires IsSpace() and IsAlpaNum() to work
Procedure.b IsPunct(chara.s)
chara = mid(chara, 1, 1);
isIt.b=1:character.b=asc(chara)
If IsSpace(chara):isIt = 0:EndIf
If IsAlphaNum(chara):isIt = 0:EndIf
ProcedureReturn isIt
EndProcedure
cr.s=chr(13)
messagerequester("2 IsDigit()",str(IsDigit("2"))+cr+"True It's a digit",0)
messagerequester("a IsDigit()",str(IsDigit("a"))+cr+"False It's not a digit",0)
messagerequester("Q IsLower()",str(IsLower("Q"))+cr+"False it's not LC",0)
messagerequester("q IsLower()",str(IsLower("q"))+cr+"True it's LC",0)
messagerequester("Q IsUpper()",str(IsUpper("Q"))+cr+"True it's UC",0)
messagerequester("q IsUpper()",str(IsUpper("q"))+cr+"False it's not UC",0)
messagerequester("w IsAlpha()",str(IsAlpha("w"))+cr+"True it's Alphabetic",0)
messagerequester("/ IsAlpha()",str(IsAlpha("/"))+cr+"False it's not Alphabetic",0)
messagerequester("1 IsAlphaNum()",str(IsAlphaNum("1"))+cr+"True it's AlphaNumeric",0)
messagerequester("s IsAlphaNum()",str(IsAlphaNum("s"))+cr+"True it's AlphaNumeric",0)
messagerequester("< IsAlphaNum()",str(IsAlphaNum("<"))+cr+"False it's not AlphaNumeric",0)
messagerequester(" IsSpace()",str(IsSpace(" "))+cr+"True it's a space char",0)
messagerequester("w IsPunct()",str(IsPunct("w"))+cr+"False it's not Punct",0)
messagerequester("~ IsPunct()",str(IsPunct("~"))+cr+"True it's Punct",0)
Edited by - wayne1 on 12 August 2001 05:44:46
IsDigit IsAlpha IsAlphaNum etc. updated for v2.4
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Mr.Skunk.
Wayne1, you're the champion of the "Tricks 'n' Tips"...
Thanks for all.
Can i use some of your Tips for libraries Functions?
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
Wayne1, you're the champion of the "Tricks 'n' Tips"...
Thanks for all.
Can i use some of your Tips for libraries Functions?
Mr Skunk
Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
Thanks a lot for your tips, they are very valuable ! I've seen you've used the Ascii number for testing if the char was a digit. But in PureBasic you can directly use the following stuff (much faster to develop as you don't need to know all the Ascii table by heart
:
If Asc(char) >= 65
Can be changed to:
If Asc(char) >= 'A'
I hope this help !
Fred - AlphaSND
Hello Waynes,
IsAlpha() etc..
Thanks a lot for your tips, they are very valuable ! I've seen you've used the Ascii number for testing if the char was a digit. But in PureBasic you can directly use the following stuff (much faster to develop as you don't need to know all the Ascii table by heart

If Asc(char) >= 65
Can be changed to:
If Asc(char) >= 'A'
I hope this help !
Fred - AlphaSND