04-01-2023, 02:44 AM
(This post was last modified: 04-01-2023, 02:47 AM by mnrvovrfc.
Edit Reason: Sorry didn't read, it's a whole fragment and not just a char
)
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:
(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.
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.