// 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 .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
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 .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
$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 .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.
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 .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.
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