08-12-2016 11:54 AM
Hi, I have a text channel, channel length is more than 10,000.
Whenever the value in this channel changes, I need to detect and find out index.
I can loop through the channel and compare if the channel is short. Any better ways to do this?
Thank you.
Solved! Go to Solution.
08-13-2016 10:25 AM
Hi IIx,
Using the ChnFind() command in a loop will perform much faster than accessing each channel value individually in a VBScript loop. If you have trouble figuring this out, please post an example data set with such a text channel in it.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-15-2016 10:24 AM
Hi Brad,
Thank you for you response. I was tring to use the combination of chnfind() and strcomp().
However, I can't get the syntax correct. Here is what I did:
Str1 = "test" -- Str1 is a constant string
Str2 = cht(1,"Group1/Channel1") -- Str2 is as string value from a channel.
Str2 = "What"
startIndex = 200
Indexfind = chnfind("strcomp(Str1,Str2)<>0", startIndex)
The script runs, no error message, it won't find corrext index either. Please help.
Thank you very much.
08-15-2016 05:16 PM - edited 08-15-2016 05:17 PM
Hi IIx,
The ChnFind expression can only reference global DIAdem variables. So you either need to GlobalDim() your "Str2" variable or just use one of the existing temporary T1, T2... variables. Also, you want to refer to the entire channel in the expression, not just one of the channel's values. The motivation to use ChnFind is so that the search through the channel happens in the function call and not with VBScript primitives.
T1 = "Group1/Channel1" T2 = "test" startIndex = 200 Indexfind = ChnFind("Ch(T1) = T2", startIndex)
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-23-2016 02:01 PM
Hi Brad,
Thank you for your reply.
It worked this way, only minor changes needed.
For T2 is a string here, I need to use cstr(T2) instead of T2 in the chnfind().