Is there an IsAlpha function in QB64PE? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Is there an IsAlpha function in QB64PE? (/showthread.php?tid=1594) |
Is there an IsAlpha function in QB64PE? - PhilOfPerth - 03-31-2023 Is there an IsAlpha or IsNum (or equivalent) function in PE, to examine an input's type? If not, should there be? I couldn't see one in Help or the Wiki. I know we can use Select Case etc., but it would be much more convenient if these functions were available. RE: Is there an IsAlpha function in QB64PE? - bplus - 04-01-2023 Quote:to examine an input's type An input's type is determined by the variable that contains the value: Code: (Select All) Input "Enter a number"; aNum ' << single type RE: Is there an IsAlpha function in QB64PE? - TerryRitchie - 04-01-2023 (03-31-2023, 11:56 PM)PhilOfPerth Wrote: Is there an IsAlpha or IsNum (or equivalent) function in PE, to examine an input's type? If not, should there be? Functions like those are really handy (and necessary) for languages that don't rely on, or are very flexible with, variable types. Since QB64 requires a variable to have a type (integer, single, string, etc..) there would be no reason to have an IsAlpha or IsNum function. All variables created in QB64 without specifying a type default to SINGLE, therefore they are always "IsNum" so to speak. If you want to test a string for a numeric value use VAL(). RE: Is there an IsAlpha function in QB64PE? - PhilOfPerth - 04-01-2023 Ah, of course it is! Sorry. RE: Is there an IsAlpha function in QB64PE? - PhilOfPerth - 04-01-2023 (04-01-2023, 12:13 AM)TerryRitchie Wrote:Yep, got it. Thanks Terry.(03-31-2023, 11:56 PM)PhilOfPerth Wrote: Is there an IsAlpha or IsNum (or equivalent) function in PE, to examine an input's type? If not, should there be? RE: Is there an IsAlpha function in QB64PE? - mnrvovrfc - 04-01-2023 https://qb64phoenix.com/qb64wiki/index.php/C_Libraries#C_Functions_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 (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. RE: Is there an IsAlpha function in QB64PE? - SMcNeill - 04-01-2023 https://staging.qb64phoenix.com/showthread.php?tid=1207&highlight=Isnum RE: Is there an IsAlpha function in QB64PE? - RhoSigma - 04-01-2023 The ctype.h header is allready included in QB64pe and its functions can easily accessed via a declare library block. Code: (Select All) DECLARE LIBRARY |