ValueStrMethod

Applies to:Fast Math Parser
Class:uCalc.Item
Returns the String value associated with a uCalc.Item
Syntax
ValueStr()
Remarks
Use this to retrieve the String value associated with a variable.

ValueStr has a special property beyond the Value function for other data types in that it can return the value of an item regardless of what data type it has. The value is returned as a string.

Example 1: Retrieving an item value by explicit data type

Dim var = uc.DefineVariable("Var = 1.25")
Dim ByteVar = uc.DefineVariable("ByteVar As Byte = -1")
Dim Int16Var = uc.DefineVariable("Int16Var As Int16 = 456")
Dim Int32Var = uc.DefineVariable("Int32Var As Int32 = Int16u(-1)")
Dim Int64Var = uc.DefineVariable("Int64Var = Int64(55.2)")
Dim SingleVar = uc.DefineVariable("SingleVar As Single = Single(1.0000000001)-1")
Dim DoubleVar = uc.DefineVariable("DoubleVar As Double = Double(1.0000000001)-1")
Dim StringVar = uc.DefineVariable("StringVar = 'Just a test'"): ' Defaults to string when there are quotes
Dim PointerVar = uc.DefineVariable("PtrVar As Double Ptr = AddressOf(DoubleVar)")
      
Console.WriteLine("Var value: " + var.Value()) ' Returns "Var value: 1.25"      
Console.WriteLine("ByteVar value: " + CInt(ByteVar.ValueByte())) ' Returns "ByteVar value: 255"
Console.WriteLine("Int16Var value: " + Int16Var.ValueInt16()) ' Returns "Int16Var value: 456"
Console.WriteLine("Int32Var value: " + Int32Var.ValueInt32()) ' Returns "Int32Var value: 65535"
Console.WriteLine("Int64Var value: " + Int64Var.ValueInt64()) ' Returns "Int64Var value: 55"
Console.WriteLine("SingleVar value: " + SingleVar.ValueSng()) ' Returns "SingleVar value: 0"
Console.WriteLine("DoubleVar value: " + DoubleVar.ValueDbl()) ' Returns "DoubleVar value: 1e-10"
Console.WriteLine("StringVar value: " + StringVar.ValueStr()) ' Returns "StringVar value: Just a test"
' The values in the two lines below should match although their specific value is not known beforehand
Console.Write("PointerVar value: "): Console.WriteLine(PointerVar.ValuePtr())
Console.Write("DoubleVar address: "): Console.WriteLine(DoubleVar.ValueAddr())
Console.WriteLine(PointerVar.ValuePtr())
            
          

var var = uc.DefineVariable("Var = 1.25");
var ByteVar = uc.DefineVariable("ByteVar As Byte = -1");
var Int16Var = uc.DefineVariable("Int16Var As Int16 = 456");
var Int32Var = uc.DefineVariable("Int32Var As Int32 = Int16u(-1)");
var Int64Var = uc.DefineVariable("Int64Var = Int64(55.2)");
var SingleVar = uc.DefineVariable("SingleVar As Single = Single(1.0000000001)-1");
var DoubleVar = uc.DefineVariable("DoubleVar As Double = Double(1.0000000001)-1");
var StringVar = uc.DefineVariable("StringVar = 'Just a test'"); // Defaults to string when there are quotes
var PointerVar = uc.DefineVariable("PtrVar As Double Ptr = AddressOf(DoubleVar)");

Console.WriteLine("Var value: " + var.Value()); // Returns "Var value: 1.25";      
Console.WriteLine("ByteVar value: " + (int)ByteVar.ValueByte()); // Returns "ByteVar value: 255";
Console.WriteLine("Int16Var value: " + Int16Var.ValueInt16()); // Returns "Int16Var value: 456";
Console.WriteLine("Int32Var value: " + Int32Var.ValueInt32()); // Returns "Int32Var value: 65535";
Console.WriteLine("Int64Var value: " + Int64Var.ValueInt64()); // Returns "Int64Var value: 55";
Console.WriteLine("SingleVar value: " + SingleVar.ValueSng()); // Returns "SingleVar value: 0";
Console.WriteLine("DoubleVar value: " + DoubleVar.ValueDbl()); // Returns "DoubleVar value: 1e-10";
Console.WriteLine("StringVar value: " + StringVar.ValueStr()); // Returns "StringVar value: Just a test";
// The values in the two lines below should match although their specific value is not known beforehand
Console.Write("PointerVar value: "); Console.WriteLine(PointerVar.ValuePtr());
Console.Write("DoubleVar address: "); Console.WriteLine(DoubleVar.ValueAddr());
Console.WriteLine(PointerVar.ValuePtr());

          

//var Var = uc.DefineVariable('Var = 1.25');
//var ByteVar = uc.DefineVariable('ByteVar As Byte = -1');
//var Int16Var = uc.DefineVariable('Int16Var As Int16 = 456');
//var Int32Var = uc.DefineVariable('Int32Var As Int32 = Int16u(-1)');
//var Int64Var = uc.DefineVariable('Int64Var = Int64(55.2)');
//var SingleVar = uc.DefineVariable('SingleVar As Single = Single(1.0000000001)-1');
//var DoubleVar = uc.DefineVariable('DoubleVar As Double = Double(1.0000000001)-1');
//var StringVar = uc.DefineVariable('StringVar = "Just a test"'); // Defaults to string when there are quotes
//var PointerVar = uc.DefineVariable('PtrVar As Double Ptr = AddressOf(DoubleVar)');
      
      WriteLn('Var value: ' + var.Value()); // Returns 'Var value: 1.25';      
      WriteLn('ByteVar value: ' + CInt(ByteVar.ValueByte())); // Returns 'ByteVar value: 255';
      WriteLn('Int16Var value: ' + Int16Var.ValueInt16()); // Returns 'Int16Var value: 456';
      WriteLn('Int32Var value: ' + Int32Var.ValueInt32()); // Returns 'Int32Var value: 65535';
      WriteLn('Int64Var value: ' + Int64Var.ValueInt64()); // Returns 'Int64Var value: 55';
      WriteLn('SingleVar value: ' + SingleVar.ValueSng()); // Returns 'SingleVar value: 0';
      WriteLn('DoubleVar value: ' + DoubleVar.ValueDbl()); // Returns 'DoubleVar value: 1e-10';
      WriteLn('StringVar value: ' + StringVar.ValueStr()); // Returns 'StringVar value: Just a test';
      // The values in the two lines below should match although their specific value is not known beforehand
      Write('PointerVar value: '); WriteLn(PointerVar.ValuePtr());
      Write('DoubleVar address: '); WriteLn(DoubleVar.ValueAddr());
      WriteLn(PointerVar.ValuePtr());
            
          

auto var = uc.DefineVariable("Var = 1.25");
auto ByteVar = uc.DefineVariable("ByteVar As Byte = -1");
auto Int16Var = uc.DefineVariable("Int16Var As Int16 = 456");
auto Int32Var = uc.DefineVariable("Int32Var As Int32 = Int16u(-1)");
auto Int64Var = uc.DefineVariable("Int64Var = Int64(55.2)");
auto SingleVar = uc.DefineVariable("SingleVar As Single = Single(1.0000000001)-1");
auto DoubleVar = uc.DefineVariable("DoubleVar As Double = Double(1.0000000001)-1");
auto StringVar = uc.DefineVariable("StringVar = 'Just a test'"); // Defaults to string when there are quotes
auto PointerVar = uc.DefineVariable("PtrVar As Double Ptr = AddressOf(DoubleVar)");

cout << "Var value: " << var.Value() << endl; // Returns "Var value: 1.25";      
cout << "ByteVar value: " << (int)ByteVar.ValueByte() << endl; // Returns "ByteVar value: 255";
cout << "Int16Var value: " << Int16Var.ValueInt16() << endl; // Returns "Int16Var value: 456";
cout << "Int32Var value: " << Int32Var.ValueInt32() << endl; // Returns "Int32Var value: 65535";
cout << "Int64Var value: " << Int64Var.ValueInt64() << endl; // Returns "Int64Var value: 55";
cout << "SingleVar value: " << SingleVar.ValueSng() << endl; // Returns "SingleVar value: 0";
cout << "DoubleVar value: " << DoubleVar.ValueDbl() << endl; // Returns "DoubleVar value: 1e-10";
cout << "StringVar value: " << StringVar.ValueStr() << endl; // Returns "StringVar value: Just a test";
// The values in the two lines below should match although their specific value is not known beforehand
cout << "PointerVar value: "; cout << PointerVar.ValuePtr() << endl;
cout << "DoubleVar address: "; cout << DoubleVar.ValueAddr() << endl;
cout << PointerVar.ValuePtr() << endl;

          

auto var = uc.DefineVariable("Var = 1.25");
auto ByteVar = uc.DefineVariable("ByteVar As Byte = -1");
auto Int16Var = uc.DefineVariable("Int16Var As Int16 = 456");
auto Int32Var = uc.DefineVariable("Int32Var As Int32 = Int16u(-1)");
auto Int64Var = uc.DefineVariable("Int64Var = Int64(55.2)");
auto SingleVar = uc.DefineVariable("SingleVar As Single = Single(1.0000000001)-1");
auto DoubleVar = uc.DefineVariable("DoubleVar As Double = Double(1.0000000001)-1");
auto StringVar = uc.DefineVariable("StringVar = 'Just a test'"); // Defaults to string when there are quotes
auto PointerVar = uc.DefineVariable("PtrVar As Double Ptr = AddressOf(DoubleVar)");

Console::WriteLine("Var value: " + var.Value()); // Returns "Var value: 1.25";      
Console::WriteLine("ByteVar value: " + (int)ByteVar.ValueByte()); // Returns "ByteVar value: 255";
Console::WriteLine("Int16Var value: " + Int16Var.ValueInt16()); // Returns "Int16Var value: 456";
Console::WriteLine("Int32Var value: " + Int32Var.ValueInt32()); // Returns "Int32Var value: 65535";
Console::WriteLine("Int64Var value: " + Int64Var.ValueInt64()); // Returns "Int64Var value: 55";
Console::WriteLine("SingleVar value: " + SingleVar.ValueSng()); // Returns "SingleVar value: 0";
Console::WriteLine("DoubleVar value: " + DoubleVar.ValueDbl()); // Returns "DoubleVar value: 1e-10";
Console::WriteLine("StringVar value: " + StringVar.ValueStr()); // Returns "StringVar value: Just a test";
// The values in the two lines below should match although their specific value is not known beforehand
Console::Write("PointerVar value: "); Console::WriteLine(PointerVar.ValuePtr());
Console::Write("DoubleVar address: "); Console::WriteLine(DoubleVar.ValueAddr());
Console::WriteLine(PointerVar.ValuePtr());

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

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

protected static extern  IntPtr ValueStr_(IntPtr ItemHandle);
            
{DLLImport}function ValueStr__(ItemHandle: System.Pointer):  PAnsiChar; cdecl; external uCalcDLL name 'ValueStr';

            
typedef const char * (* __ValueStr)(void *ItemHandle); 

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

static STR_RETURN ValueStr_(void *  ItemHandle);
            
See also
Prev | Next