Delete a handle of a PLC variable

Download

Language / IDE

Extract the sample program

Visual C#

Sample11.zip

Visual Basic (for .NET Framework)

-

Delphi Prism (Embarcadero Prism XE2, Oxygene for .NET)

Sample11.exe

Delphi for .NET (Borland Developer Studio 2006)

-

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 - TwinCAT2 Port=801, TwinCAT3 Port=851
    tcClient.Connect(801);
    
        //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();
    }
}