08-08-2008 03:53 AM
08-08-2008 09:42 AM
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 Turpin
DIAdem Product Support Engineer
National Instruments
08-11-2008 04:16 AM
08-11-2008 02:07 PM
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").ValueAsk if you have further questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments