Use the FieldGet and FieldPut methods
- Last UpdatedApr 08, 2026
- 1 minute read
This scenario guides you through the steps required to use the FieldGet and FieldPut methods for an analog record in the RealTime database (RTDB).
To identify the code associated with each step, see the code comments in the Example code section.
Using the virtual path will enable you to go through the Virtual Database (VDB) layer in real time using managed code.
To use the FieldGet and FieldPut methods
In this example, the remote field is used; the type is slot.
If you want to get the value from the database converted to a string, use the FieldGetConvertedToString().
- Open the Program.cs file from the created project.
- Open the RTDB.
- Access the analog table through a path.
- Use the FieldGet proper function to get the field value.
- Use the FieldPut proper function to put a field value.
Example code
IRealTimeDatabase database = new RealTimeDatabase();
try
{
// Open the RTDB.
if (!database.IsOpen())
{
database.Open();
}
// Access the analog table through a path.
var virtualPath = database.GetVPath("analog", "AutoCommandAnalog01", "rtu");
// Use the FieldGet proper function to get the field value.
Console.WriteLine(quot;{virtualPath.FieldName} number: {virtualPath.FieldGetSlot()}");
virtualPath.FieldPutSlot(10);
// Use the FieldPut proper function to put a field value.
Console.WriteLine(quot;{virtualPath.FieldName} updated to: {virtualPath.FieldGetSlot()}");
}
catch (Exception ex)
{
Console.WriteLine(quot;An error occurred while reading/writing the slot field: {ex.Message}");
}