Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read out the channel length??

43 views
Skip to first unread message

XManBG

unread,
Aug 8, 2008, 5:10:15 AM8/8/08
to
Greets,
 
I've just tried to fill one channel with predefined values.  I've used a FOR .. TO loop to do this.  Then I wanted to set the length of the loop to be as long as the length of the previous channel in the same group.  I've tried to read out the previous channel length with Root.ChannelGroups(1).Channels(CNo("/NewChannel")-1)).Properties.Length and it didn't work.  It showed me an error:  "Root variable not defined" ?!  What's wrong??  How to read out the channel length??
 
Thanks in advance, Hristo
 

Brad Turpin

unread,
Aug 8, 2008, 11:10:22 AM8/8/08
to
Hi Hristo,
I'd recommend you try the age-old function ChnLength(CNo("/NewChannel")), although you could add additional error checking that might have uncovered the source of the trouble in your original code:
ChNum = CNo("/NewChannel")IF ChNum = 0 THEN Call AutoQuit("Could not find channel '/NewChannel'")ChLen = ChnLength(ChNum)
Brad TurpinDIAdem Product Support EngineerNational Instruments

Brad Turpin

unread,
Aug 11, 2008, 3:10:11 PM8/11/08
to
Hi Hristo,
I think the error code you're getting is misleading.  What the error should say is something like "The channel index parameter is invalid".  The trouble arises because there is a difference between the global channel number that CNo() returns and the group-relative channel index that is pertinent in the Channels collection.  If you only have 1 group, and if the channels were created in order and never moved, then these two properties "Channel.Number" and "Channel.GroupIndex" are in fact the same for each channel.  As soon as you have a second group, though, its first channel has Channel.GroupIndex = 1, and this is not equal to its Channel.Number property, which is > 1.  I also missed the "-1" in your original code post-- you want to reference the channel BEFORE the "NewChannel".  So, you first need to get the group-relative channel index of the "NewChannel", then reference the channel immediately previous to that channel, like this:
ChIdx = Data. Root. ChannelGroups( GroupDefaultGet).Channels( "NewChannel").Properties( "groupindex").ValueChLen = Data. Root. ChannelGroups( GroupDefaultGet).Channels(ChIdx-1 ).Properties( "length").Value
Ask if you have further questions,Brad TurpinDIAdem Product Support EngineerNational Instruments
0 new messages