HP Forums

Full Version: Getting character number from String entry.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to get a single character identifier for a single letter of a string at a time?

ASC seems like it would do it, but it outputs a list.

If ASC is the only way to get it, then is there a way to extract the single entry in a list, as a single number?
(03-22-2022 06:04 PM)matalog Wrote: [ -> ]Is there a way to get a single character identifier for a single letter of a string at a time?

with s:="ABCDE"
s(3) will return 67
s(3,1) will return "C"
s(3,2) will return "CD"
(03-22-2022 08:48 PM)Didier Lachieze Wrote: [ -> ]
(03-22-2022 06:04 PM)matalog Wrote: [ -> ]Is there a way to get a single character identifier for a single letter of a string at a time?

with s:="ABCDE"
s(3) will return 67
s(3,1) will return "C"
s(3,2) will return "CD"

Great, thanks.
Actually, where in the manual is that particular ability/feature described. That a string referred to as M(1) will return the ascii character number, and referred to with M(1,1) will return the string character?
(03-23-2022 12:02 PM)matalog Wrote: [ -> ]Actually, where in the manual is that particular ability/feature described.

Indirectly in the section "List references" of the manual:
Quote: List references
Suppose L1:={5, "abcde", {1,2,3,4,5}, 11}. L1(1) returns 5 and L1(2) returns "abcde". L1(2, 4) returns 100 (the ASCII code for d) and L1(2,4,1) returns "d".
Reference URL's