Delete a handle of a PLC variable
Download
Requirements
Language / IDE | Extract the sample program |
---|---|
C# / Visual Studio |
Description
This Sample shows how to delete a handle of a PLC variable:
C# program
static void Main(string[] args)
{
//Create a new instance of class TcAdsClient
TcAdsClient tcClient = new TcAdsClient();
int iHandle = 0;
try
{
// Connect to local PLC - Runtime 1 - TwinCAT 3 Port=851
tcClient.Connect(851);
//Get the handle of the PLC variable "PLCVar"
iHandle = tcClient.CreateVariableHandle("MAIN.PLCVar");
//Release the specific handle of "PLCVar"
tcClient.DeleteVariableHandle(iHandle);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadKey();
}
finally
{
tcClient.Dispose();
}
}