HP Forums
How to get textbook display of an expression held in a string? - 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: How to get textbook display of an expression held in a string? (/thread-4273.html)



How to get textbook display of an expression held in a string? - BruceH - 07-01-2015 12:59 AM

I have a piece of code that generates an expression as a string. I can't find a way to convert it into a CAS expression (within the program and without simplifying or evaluating it) so that it displays pretty-printed in textbook mode on the history stack when the program ends.

Typical example is: "3 NTHROOT (1/8)" which I'd like to see displayed as:
\begin{equation}
\sqrt[3]{1/8}
\end{equation}

Any suggestions, please?


RE: How to get textbook display of an expression held in a string? - Didier Lachieze - 07-01-2015 01:43 AM

If s is your string, then the following should work:
Code:
EXPR("'" + s + "'")
or
Code:
EXPR("QUOTE(" + s + ")")



RE: How to get textbook display of an expression held in a string? - BruceH - 07-01-2015 10:37 PM

Thanks, the latter version did the trick. I felt sure that I had tried every combination of QUOTE, EXPR and EVAL but clearly not. Thanks again.


RE: How to get textbook display of an expression held in a string? - Didier Lachieze - 07-02-2015 03:54 AM

Both versions work in the tests I've done. Do you have an example where the first one would not work ?