String Stuff
Lawrence Shafer
Posts: 12
It's been years since I last used a basic stamp and I've forgotten way too much!
I know there is a command for getting certain chars from a string, but I cannot find it now? How would I go about pulling the last two chars (or the middle, or first for that matter) from a string?
And how would I add one string to another, not mathematically but kinda like this
string3 = [noparse][[/noparse]string1, string2]
--OR--
string3 = string1 AND string2
Anyway, you get the idea,
I feel stupid for forgetting this much, and now I can't even find it.
Thanks,
Lawrence
I know there is a command for getting certain chars from a string, but I cannot find it now? How would I go about pulling the last two chars (or the middle, or first for that matter) from a string?
And how would I add one string to another, not mathematically but kinda like this
string3 = [noparse][[/noparse]string1, string2]
--OR--
string3 = string1 AND string2
Anyway, you get the idea,
I feel stupid for forgetting this much, and now I can't even find it.
Thanks,
Lawrence
Comments
This gives you a 5 character array with subscripts starting at zero. You can access the 4th character like:
Have a look at the PBasic manual. Remember that there are special "formatters" for the I/O statements that will input or output a string, either a specific number of characters from an array or a zero-terminated string value. This helps a little.
Indeed the usual string functions mid$(), left$(), and right$() do exist in certain varients of BASIC. PBASIC (the language for the Parallax Stamp) has no string functions and no inherent string handling capability. This doesn't mean that you can't use strings, it just means you have to use the existing language command set in some clever ways to simulate string functions, to the minimal extent that one can. Here is one example below.
The single biggest problem that one usually runs across is the the unavaiability of a string comparison function. Because of that, each character of an alphameric array must be compared individually to establish the appropriate comparison relationship.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔