// This example shows how to browse objects under the "Objects" node and display event sources.
class procedure BrowseEventSources.Main;
var
  ObjectNodeId: _UANodeId;
begin
  ObjectNodeId := CoUANodeId.Create;
  ObjectNodeId.StandardName := 'Objects';
  try
    BrowseFrom(ObjectNodeId);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;
end;
class procedure BrowseEventSources.BrowseFrom(NodeId: _UANodeId);
var
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  Count: Cardinal;
  Element: OleVariant;
  EndpointDescriptor: string;
  EventSourceNodeElement: _UANodeElement;
  EventSourceNodeElementEnumerator: IEnumVariant;
  EventSourceNodeElements: _UANodeElementCollection;
  ObjectNodeElement: _UANodeElement;
  ObjectNodeElementEnumerator: IEnumVariant;
  ObjectNodeElements: _UANodeElementCollection;
begin
  EndpointDescriptor := 'opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer';
  WriteLn;
  WriteLn;
  WriteLn('Parent node: ', NodeId.ToString);
  // Instantiate the client object
  Client := CoEasyUAClient.Create;
  // Obtain event sources
  EventSourceNodeElements := Client.BrowseEventSources(EndpointDescriptor, NodeId.ExpandedText);
  // Display event sources
  if EventSourceNodeElements.Count <> 0 then
  begin
    WriteLn;
    WriteLn('Event sources:');
    EventSourceNodeElementEnumerator := EventSourceNodeElements.GetEnumerator;
    while (EventSourceNodeElementEnumerator.Next(1, Element, Count) = S_OK) do
    begin
      EventSourceNodeElement := IUnknown(Element) as _UANodeElement;
      WriteLn(EventSourceNodeElement.ToString);
    end;
  end;
  // Obtain objects
  ObjectNodeElements := Client.BrowseObjects(EndpointDescriptor, NodeId.ExpandedText);
  // Recurse
  ObjectNodeElementEnumerator := ObjectNodeElements.GetEnumerator;
  while (ObjectNodeElementEnumerator.Next(1, Element, Count) = S_OK) do
  begin
    ObjectNodeElement := IUnknown(Element) as _UANodeElement;
    BrowseFrom(ObjectNodeElement.NodeId);
  end;
end;
	 
	
		// This example shows how to browse objects under the "Objects" node and display event sources.
// Start browsing from the "Objects" node
$ObjectNodeId = new COM("OpcLabs.EasyOpc.UA.AddressSpace.UANodeId");
$ObjectNodeId->StandardName = "Objects";
try
{
    BrowseFrom($ObjectNodeId);
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    exit();
}
function BrowseFrom($NodeId) {
    $EndpointDescriptor = "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer";
    printf("\n");
    printf("\n");
    printf("Parent node: %s\n", $NodeId);
    // Instantiate the client object
    $Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
    // Obtain event sources
    $EventSourceNodeElements = $Client->BrowseEventSources($EndpointDescriptor, $NodeId->ExpandedText);
    // Display event sources
    if ($EventSourceNodeElements->Count != 0) {
        printf("\n");
        printf("Event sources:\n");
        foreach ($EventSourceNodeElements as $EventSourceNodeElement)
        {
             printf("%s\n", $EventSourceNodeElement);
        }
     }
    // Obtain objects
    $ObjectNodeElements = $Client->BrowseObjects($EndpointDescriptor, $NodeId->ExpandedText);
    // Recurse
    foreach ($ObjectNodeElements as $ObjectNodeElement)
    {
         BrowseFrom($ObjectNodeElement->NodeId);
    }
}
// Example output (truncated):
//
//
//Parent node: ObjectsFolder
//
//
//Parent node: Server
//
//Event sources:
//Green -> nsu=http://opcfoundation.org/Quickstarts/AlarmCondition ;ns=2;s=0:/Green (Object)
//Yellow -> nsu=http://opcfoundation.org/Quickstarts/AlarmCondition ;ns=2;s=0:/Yellow (Object)
//
//
//Parent node: Server_ServerCapabilities
//...
	 
	
		Rem This example shows how to browse objects under the "Objects" node and display event sources.
Option Explicit
' Start browsing from the "Objects" node
Dim ObjectsNodeId: Set ObjectsNodeId = CreateObject("OpcLabs.EasyOpc.UA.AddressSpace.UANodeId")
ObjectsNodeId.StandardName = "Objects"
On Error Resume Next
BrowseFrom ObjectsNodeId
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0
Sub BrowseFrom(NodeId)
    Dim endpointDescriptor
    endpointDescriptor = "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer"
    WScript.Echo 
    WScript.Echo 
    WScript.Echo "Parent node: " & NodeId
    ' Instantiate the client object
    Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
    ' Obtain event sources
    Dim EventSourceNodeElementCollection: Set EventSourceNodeElementCollection = Client.BrowseEventSources( _
        endpointDescriptor, NodeId.ExpandedText)
    ' Display event sources
    If EventSourceNodeElementCollection.Count <> 0 Then
        WScript.Echo 
        WScript.Echo "Event sources:"
        Dim EventSourceNodeElement: For Each EventSourceNodeElement In EventSourceNodeElementCollection
            WScript.Echo EventSourceNodeElement
        Next
    End If
    
    ' Obtain objects
    Dim ObjectNodeElementCollection: Set ObjectNodeElementCollection = Client.BrowseObjects( _
        endpointDescriptor, NodeId.ExpandedText)
    ' Recurse
    Dim ObjectNodeElement: For Each ObjectNodeElement In ObjectNodeElementCollection
        BrowseFrom ObjectNodeElement.NodeId
    Next
End Sub
' Example output (truncated):
'
'
'Parent node: ObjectsFolder
'
'
'Parent node: Server
'
'Event sources:
'Green -> nsu=http://opcfoundation.org/Quickstarts/AlarmCondition ;ns=2;s=0:/Green (Object)
'Yellow -> nsu=http://opcfoundation.org/Quickstarts/AlarmCondition ;ns=2;s=0:/Yellow (Object)
'
'
'Parent node: Server_ServerCapabilities
'...