DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Move ChannelGroup to new position

Solved!
Go to solution

 Hi,

 

Not for the first time I'm having trouble getting Move for Data to work properly (previous problem here: https://forums.ni.com/t5/DIAdem/Move-method-for-data-working-on-some-installations-and-not/m-p/40584...)

 

My data file has two groups in it and all I want to do is move the second group to the first position. I have tried various combinations and argument entries but none of them are working.

 

My code started out as:

Call Data.Move(Data.Root.ChannelGroups("Results"), Data.Root.ChannelGroups(1))

And then, using the advice from the previous time I submitted this problem, progressed to:

Dim FromGrp, ToGrp
Set FromGrp = Data.Root.ChannelGroups("Results")
Set ToGrp = Data.Root.ChannelGroups(1)
Call Data.Move(FromGrp, ToGrp)

I also tried the intermediate cases where only one of the arguments was defined using Set and the other typed in longhand.

 

The help files state that the source should be type Element <Data> and suggest that a channelgroup is a valid element. The destination should be type ElementList <Data> or type Element <Data>. Since it is stated that "If you assign an Element <Data> type object to the Destination parameter, the parameter determines the object behind which DIAdem moves the object you want to move. In this case, DIAdem ignores the DestIndex parameter.", it would seem correct to define a channelgroup again and that DIAdem will define this as the first group in the portal and place the source group behind it. Unfortunately, there is no example of moving a group.

 

If I use the script recording feature, then the given code is:

Call Data.Move(Data.Root.ChannelGroups(2),Data.Root.ChannelGroups,1)

 

Both of the arguments are (or would appear to be) of the type Element <Data> and yet if the destination is of this type and it's stated that the destination index is ignored, how could the given destination work with also giving the destination index?

 

Could someone clarify this confusion for me please?

 

Thanks.

 

0 Kudos
Message 1 of 6
(1,264 Views)

Hi Simon_Aldworth,

 

A small detail is important here:

Data Element – a single element like a certain channel or channel group

Data Element List – a list of channels or channel groups (or all channel groups)

 

The source is always a single data element.

The destination can be either a single data element or a data element list.

The index stands for the position for the destination and is optional.

 

Case 1: The destination is a single data element

The source element will be moved behind the destination element. The index is ignored.

Example: group 1 will be moved behind group 2. Which means that group 1 will be the third channel group.

call Data.Move(Data.Root.ChannelGroups(1), Data.Root.ChannelGroups(2))

 

Case 2: The destination is a data element list

The source element will be moved to the position of the index.

Example: group 2 will be moved to the first position. Which means that group 1 will be the first channel group.

call Data.Move(Data.Root.ChannelGroups(2), Data.Root.ChannelGroups, 1)

If you don’t set the index, the source will be moved to the end of the destination.

 

I hope this explanation makes the function of MOVE a bit more transparent.

 

Greetings

Walter

0 Kudos
Message 2 of 6
(1,206 Views)

Thanks Walter.

 

I was initially going to reply that my first piece of code has exactly the required form as your first case: two specific groups and no index. However, whilst writing out my reply I may have realised why my code didn't work, and I'm guessing it's something that you didn't spot in my post: I have misunderstood the definition of 'behind'. I took it to mean earlier in the group count, i.e. 1 is behind 2. However, it's the other way around: 2 is behind 1.

 

Presumably, if I adjust my code by swapping the groups then it should work:

Call Data.Move(Data.Root.ChannelGroups(1), Data.Root.ChannelGroups("Results"))

 

I tried it but it didn't. An error message claims that 'the target index is not in the valid range.' I then adjusted to code to exactly match your first case and it still doesn't work.

 

I then started with an empty portal and created two groups, each with a couple of empty channels. I got the same error message. I then added a third group and the code executed but I ended up with the groups in the order 2, 3, 1 instead of 2, 1, 3.

 

It strikes me that there are some critical but unstated limitations to using the Move method by using two specific groups and no index.

 

Regards.

0 Kudos
Message 3 of 6
(1,196 Views)
Solution
Accepted by Simon_Aldworth

Hi Simon_Aldworth,

 

Group 1 behind group 2 means that group 1 will be the third group.

If you have only 2 groups and the first group should be positioned as second group, then the first group is behind the 1 group.

call Data.Move(Data.Root.ChannelGroups(1), Data.Root.ChannelGroups(1))

 

Greetings

Walter

0 Kudos
Message 4 of 6
(1,192 Views)

Thanks for the clarification Walter.

 

Whilst I see the logic now that you've explained it, I don't find it intuitive based on the information in the help files. Perhaps they could be updated to give the examples you have given here?

 

Regards.

0 Kudos
Message 5 of 6
(1,187 Views)

Yes, I will share this info with R&D

 

Greetings

Walter

0 Kudos
Message 6 of 6
(1,180 Views)