// Attempts to parse a relative OPC-UA browse path and displays its elements.
class procedure TryParseRelative.Main;
var
BrowsePathElement: _UABrowsePathElement;
BrowsePathElements: _UABrowsePathElementCollection;
BrowsePathParser: OpcLabs_EasyOpcUA_TLB._UABrowsePathParser;
Count: Cardinal;
Element: OleVariant;
ElementEnumerator: IEnumVariant;
StringParsingError: _StringParsingError;
begin
BrowsePathElements := CoUABrowsePathElementCollection.Create;
BrowsePathParser := CoUABrowsePathParser.Create;
StringParsingError := BrowsePathParser.TryParseRelative('/Data.Dynamic.Scalar.CycleComplete', BrowsePathElements);
// Display results
if StringParsingError <> nil then
begin
WriteLn('*** Error: ', StringParsingError.ToString);
Exit;
end;
ElementEnumerator := BrowsePathElements.GetEnumerator;
while (ElementEnumerator.Next(1, Element, Count) = S_OK) do
begin
BrowsePathElement := IUnknown(Element) as _UABrowsePathElement;
WriteLn(BrowsePathElement.ToString);
end;
// Example output:
// /Data
// .Dynamic
// .Scalar
// .CycleComplete
end;
// Attempts to parse a relative OPC-UA browse path and displays its elements.
$BrowsePathElements = new COM("OpcLabs.EasyOpc.UA.Navigation.UABrowsePathElementCollection");
$BrowsePathParser = new COM("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser");
$StringParsingError = $BrowsePathParser->TryParseRelative("/Data.Dynamic.Scalar.CycleComplete", $BrowsePathElements);
// Display results
if (!is_null($StringParsingError)) {
printf("*** Error: %s\n", $StringParsingError);
exit();
}
printf("StartingNodeId: %s\n", $BrowsePath->StartingNodeId);
printf("Elements:\n");
for ($i = 0; $i < $BrowsePathElements->Count; $i++)
{
printf("%s\n", $BrowsePathElements[$i]);
}
// Example output:
// /Data
// .Dynamic
// .Scalar
// .CycleComplete
Rem Attempts to parse a relative OPC-UA browse path and displays its elements.
Private Sub TryParseRelative_Main_Command_Click()
OutputText = ""
Dim BrowsePathElements As New UABrowsePathElementCollection
Dim BrowsePathParser As New UABrowsePathParser
Dim stringParsingError As stringParsingError
Set stringParsingError = BrowsePathParser.TryParseRelative("/Data.Dynamic.Scalar.CycleComplete", BrowsePathElements)
' Display results
If Not stringParsingError Is Nothing Then
OutputText = OutputText & "*** Error: " & stringParsingError & vbCrLf
Exit Sub
End If
Dim BrowsePathElement: For Each BrowsePathElement In BrowsePathElements
OutputText = OutputText & BrowsePathElement & vbCrLf
Next
' Example output:
'/Data
'.Dynamic
'.Scalar
'.CycleComplete
End Sub