// Attempts to parse 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 TryParse.Main;
var
BrowsePath: _UABrowsePath;
BrowsePathElement: _UABrowsePathElement;
BrowsePathParser: OpcLabs_EasyOpcUA_TLB._UABrowsePathParser;
BrowsePathResult: OleVariant;
Count: Cardinal;
Element: OleVariant;
ElementEnumerator: IEnumVariant;
StringParsingError: _StringParsingError;
begin
BrowsePathParser := CoUABrowsePathParser.Create;
StringParsingError := BrowsePathParser.TryParse('[ObjectsFolder]/Data/Static/UserScalar', BrowsePathResult);
// Display results
if StringParsingError <> nil then
begin
WriteLn('*** Error: ', StringParsingError.ToString);
Exit;
end;
BrowsePath := IUnknown(BrowsePathResult) as _UABrowsePath;
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;
// Attempts to 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 .
$BrowsePath = new COM("OpcLabs.EasyOpc.UA.Navigation.UABrowsePath");
$BrowsePathParser = new COM("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser");
$StringParsingError = $BrowsePathParser->TryParse("[ObjectsFolder]/Data/Static/UserScalar", $BrowsePath);
// 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 < $BrowsePath->Elements->Count; $i++)
{
printf("%s\n", $BrowsePath->Elements[$i]);
}
// Example output:
// StartingNodeId: ObjectsFolder
// Elements:
// /Data
// /Static
// /UserScalar
REM Attempts to 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 TryParse_Main_Command_Click()
OutputText = ""
Dim BrowsePathParser As New UABrowsePathParser
Dim stringParsingError As stringParsingError
Dim browsePath As Variant
Set stringParsingError = BrowsePathParser.TryParse("[ObjectsFolder]/Data/Static/UserScalar", browsePath)
' Display results
If Not stringParsingError Is Nothing Then
OutputText = OutputText & "*** Error: " & stringParsingError & vbCrLf
Exit Sub
End If
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
Rem Attempts to 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 .
Option Explicit
Dim BrowsePathParser: Set BrowsePathParser = CreateObject("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser")
Dim BrowsePath
Dim StringParsingError: Set StringParsingError = BrowsePathParser.TryParse("[ObjectsFolder]/Data/Static/UserScalar", BrowsePath)
' Display results
If Not (StringParsingError Is Nothing) Then
WScript.Echo "*** Error: " & StringParsingError
WScript.Quit
End If
WScript.Echo "StartingNodeId: " & BrowsePath.StartingNodeId
WScript.Echo "Elements:"
Dim BrowsePathElement: For Each BrowsePathElement In BrowsePath.Elements
WScript.Echo BrowsePathElement
Next