Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there an IsAlpha function in QB64PE?
#6
https://qb64phoenix.com/qb64wiki/index.p...s_and_Subs

It would be pretty easy to invent BASIC functions out of the C library ones in "ctype.h" header file.

Otherwise:

Code: (Select All)
DIM character AS INTEGER, somestring AS STRING, someposition AS LONG
character = ASC(somestring, someposition)
SELECT CASE character
CASE 44 TO 46, 48 TO 57
'(is a number)
'would have to check if plus or minus is the first character
'would have to check if there is only one of plus, minus or period
CASE 65 TO 90, 97 TO 122
'(is a letter)
CASE ELSE
'(is neither number nor letter)
END SELECT

(Declares AS INTEGER instead of AS _BYTE or AS _UNSIGNED _BYTE because those pesky negative numbers would have to be clamped away and other such calculations.)

EDIT: Added "CASE ELSE" so it could be put inside a function which should have extensive checks for number's sake, since that is more demanding than doing it to an ordinary English word apart from @#%& or other such gibberish. Smile
Reply


Messages In This Thread
RE: Is there an IsAlpha function in QB64PE? - by mnrvovrfc - 04-01-2023, 02:44 AM



Users browsing this thread: 2 Guest(s)