| display_statements | Function (ROM Call 0x4E)

estack.h

HANDLE display_statements (CESI ptr, unsigned short Newlines, unsigned short FullPrec);

Converts tokenized expressions or TI-Basic statements to the printable form.

display_statements converts the expression (or a group of tokenized TI-Basic statements) pointed to by ptr from RPN form to the standard printable ("algebraic") form, and returns a handle to the memory block where the converted string is stored (you don't need to allocate anything by yourself, this function will do it instead; note that this routine may cause heap compression). It will return H_NULL if memory is full. Newline is a Boolean flag: when it is nonzero, all newline characters will be replaced with ':', otherwise they will remain intact. FullPrec is also a Boolean flag: when it is non-zero, all floating point values will be converted using the maximal precision (14 digits), else current precision settings (from TI-Basic MODE dialog) will be used. Here is an illustrative example for usage of this command (take a look at the "Integrate" example as well):

    push_parse_text ("expand((x+1)(x+2)(x+3))");
    NG_rationalESI (top_estack);
    handle = display_statements (top_estack, 1, 1);
    printf_xy (0, 40, "%s", HeapDeref (handle));
    HeapFree (handle);

See push_parse_text, NG_rationalESI, HeapDeref and HeapFree to understand how this example works.
Note: Handles returned by display_statements aren't locked so any heap compression will move the block associated with the handle. Therefore it is safer to lock them using HLock and HeapUnlock than to just dereference them using HeapDeref.
display_statements will always convert expressions into the "canonic printing (external) form". For example, both x*3 and 3*x will be displayed as 3*x, x*y^(-1) will be displayed as x/y etc.
Note: Although display_statements is very similar to Parse1DExpr and both of them may usually be used for the same purposes, display_statements is used in TIOS for printing TI-Basic statements (from programs) and for the detokenization (in NG_RPNToText), and Parse1DExpr is used for printing expressions.

Uses: index_below_display_expression_aux, HeapAlloc, HeapFree, HeapLock, HeapRealloc, HeapUnlock, HLock, ER_catch, ER_success, ER_throwVar, OSDisableBreak, OSEnableBreak, ROM Call 0x5CB
Used by: NG_RPNToText, handleRclKey, TE_handleEvent, tokenize_if_TI_92_or_text