HP Forums
string to variable - 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: string to variable (/thread-1157.html)



string to variable - fabila - 04-24-2014 01:38 AM

in a program can you convert a string into a variable?


RE: string to variable - Han - 04-24-2014 01:40 AM

Sure, if you initialize it to some value you can.

Code:

LOCAL mystring:="MyVar";

mystring:=mystring+":=0"; // mystring = "MyVar:=0"
CAS(mystring);

This creates a CAS variable named MyVar with an initial value of 0.


RE: string to variable - fabila - 04-24-2014 02:06 AM

Thank you very much

Smile))))


RE: string to variable - OldHPUser - 04-30-2014 09:57 AM

An other way for this (in a CAS-Program) is

#("ABC_"):=4711;

This creates the global CAS-Variable ABC_ with value 4711. Of course this is also possible with a variable which contains a string:

#CDE_:=4712;

creates the global CAS-Variable ABC_ with value 4712, if the variable CDE_ has the value "ABC_".

OldHPUser