06-17-2020 10:09 AM
Hello,
I am trying to create a For Loop, and within the for loop, event searches would be performed for different channel values.
Is it possible to use a variable such as 'x' in the event search command so that it can loop?
Thank you,
Claudia
06-17-2020 12:30 PM
Sorry, can you clarify:
What are "event searches"? What is a "variable"? What is "it" that should loop? ...?
06-17-2020 02:22 PM
Hi, yes sorry---
In DIAdem, there is a function/command that is ChnEventxxx. Basically it searches channels for something you specify, and you can do AND/OR Operations between channels.
What I am trying to do is do the ChnEventxxx command for multiple ranges of data. For example, 45-47; 47-49; etc. That is what would change in every loop.
I tried setting a 'variable' x=45. And used it the bounds within the event search command, but an error occurred and said that it is an invalid input.
So basically my question is: Is it possible to have a loop around ChnEventxxx commands, where what is changing is within the command?
06-19-2020 10:52 AM
Dim x 'Declare Variables
x = 0.5 'Define Variables
For x = 0.5 to 0.975
ChnEventList1 = ChnEventDetectionWindow("", "[6]X_Avg", x, x+0.025, 0, 0)
...
...
...
Next
Here is the script I have. Is this more clear? So for each loop, the range (bolded) changes.
Thank you for any info you can provide!
06-23-2020 06:30 AM
Yes, it is possible to use ChnEvent... function in a loop like you did.
The reason for the error is caused by other problems. If you send us a dataset and script part we can try to reproduce it and analyse the problem.
Greetings
Walter
06-24-2020 09:49 AM
Hello,
I can not send the data because the file is too large. However, can you explain what my error is and how I can attempt to fix it? Is there a specific syntax I must use with the variable, "x" to use it within the command?
Thank you,
CJ
07-02-2020 04:01 PM - edited 07-02-2020 04:03 PM
Hi CJ,
I have a couple thoughts on the script you have provided.
First of all, the two parameters you have filled with "x" and "x+0.025" in the "ChnEventDetectionWindow()" function in your script-- those parameters define the vertical window within which the data must reside in order to count as a desired event. So really these are Y1 and Y2 parameters. If you're trying to loop from left to right along the X axis of your data curve using the "x" variable, then you're setting the window values incorrectly.
Second of all, a FOR loop in VBScript only works with integers. There's no way to run a FOR loop from "x = 0.5 to 0.975" directly. If you do want to run sequential event searches with an iteratively moving vertical window, you could do something like this, converting from integer FOR looping to an analog Y range:
For n = 0 TO nMax
Y1 = 0.5 + 0.025*(n+0)
Y2 = 0.5 + 0.025*(n+1)
ChnEventList1 = ChnEventDetectionWindow("", "[6]/X_Avg", Y1, Y2, 0, 0)
Next\bradt\AppData\Local\Programs\Python\Python36\"
Third, your "[6]X_Avg" channel reference needs a Group/Channel separator => "[6]/X_Avg"
Brad Turpin
Principal Technical Support Engineer
National Instruments
07-06-2020 10:06 AM
Hi Brad,
Thank you for the response.
I am looking to identify the Y1 and Y2 range, I see my variable name decisions are misleading.
I also have now:
for x=0.5 to 0.975 step 0.025
and it seems to be working.
Thanks,
Claudia