A practical example showing how to inspect multiple items and display their type properties, distinguishing between simple and compound types.
ID: 617
using uCalcSoftware;
var uc = new uCalc();
var x = uc.DefineVariable("x = 10.5"); // double
var y = uc.DefineVariable("y = 'hello'"); // string
var z = uc.DefineVariable("z As Complex = 1+2*#i"); // complex
Console.WriteLine($"Item: {x.Name}, Type: {x.DataType.Name}, Compound: {x.DataType.IsCompound}");
Console.WriteLine($"Item: {y.Name}, Type: {y.DataType.Name}, Compound: {y.DataType.IsCompound}");
Console.WriteLine($"Item: {z.Name}, Type: {z.DataType.Name}, Compound: {z.DataType.IsCompound}");
Item: x, Type: double, Compound: False
Item: y, Type: string, Compound: True
Item: z, Type: complex, Compound: True
using uCalcSoftware; var uc = new uCalc(); var x = uc.DefineVariable("x = 10.5"); // double var y = uc.DefineVariable("y = 'hello'"); // string var z = uc.DefineVariable("z As Complex = 1+2*#i"); // complex Console.WriteLine($"Item: {x.Name}, Type: {x.DataType.Name}, Compound: {x.DataType.IsCompound}"); Console.WriteLine($"Item: {y.Name}, Type: {y.DataType.Name}, Compound: {y.DataType.IsCompound}"); Console.WriteLine($"Item: {z.Name}, Type: {z.DataType.Name}, Compound: {z.DataType.IsCompound}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto x = uc.DefineVariable("x = 10.5"); // double
auto y = uc.DefineVariable("y = 'hello'"); // string
auto z = uc.DefineVariable("z As Complex = 1+2*#i"); // complex
cout << "Item: " << x.Name() << ", Type: " << x.DataType().Name() << ", Compound: " << tf(x.DataType().IsCompound()) << endl;
cout << "Item: " << y.Name() << ", Type: " << y.DataType().Name() << ", Compound: " << tf(y.DataType().IsCompound()) << endl;
cout << "Item: " << z.Name() << ", Type: " << z.DataType().Name() << ", Compound: " << tf(z.DataType().IsCompound()) << endl;
}
Item: x, Type: double, Compound: False
Item: y, Type: string, Compound: True
Item: z, Type: complex, Compound: True
#include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto x = uc.DefineVariable("x = 10.5"); // double auto y = uc.DefineVariable("y = 'hello'"); // string auto z = uc.DefineVariable("z As Complex = 1+2*#i"); // complex cout << "Item: " << x.Name() << ", Type: " << x.DataType().Name() << ", Compound: " << tf(x.DataType().IsCompound()) << endl; cout << "Item: " << y.Name() << ", Type: " << y.DataType().Name() << ", Compound: " << tf(y.DataType().IsCompound()) << endl; cout << "Item: " << z.Name() << ", Type: " << z.DataType().Name() << ", Compound: " << tf(z.DataType().IsCompound()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim x = uc.DefineVariable("x = 10.5") '// double
Dim y = uc.DefineVariable("y = 'hello'") '// string
Dim z = uc.DefineVariable("z As Complex = 1+2*#i") '// complex
Console.WriteLine($"Item: {x.Name}, Type: {x.DataType.Name}, Compound: {x.DataType.IsCompound}")
Console.WriteLine($"Item: {y.Name}, Type: {y.DataType.Name}, Compound: {y.DataType.IsCompound}")
Console.WriteLine($"Item: {z.Name}, Type: {z.DataType.Name}, Compound: {z.DataType.IsCompound}")
End Sub
End Module
Item: x, Type: double, Compound: False
Item: y, Type: string, Compound: True
Item: z, Type: complex, Compound: True
Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim x = uc.DefineVariable("x = 10.5") '// double Dim y = uc.DefineVariable("y = 'hello'") '// string Dim z = uc.DefineVariable("z As Complex = 1+2*#i") '// complex Console.WriteLine($"Item: {x.Name}, Type: {x.DataType.Name}, Compound: {x.DataType.IsCompound}") Console.WriteLine($"Item: {y.Name}, Type: {y.DataType.Name}, Compound: {y.DataType.IsCompound}") Console.WriteLine($"Item: {z.Name}, Type: {z.DataType.Name}, Compound: {z.DataType.IsCompound}") End Sub End Module