HP Forums
YAR (Yet Another Request) - 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: YAR (Yet Another Request) (/thread-8065.html)



YAR (Yet Another Request) - toml_12953 - 03-30-2017 02:39 PM

Maybe there's already an easy way to do this but I haven't found it. I'd like to be able to change characters in a string simply. It would be something like this:

PHP Code:
MYSTRING:="1234567890";
MYSTRING(4,4):="X";
PRINT(
MYSTRING); 

which prints 123X567890

Right now, I'm doing this:

PHP Code:
MYSTRING:="1234567890";
MYSTRING:=LEFT(MYSTRING,3)+"X"+MID(MYSTRING,5);
PRINT(
MYSTRING); 

which works but is inelegant.

Tom L


RE: YAR (Yet Another Request) - Tim Wessman - 03-30-2017 03:47 PM

REPLACE("1234567890",4,"XXX")

Smile


RE: YAR (Yet Another Request) - cyrille de brébisson - 03-31-2017 08:11 AM

Hello,

Not sure exactly what you want to do, but you can also do:
mystring(4):= "abc" to place abc starting at pos 4 in the string...

Cyrille