<-- Previous || Up || Next -->

Infix To Postfix Function
Math Symbolic Class

Public Function InfixToPostfix( _
    ByVal vExpr As Variant _
    ) As Variant

"Translate Infix Expression To Postfix Format"
Translate an expression from infix format (in which the operators come between the operands) into Postfix format (where the operators precede the operands).

Examples:
    ? InfixToPostfix("34 + 45 * 91")
    34 45 91 * +
    ? InfixToPostfix("2 ^ 3 ^ 4 + 5")
    2 3 4 ^ ^ 5 +
    ? InfixToPostfix("A * ( B + C ) + D")
    A B C + * D +
    ? InfixToPostfix("+ A")
    A +
    ? InfixToPostfix("A / B ^ C + D * E - A * C")
    A B C ^ / D E * + A C * -
    ? InfixToPostfix("A + B")
    A B +
    ? InfixToPostfix("A + 0 - B")
    A 0 + B -
    ? InfixToPostfix("A * % ( D + C )")
    A * % D C +
    ? InfixToPostfix("A + B * % G * H")
    A B * + G % H *
    ? InfixToPostfix("% ( D + F ) * 2")
    % D F + 2 *
See also:
    InfixToPrefix Function
    InfixToBasic Function
    InfixToPostfixInComingPriority Function
    InfixToPostfixInStackPriority Function
Note: This function recognizes the following operators and functions (listed from highest precedence to lowest):
    ABS, ASIN, ATAN, COS, LN, SIGN, SIN, SQRT, TAN
    ^
    *, /
    \, MOD
    +, -
    (
The functions at the top of this list have the highest precedence and the open parentheses character has the lowest precedence (and functions/operators on the same line have the same precedence). This function assumes that all other alphanumeric words represent variables or numeric constants.
BIG Note: Although this function supports subtraction, it does not support the use of "-" as a unary minus operator. Rephrase any expressions like "-A" into "0-A".
Note: This function can also be used to convert from a regular algebraic expression to the format required for entry into a RPN or Reverse Polish Notation calculator.

vExpr: String containing the infix-format algebraic expression which will be converted to Postfix. Function returns Null if vExpr is Null or cannot be fixed up to a String.

Note: Function will not return an error if the algebraic (infix) expression is ill-formed; it will instead return an ill-formed Postfix expression.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.