11-18-2024 08:14 AM
Hello,
I thought that the use of the Set statement when calling an analysis command was so that the result channel would then easily be available for further manipulation. However, this seems not to be the case as the following code doesn't work:
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim v_smooth, Win_other
Win_other = 19
Set v_smooth = ChnSmooth("v", "v_smooth", (Win_other-1)/2, "maxNumber", "byMeanValue")
'NV smoothed ends
Call DataBlInsertVal(v_smooth, 1, (Win_other-1)/2, NOVALUE, True)
Call DataBlInsertVal(v_smooth, v_smooth.Size-(Win_other-1)/2, (Win_other-1)/2, NOVALUE, True)
The error message says that Size is not supported by the object. I'm working around this by inserting the following line after the smoothing call:
Set v_smooth = Data.GetChannel("[1]/v_smooth")
Watching the status of the variable v_smooth after the smoothing call shows that it is an object variable. The help files, however, say that it's an ElementList type.
It seems to me that it would be more useful to define the results channel as an object from which I can access it's various properties. The addition of the extra line seems inefficient. Am I missing something?
What is the point of the ElementList type?
Regards,
Simon.
11-19-2024 06:19 AM
As the name ElementList suggests, the resulting object is a list of elements. Therefore, if you want to access a property of a single channel you have to take out this single element = channel from the list:
v_smooth.Item(1).Size
11-20-2024 07:45 AM
Thanks for the response.
If I need to refer to the specific element by using v_smooth.Item(1) then shouldn't I need to do that when passing the input channel to the smoothing function? In other words:
Call DataBlInsertVal(v_smooth.Item(1), v_smooth.Size-(Win_other-1)/2, (Win_other-1)/2, NOVALUE, True)
The previous line in the code worked without needing to specify the particular element in the list. How does the function know which element I am passing to it if I don't specify it?
Regards.
11-26-2024 10:42 AM
The first parameter of DataBlInsertVal is a channel list, so use v_smooth there. The second a numeric value, in that case calculated form the length of a certain channel: v_smooth.Item(1).Size
Call DataBlInsertVal(v_smooth, v_smooth.Item(1).Size ...
11-27-2024 02:53 AM
Thank you.
I must admit that whilst I understand what's going on, I'm still confused as to why commands like ChnSmooth provide their results in ElementList form. If they were working on multiple input channels then I can see why they would put all the output channels in a single list variable. However, ChnSmooth only works on one channel at a time, so why not just put the result in a channel object?
You would then have direct access to the channel properties without needing to know which element it is in the list.
Regards.