Sometimes data spans multiple files but you want to work with it as a single channel. This allows (assuming a suitable search has been performed) this to happen.
This works by loading the list of the results of the navigator, driving the main requirement: the data channels must be the results in the navigator window in the order in which you want them concatenated.
The script loads this list and loads the channels one by one, but for each channel it appends it to the first and then deletes it again. It is also attached below.
dim oResultChannels, oCurrChannel, oLoadedChannel, sFirstChannel
set oResultChannels = Navigator.Display.CurrDataFinder.ResultsList
For Each oCurrChannel in oResultChannels.Elements 'Could change to only selected.
'Either make first channel or load into existing channel.
If isEmpty(sFirstChannel) Then
'Loads root and channel group first time.
Set oLoadedChannel = Navigator.LoadData(oCurrChannel,"Load").Item(1)
'Handle first may load as root or group if it did not exist.
If oLoadedChannel.IsKindOf(eDataRoot) Then
Set oLoadedChannel = oLoadedChannel.ChannelGroups.Item(1).Channels.Item(1)
ElseIf oLoadedChannel.IsKindOf(eDataChannelGroup) Then
Set oLoadedChannel = oLoadedChannel.Channels.Item(1)
End If
'Assign the reference.
sFirstChannel = oLoadedChannel.GetReference(eRefTypeNameName)
Else ' Append the channels.
'This should now only load as a channel so removed the checking here.
set oLoadedChannel = Navigator.LoadData(oCurrChannel,"Load").Item(1)
Call ChnConcat(oLoadedChannel.GetReference(eRefTypeNameName),sFirstChannel)
Call ChnDelete(oLoadedChannel.GetReference(eRefTypeNameName))
End If
Next
Software
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.