PrecedenceMethod

Applies to:Fast Math Parser
Class:uCalc.Item
Returns the precedence level of the uCalc.Item
Syntax
Precedence()
Remarks
Operators, and some syntax constructs are defined with a precedence level. When defining a new operator you may sometimes want to give it the same level as a pre-existing operator.
Example 1: Finding the precedence level of an operator

Console.Write("The precedence level of the 'And' operator is: ")
Console.WriteLine(uc.GetItemOf("And").Precedence()) ' Returns 30
uc.DefineOperator("{a} && {b} As Bool = a And b", uc.GetItemOf("And").Precedence())
Console.WriteLine(uc.EvalStr("1 > 0 && 2 > 0")) ' Returns "true"
Console.WriteLine(uc.EvalStr("1 > 2 && 2 > 0")) ' Returns "false"

          

Console.Write("The precedence level of the 'And' operator is: ");
Console.WriteLine(uc.GetItemOf("And").Precedence()); // Returns 30;
uc.DefineOperator("{a} && {b} As Bool = a And b", uc.GetItemOf("And").Precedence());
Console.WriteLine(uc.EvalStr("1 > 0 && 2 > 0")); // Returns "true";
Console.WriteLine(uc.EvalStr("1 > 2 && 2 > 0")); // Returns "false";

          

      Write('The precedence level of the "And" operator is: ');
      WriteLn(uc.GetItemOf('And').Precedence()); // Returns 30;
      uc.DefineOperator('{a} && {b} As Bool = a And b', uc.GetItemOf('And').Precedence());
      WriteLn(uc.EvalStr('1 > 0 && 2 > 0')); // Returns 'true';
      WriteLn(uc.EvalStr('1 > 2 && 2 > 0')); // Returns 'false';

          

cout << "The precedence level of the 'And' operator is: ";
cout << uc.GetItemOf("And").Precedence() << endl; // Returns 30;
uc.DefineOperator("{a} && {b} As Bool = a And b", uc.GetItemOf("And").Precedence());
cout << uc.EvalStr("1 > 0 && 2 > 0") << endl; // Returns "true";
cout << uc.EvalStr("1 > 2 && 2 > 0") << endl; // Returns "false";

          

Console::Write("The precedence level of the 'And' operator is: ");
Console::WriteLine(uc.GetItemOf("And").Precedence()); // Returns 30;
uc.DefineOperator("{a} && {b} As Bool = a And b", uc.GetItemOf("And").Precedence());
Console::WriteLine(uc.EvalStr("1 > 0 && 2 > 0")); // Returns "true";
Console::WriteLine(uc.EvalStr("1 > 2 && 2 > 0")); // Returns "false";

          
DLL import code
<DllImport(uCalcDLL, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="Precedence_Overload_Item")> _

Private Function Precedence_Overload_Item__(ByVal ItemHandle As IntPtr) As  Int32
End Function
            
[DllImport(uCalcDLL, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl, EntryPoint="Precedence_Overload_Item")]

protected static extern  Int32 Precedence_Overload_Item_(IntPtr ItemHandle);
            
{DLLImport}function Precedence_Overload_Item__(ItemHandle: System.Pointer):  Int32; cdecl; external uCalcDLL name 'Precedence_Overload_Item';

            
typedef  int32_t (* __Precedence_Overload_Item)(void *ItemHandle); 

            
[DllImport(uCalcLib, CharSet=CharSet::Ansi, CallingConvention=CallingConvention::Cdecl, EntryPoint = "Precedence_Overload_Item")]

static Int32 Precedence_Overload_Item_(void *  ItemHandle);
            
See also
Prev | Next