| Print2DExpr | Function (ROM Call 0x4C)

estack.h

void Print2DExpr (CESI ptr, WINDOW *w, short x, short y);

Performs "pretty printing" (or "2D printing") of an expression.

Print2DExpr prints the expression in "pretty" or "2D" style. Before printing, the expression needs first to be "parsed" using Parse2DExpr, and argument ptr should be a result returned from Parse2DExpr (an error may be thrown if ptr points to something else). w is a pointer to the WINDOW structure which describes the window in which the expression will be displayed (see wingraph.h header file for more info about windows). If you didn't create your own windows in the program, you can pass DeskTop as the parameter (as in the example given below). x and y are coordinates (window-relative) where the expression will be printed. x determines the left edge of the expression, and the expression goes (in y direction) both above and below the value of y. See Parms2D for exact information about dimensions of displayed expression. If the displayed expression can not fit into the given window, it will be simply clipped at edges of the window.
Here is an example (called "Pretty Print") which first calculates the integral of 1/((x-3)(x^2+4)), then "pretty prints" the result on the screen:

    // Calculate an integral and pretty print it

    #define USE_TI89              // Compile for TI-89
    #define USE_TI92PLUS          // Compile for TI-92 Plus
    #define USE_V200              // Compile for V200

    #define MIN_AMS 101           // Compile for AMS 1.01 or higher
    #define SAVE_SCREEN           // Save/Restore LCD Contents

    #include <tigcclib.h>         // Include All Header Files

    // Main Function
    void _main(void)
    {
      TRY
        push_END_TAG ();
        push_quantum (VAR_X_TAG);
        push_parse_text ("1/((x-3)(x^2+4))");
        push_quantum (INTEGRATE_TAG);
        NG_rationalESI (top_estack);
        WinClr (DeskTop);
        Print2DExpr (Parse2DExpr (top_estack, FALSE), DeskTop, 0, 50);
      ONERR
        DrawStr (20, 20, "Error!", A_NORMAL);
      ENDTRY
      ngetchx ();
    }

It is also possible to use

    Parse2DExpr (top_estack, FALSE);
    Print2DExpr (top_estack, DeskTop, 0, 50);

instead of

    Print2DExpr (Parse2DExpr (top_estack, FALSE), DeskTop, 0, 50);

You can use Parms2D to get information about the height and the width of the printed expression without displaying it on the screen. This may be used to determine coordinates where the expression needs to be displayed.

Uses: WinFont
Used by: cmd_disp, cmd_output, cmd_pause, HomeExecute