Checking variable types against BuiltInType

ID: 278

				
					using uCalcSoftware;

var uc = new uCalc();
// Define a variable with a specific type
uc.DefineVariable("myVar As Int16");

// Retrieve the generic Int16 type object
var typeObj = uc.DataTypeOf(BuiltInType.Integer_16);

// Check if the variable's type matches Int16
if (uc.ItemOf("myVar").DataType.BuiltInTypeEnum == typeObj.BuiltInTypeEnum) {
   Console.WriteLine("Variable 'myVar' is an Int16.");
} else {
   Console.WriteLine("Type mismatch.");
}
				
			
Variable 'myVar' is an Int16.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define a variable with a specific type
   uc.DefineVariable("myVar As Int16");

   // Retrieve the generic Int16 type object
   auto typeObj = uc.DataTypeOf(BuiltInType::Integer_16);

   // Check if the variable's type matches Int16
   if (uc.ItemOf("myVar").DataType().BuiltInTypeEnum() == typeObj.BuiltInTypeEnum()) {
      cout << "Variable 'myVar' is an Int16." << endl;
   } else {
      cout << "Type mismatch." << endl;
   }
}
				
			
Variable 'myVar' is an Int16.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Define a variable with a specific type
      uc.DefineVariable("myVar As Int16")
      
      '// Retrieve the generic Int16 type object
      Dim typeObj = uc.DataTypeOf(BuiltInType.Integer_16)
      
      '// Check if the variable's type matches Int16
      If uc.ItemOf("myVar").DataType.BuiltInTypeEnum = typeObj.BuiltInTypeEnum Then
         Console.WriteLine("Variable 'myVar' is an Int16.")
      Else
         Console.WriteLine("Type mismatch.")
      End If
   End Sub
End Module
				
			
Variable 'myVar' is an Int16.