02-18-2008 10:53 PM
02-19-2008 08:51 AM
Hi Craig,
If I understand you correctly, you wish to sort the order in which the curves appear in the VIEW legend, is that correct? One way to do this would be to programmatically assign the X and Y channels for each curve with the VIEW object variable in a VBScript. In this case it does not matter how the channels are arranged or named, since you will just assign the Group/Channel path for each channel to the correct VIEW curve.
Another way to do this would be to re-order or re-name the groups/channels in the Data Portal, but what you do in this case depends on how you are referencing the channels in the VIEW graphs. The standard channel referencing in DIAdem is [GroupIndex]/ChannelName, is this how you are referencing the channels for each VIEW curve? How are your data channels arranged in the DataPortal-- the data channels for each curve in a separate group, or all the channels in the same group? Do the channels have different names?
If all the channels for a given VIEW graph are in the same group and named differently, and if you want to achieve your goal without using the VIEW object variable, then you need to change your VIEW layout so that it references the channels by channel index, i.e.
[GroupIndex]/[ChannelIndex] ---> [1]/[1]
GroupName/[ChannelIndex] ---> Example/[1]
Now if you reorder the channels within that Group based on their custom property value with the ChnMove() command, their display order in the VIEW graph will change.
Ask if you have further questions,
Brad Turpin
DIAdem Product Support Engineer
National Instrument
02-19-2008 09:09 AM
Brad,
Yes, I would like to sort the order of the curves in the legend and since I am using the "n Systems" display type, I assume this order of the curves on the graph will match this.
The channels that I want to display on a given graph are in the same group and they have different names. Because the names of the channels are variable and unknown when the file is loaded, I use the [GroupIndex]/[ChannelIndex] syntax to refer to them. I think I understand how to reorder them with the ChnMove() command, but I'm not sure how to actually sort by a property. Do I need to populate an array with the property values, sort this with some string functions, and then reassign all the channels based on this, or is there a function in DIAdem that would simplify this process?
Thanks,
Craig
02-19-2008 03:31 PM
Hello Craig!
Unfortunately DIAdem doesn't have a adequate command. You have to use some lines of script code. Try this bubblesort adaption:
Option Explicit
Call GroupChnSort(1,"name")
Sub GroupChnSort(ByRef nGroupIndex, ByRef sgPropName)
Dim i
Dim j
Dim n
Dim anCNo()
If GroupChnCount(nGroupIndex) > 1 Then
ReDim anCNo( GroupChnCount(nGroupIndex)-1 )
For i=1 To GroupChnCount(nGroupIndex)
anCNo(i-1) = i
Next
For i = 0 to UBound(anCNo)
For j = i+1 to UBound(anCNo)
If ChnPropValGet("[" & nGroupIndex & "]/[" & anCNo(i) & "]", sgPropName) > _
ChnPropValGet("[" & nGroupIndex & "]/[" & anCNo(j) & "]", sgPropName) Then
n = anCNo(i)
anCNo(i) = anCNo(j)
anCNo(j) = n
End If
Next
Next
For i=1 To GroupChnCount(nGroupIndex)
Call ChnMove( anCNo(i-1), nGroupIndex, i)
Next
End If
End Sub
The string compare is casessensitive. You can wrap the ChnPropValGet with a UCase to change this.
Matthias
Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |
02-28-2008 03:34 PM