// Parses an absolute  OPC-UA browse path and displays its starting node and elements.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
class procedure Parse.Main;
var
  BrowsePath: _UABrowsePath;
  BrowsePathElement: _UABrowsePathElement;
  BrowsePathParser: OpcLabs_EasyOpcUA_TLB._UABrowsePathParser;
  Count: Cardinal;
  Element: OleVariant;
  ElementEnumerator: IEnumVariant;
begin
  BrowsePathParser := CoUABrowsePathParser.Create;
  try
    BrowsePath := BrowsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar');
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;
  // Display results
  WriteLn('StartingNodeId: ', BrowsePath.StartingNodeId.ToString);
  WriteLn('Elements:');
  ElementEnumerator := BrowsePath.Elements.GetEnumerator;
  while (ElementEnumerator.Next(1, Element, Count) = S_OK) do
  begin
    BrowsePathElement := IUnknown(Element) as _UABrowsePathElement;
    WriteLn(BrowsePathElement.ToString);
  end;
  // Example output:
  // StartingNodeId: ObjectsFolder
  // Elements:
  // /Data
  // /Static
  // /UserScalar
end;
	 
	
		// Parses an absolute  OPC-UA browse path and displays its starting node and elements.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
$BrowsePathParser = new COM("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser");
try
{
    $BrowsePath = $BrowsePathParser->Parse("[ObjectsFolder]/Data/Static/UserScalar");
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    exit();
}
// Display results
printf("StartingNodeId: %s\n", $BrowsePath->StartingNodeId);
printf("Elements:\n");
for ($i = 0; $i < $BrowsePath->Elements->Count; $i++)
{
    printf("%s\n", $BrowsePath->Elements[$i]);
}
// Example output:
// StartingNodeId: ObjectsFolder
// Elements:
// /Data
// /Static
// /UserScalar
	 
	
		REM Parses an absolute  OPC-UA browse path and displays its starting node and elements.
REM
REM Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Private Sub Parse_Main_Command_Click()
    OutputText = ""
    
    Dim BrowsePathParser As New UABrowsePathParser
    On Error Resume Next
    Dim browsePath As UABrowsePath
    Set browsePath = BrowsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0
    
    ' Display results
    OutputText = OutputText & "StartingNodeId: " & browsePath.StartingNodeId & vbCrLf
    
    OutputText = OutputText & "Elements:" & vbCrLf
    Dim BrowsePathElement: For Each BrowsePathElement In browsePath.Elements
        OutputText = OutputText & BrowsePathElement & vbCrLf
    Next
    ' Example output:
    'StartingNodeId: ObjectsFolder
    'Elements:
    '/Data
    '/Static
    '/UserScalar
End Sub