HP Forums
Getting character number from String entry. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Getting character number from String entry. (/thread-18158.html)



Getting character number from String entry. - matalog - 03-22-2022 06:04 PM

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?


RE: Getting character number from String entry. - Didier Lachieze - 03-22-2022 08:48 PM

(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"


RE: Getting character number from String entry. - matalog - 03-22-2022 10:21 PM

(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.


RE: Getting character number from String entry. - matalog - 03-23-2022 12:02 PM

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?


RE: Getting character number from String entry. - Didier Lachieze - 03-24-2022 04:48 AM

(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".