It is not quite clear, what do you want to achieve. It is always helpful if in the question one formulates the result he needs to get.
I understood the question such that you want to transform the StringForm
into the expression. Then after the evaluation Mma will know that x is 5 and Delta is 10. Is it right? If yes, try the following.
Step 1: let us form two strings
str1 = StringTake[ToString[variables], 3];
str2 = StringTake[ToString[variables], 5 ;; 8];
So far, str1 and str2 are strings
str1
str2
(* "x=5"
"\[Delta]=10" *)
One can check it:
Head[str1]
(* String *)
Step 2:
Now, it is easy to transform them into expressions:
ToExpression[str1]
ToExpression[str2]
(* 5
10 *)
Let us check if Mma "knows" the values of x and Delta:
x
\[Delta]
(* 5
10 *)
Edit
Step 3:
expr = \[Delta]*x;
With[{x = ToExpression[str1],
\[Delta] = ToExpression[str2]}, expr]
(* 50 *)
Done.
Some explanations:
The construct With
requires the Set
statement within the curly braces. That is, With[{expr1=something1, expr2=something2}, expr3]
. Your variable variables
does not have a form of the Set
statement. This is reported to you as an error message.
The variable variables
has a head StringForm
. Please check Head[variables]
. It is a specific form to work with texts. Using variables with such a head for standard calculations is possible (as I have shown) but strongly complicates the code. I generally recommend another way around. That is, making calculations in a usual way with standard variables, and then transforming these variables into strings when needed.
Hope it helps. Have fun!
String
? I think there are better options likeAssociation
, or others. $\endgroup$