ItemIsEnumEnum

Applies to:Fast Math Parser
*/ */
Remarks
Members
AnyItem
LeftToRight
RightToLeft
DataType
Array
Class
NameSpace
Variable
LocalVariable
Function
Operator
FunctionOrOperator
Prefix
Infix
Postfix
AddressOwner
ByVal
ByRef
ByCopy
ByExpr
ByHandle
Pointer
Optional
VariableNumberOfArgs
RegEx
LiteralItem
Locked
Transform
InTable
ItemDef
ErrorHandler
StopNow
ApiCall
CaseSensitive
QuotedText
ChangeMulti
ExpandArg
IgnoreStatementSep
IgnoreCodeBlock
SyntaxStop
SkipEvalExpand
ExprUnit
EagerArg
SkipSyntax
WhiteSpaceCounts
IgnoreQuote
UpToEndOrSeparator
UpToUserStop
EvalStrOutput
SkipOutput
DefaultSettings
NotFound
MiscItem
Example 1: Determining whether items are functions, or arrays, etc.

uc.DefineVariable("MyVar")
' Note: Some properties may end with an underscore (_) if the original property name is a reserved word in the compiler.
' True or False, or 1 or 0 may be returned depending on the compiler and/or settings 
Console.WriteLine("Cos is a function? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.Function_)) ' Returns "Cos is a function? 1"
Console.WriteLine("Cos is a variable? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.Variable)) ' Returns "Cos is a variable? 0"
Console.WriteLine("Cos is an operator? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.Operator_)) ' Returns "Cos is an operator? 0"
Console.WriteLine("MyVar is a function? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum.Function_)) ' Returns "MyVar is a function? 0"
Console.WriteLine("MyVar is a variable? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum.Variable)) ' Returns "MyVar is a variable? 1"
Console.WriteLine("MyVar is an operator? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum.Operator_)) ' Returns "MyVar is an operator? 0"
Console.WriteLine("+ is a function? " + uc.GetItemOf("+").IsProperty(ItemIsEnum.Function_)) ' Returns "+ is a function? 0"
Console.WriteLine("+ is a variable? " + uc.GetItemOf("+").IsProperty(ItemIsEnum.Variable)) ' Returns "+ is a variable? 0"
Console.WriteLine("+ is an operator? " + uc.GetItemOf("+").IsProperty(ItemIsEnum.Operator_)) ' Returns "+ is an operator? 1"
Console.WriteLine("Cos doesn't exist? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.NotFound)) ' Returns "Cos doesn't exist? 0"
Console.WriteLine("XYZABC doesn't exist? " + uc.GetItemOf("XYZABC").IsProperty(ItemIsEnum.NotFound)) ' Returns "XYZABC doesn't exist? 1"

          

uc.DefineVariable("MyVar");
// Note: Some properties may end with an underscore (_) if the original property name is a reserved word in the compiler.
// True or False, or 1 or 0 may be returned depending on the compiler and/or settings 
Console.WriteLine("Cos is a function? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.Function)); // Returns "Cos is a function? 1";
Console.WriteLine("Cos is a variable? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.Variable)); // Returns "Cos is a variable? 0";
Console.WriteLine("Cos is an operator? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.Operator)); // Returns "Cos is an operator? 0";
Console.WriteLine("MyVar is a function? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum.Function)); // Returns "MyVar is a function? 0";
Console.WriteLine("MyVar is a variable? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum.Variable)); // Returns "MyVar is a variable? 1";
Console.WriteLine("MyVar is an operator? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum.Operator)); // Returns "MyVar is an operator? 0";
Console.WriteLine("+ is a function? " + uc.GetItemOf("+").IsProperty(ItemIsEnum.Function)); // Returns "+ is a function? 0";
Console.WriteLine("+ is a variable? " + uc.GetItemOf("+").IsProperty(ItemIsEnum.Variable)); // Returns "+ is a variable? 0";
Console.WriteLine("+ is an operator? " + uc.GetItemOf("+").IsProperty(ItemIsEnum.Operator)); // Returns "+ is an operator? 1";
Console.WriteLine("Cos doesn't exist? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum.NotFound)); // Returns "Cos doesn't exist? 0";
Console.WriteLine("XYZABC doesn't exist? " + uc.GetItemOf("XYZABC").IsProperty(ItemIsEnum.NotFound)); // Returns "XYZABC doesn't exist? 1";

          

      uc.DefineVariable('MyVar');
      // Note: Some properties may end with an underscore (_) if the original property name is a reserved word in the compiler.
      // True or False, or 1 or 0 may be returned depending on the compiler and/or settings 
      WriteLn('Cos is a function? ' + uc.GetItemOf('Cos').IsProperty(ItemIsEnum.Function_)); // Returns 'Cos is a function? 1';
      WriteLn('Cos is a variable? ' + uc.GetItemOf('Cos').IsProperty(ItemIsEnum.Variable)); // Returns 'Cos is a variable? 0';
      WriteLn('Cos is an operator? ' + uc.GetItemOf('Cos').IsProperty(ItemIsEnum.Operator_)); // Returns 'Cos is an operator? 0';
      WriteLn('MyVar is a function? ' + uc.GetItemOf('MyVar').IsProperty(ItemIsEnum.Function_)); // Returns 'MyVar is a function? 0';
      WriteLn('MyVar is a variable? ' + uc.GetItemOf('MyVar').IsProperty(ItemIsEnum.Variable)); // Returns 'MyVar is a variable? 1';
      WriteLn('MyVar is an operator? ' + uc.GetItemOf('MyVar').IsProperty(ItemIsEnum.Operator_)); // Returns 'MyVar is an operator? 0';
      WriteLn('+ is a function? ' + uc.GetItemOf('+').IsProperty(ItemIsEnum.Function_)); // Returns '+ is a function? 0';
      WriteLn('+ is a variable? ' + uc.GetItemOf('+').IsProperty(ItemIsEnum.Variable)); // Returns '+ is a variable? 0';
      WriteLn('+ is an operator? ' + uc.GetItemOf('+').IsProperty(ItemIsEnum.Operator_)); // Returns '+ is an operator? 1';
      WriteLn('Cos doesn"t exist? ' + uc.GetItemOf('Cos').IsProperty(ItemIsEnum.NotFound)); // Returns 'Cos doesn"t exist? 0';
      WriteLn('XYZABC doesn"t exist? ' + uc.GetItemOf('XYZABC').IsProperty(ItemIsEnum.NotFound)); // Returns 'XYZABC doesn"t exist? 1';

          

uc.DefineVariable("MyVar");
// Note: Some properties may end with an underscore (_) if the original property name is a reserved word in the compiler.
// True or False, or 1 or 0 may be returned depending on the compiler and/or settings 
cout << "Cos is a function? " << uc.GetItemOf("Cos").IsProperty(ItemIsEnum::Function) << endl; // Returns "Cos is a function? 1";
cout << "Cos is a variable? " << uc.GetItemOf("Cos").IsProperty(ItemIsEnum::Variable) << endl; // Returns "Cos is a variable? 0";
cout << "Cos is an operator? " << uc.GetItemOf("Cos").IsProperty(ItemIsEnum::Operator) << endl; // Returns "Cos is an operator? 0";
cout << "MyVar is a function? " << uc.GetItemOf("MyVar").IsProperty(ItemIsEnum::Function) << endl; // Returns "MyVar is a function? 0";
cout << "MyVar is a variable? " << uc.GetItemOf("MyVar").IsProperty(ItemIsEnum::Variable) << endl; // Returns "MyVar is a variable? 1";
cout << "MyVar is an operator? " << uc.GetItemOf("MyVar").IsProperty(ItemIsEnum::Operator) << endl; // Returns "MyVar is an operator? 0";
cout << "+ is a function? " << uc.GetItemOf("+").IsProperty(ItemIsEnum::Function) << endl; // Returns "+ is a function? 0";
cout << "+ is a variable? " << uc.GetItemOf("+").IsProperty(ItemIsEnum::Variable) << endl; // Returns "+ is a variable? 0";
cout << "+ is an operator? " << uc.GetItemOf("+").IsProperty(ItemIsEnum::Operator) << endl; // Returns "+ is an operator? 1";
cout << "Cos doesn't exist? " << uc.GetItemOf("Cos").IsProperty(ItemIsEnum::NotFound) << endl; // Returns "Cos doesn't exist? 0";
cout << "XYZABC doesn't exist? " << uc.GetItemOf("XYZABC").IsProperty(ItemIsEnum::NotFound) << endl; // Returns "XYZABC doesn't exist? 1";

          

uc.DefineVariable("MyVar");
// Note: Some properties may end with an underscore (_) if the original property name is a reserved word in the compiler.
// True or False, or 1 or 0 may be returned depending on the compiler and/or settings 
Console::WriteLine("Cos is a function? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum::Function)); // Returns "Cos is a function? 1";
Console::WriteLine("Cos is a variable? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum::Variable)); // Returns "Cos is a variable? 0";
Console::WriteLine("Cos is an operator? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum::Operator)); // Returns "Cos is an operator? 0";
Console::WriteLine("MyVar is a function? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum::Function)); // Returns "MyVar is a function? 0";
Console::WriteLine("MyVar is a variable? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum::Variable)); // Returns "MyVar is a variable? 1";
Console::WriteLine("MyVar is an operator? " + uc.GetItemOf("MyVar").IsProperty(ItemIsEnum::Operator)); // Returns "MyVar is an operator? 0";
Console::WriteLine("+ is a function? " + uc.GetItemOf("+").IsProperty(ItemIsEnum::Function)); // Returns "+ is a function? 0";
Console::WriteLine("+ is a variable? " + uc.GetItemOf("+").IsProperty(ItemIsEnum::Variable)); // Returns "+ is a variable? 0";
Console::WriteLine("+ is an operator? " + uc.GetItemOf("+").IsProperty(ItemIsEnum::Operator)); // Returns "+ is an operator? 1";
Console::WriteLine("Cos doesn't exist? " + uc.GetItemOf("Cos").IsProperty(ItemIsEnum::NotFound)); // Returns "Cos doesn't exist? 0";
Console::WriteLine("XYZABC doesn't exist? " + uc.GetItemOf("XYZABC").IsProperty(ItemIsEnum::NotFound)); // Returns "XYZABC doesn't exist? 1";

          
Example 2: Determining properties of an expression part

Sub OpItemTestCB(ByVal ExprPartPtr As IntPtr)
   Dim ExprPart As New uCalc.Callback(ExprPartPtr)
   Console.WriteLine("Name: " + ExprPart.OpItem().Name())
   Console.WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name())
   Console.WriteLine("Param count: " + ExprPart.OpItem().ElementCount())
   Console.WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator_))
End Sub

Sub HandleTest()
   uc.DefineFunction("AAA() As Double", uc.PinAddr(AddressOf OpItemTestCB))
   uc.DefineFunction("BBB(x, y, z) As String", uc.PinAddr(AddressOf OpItemTestCB))
   uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum.GroupLeftToRight, uc.PinAddr(AddressOf OpItemTestCB)): ' 0 should work
   uc.EvalStr("AAA()")
   ' Output
   ' Name: aaa
   ' Data type: double
   ' Param count: 0
   ' Is Operator_? 0

   uc.EvalStr("BBB(9, 8, 7)")
   ' Output
   ' Name: bbb
   ' Data type: string
   ' Param count: 3
   ' Is Operator_? 0

   uc.EvalStr("5 CCC 4")
   ' Output
   ' Name: ccc
   ' Data type: Int32
   ' Param count: 2
   ' Is Operator_? 1
End Sub

          

static void OpItemTestCB(IntPtr ExprPartPtr) {
   var ExprPart = New uCalc.Callback(ExprPartPtr);
   Console.WriteLine("Name: " + ExprPart.OpItem().Name());
   Console.WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name());
   Console.WriteLine("Param count: " + ExprPart.OpItem().ElementCount());
   Console.WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator));
}

static void HandleTest() {
   uc.DefineFunction("AAA() As Double", uc.PinAddr(OpItemTestCB));
   uc.DefineFunction("BBB(x, y, z) As String", uc.PinAddr(OpItemTestCB));
   uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum.GroupLeftToRight, uc.PinAddr(OpItemTestCB)); // 0 should work
   uc.EvalStr("AAA()");
   // Output
   // Name: aaa
   // Data type: double
   // Param count: 0
   // Is operator? 0
   
   uc.EvalStr("BBB(9, 8, 7)");
   // Output
   // Name: bbb
   // Data type: string
   // Param count: 3
   // Is operator? 0
   
   uc.EvalStr("5 CCC 4");
   // Output
   // Name: ccc
   // Data type: Int32
   // Param count: 2
   // Is operator? 1
   
}

          

procedure OpItemTestCB(ExprPartPtr: System.Pointer);
begin
   
//var ExprPart: uCalc.CreateCallback(ExprPartPtr);
   WriteLn('Name: ' + ExprPart.OpItem().Name());
   WriteLn('Data type: ' + ExprPart.OpItem().GetDataType().Name());
   WriteLn('Param count: ' + ExprPart.OpItem().ElementCount());
   WriteLn('Is operator? ' + ExprPart.OpItem().IsProperty(ItemIsEnum.Operator_));
End;

procedure HandleTest();
begin
   
   uc.DefineFunction('AAA() As Double', OpItemTestCB);
   uc.DefineFunction('BBB(x, y, z) As String', OpItemTestCB);
   uc.DefineOperator('{x} CCC {y} As Int32', 0, GroupingEnum.GroupLeftToRight, OpItemTestCB); // 0 should work
   uc.EvalStr('AAA()');
   // Output
// Name: aaa
// Data type: double
// Param count: 0
// Is Operator_? 0

   uc.EvalStr('BBB(9, 8, 7)');
   // Output
// Name: bbb
// Data type: string
// Param count: 3
// Is Operator_? 0

   uc.EvalStr('5 CCC 4');
   // Output
// Name: ccc
// Data type: Int32
// Param count: 2
// Is Operator_? 1

End;

          

void _stdcall OpItemTestCB(uCalcPtr ExprPartPtr) {
   auto ExprPart = uCalc::Callback(ExprPartPtr);
   cout << "Name: " << ExprPart.OpItem().Name() << endl;
   cout << "Data type: " << ExprPart.OpItem().GetDataType().Name() << endl;
   cout << "Param count: " << ExprPart.OpItem().ElementCount() << endl;
   cout << "Is operator? " << ExprPart.OpItem().IsProperty(ItemIsEnum::Operator) << endl;
}

void HandleTest() {
   uc.DefineFunction("AAA() As Double", OpItemTestCB);
   uc.DefineFunction("BBB(x, y, z) As String", OpItemTestCB);
   uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum::GroupLeftToRight, OpItemTestCB); // 0 should work
   uc.EvalStr("AAA()");
   // Output
   // Name: aaa
   // Data type: double
   // Param count: 0
   // Is operator? 0
   
   uc.EvalStr("BBB(9, 8, 7)");
   // Output
   // Name: bbb
   // Data type: string
   // Param count: 3
   // Is operator? 0
   
   uc.EvalStr("5 CCC 4");
   // Output
   // Name: ccc
   // Data type: int
   // Param count: 2
   // Is operator? 1
   
}

          

static void OpItemTestCB(uCalcPtr ExprPartPtr) {
   auto ExprPart = uCalc::Callback(ExprPartPtr);
   Console::WriteLine("Name: " + ExprPart.OpItem().Name());
   Console::WriteLine("Data type: " + ExprPart.OpItem().GetDataType().Name());
   Console::WriteLine("Param count: " + ExprPart.OpItem().ElementCount());
   Console::WriteLine("Is operator? " + ExprPart.OpItem().IsProperty(ItemIsEnum::Operator));
}

static void HandleTest() {
   uc.DefineFunction("AAA() As Double", ucPinAddr(OpItemTestCB));
   uc.DefineFunction("BBB(x, y, z) As String", ucPinAddr(OpItemTestCB));
   uc.DefineOperator("{x} CCC {y} As Int32", 0, GroupingEnum::GroupLeftToRight, ucPinAddr(OpItemTestCB)); // 0 should work
   uc.EvalStr("AAA()");
   // Output
   // Name: aaa
   // Data type: double
   // Param count: 0
   // Is operator? 0
   
   uc.EvalStr("BBB(9, 8, 7)");
   // Output
   // Name: bbb
   // Data type: string
   // Param count: 3
   // Is operator? 0
   
   uc.EvalStr("5 CCC 4");
   // Output
   // Name: ccc
   // Data type: int
   // Param count: 2
   // Is operator? 1
   
}

          
See also
Prev | Next