HP Forums

Full Version: string to variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
in a program can you convert a string into a variable?
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.
Thank you very much

Smile))))
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
Reference URL's