DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I reference to a group and channel index

Hello,
 
I would like to know if I can make calculations, repeating by a loop for different groups, by referring to a Groupindex and a Channelindex.
Here is an example of what I'm trying to do:
 
if Chnname("[...]/[2]") = Speed 1  Then
RV1(1)=CHD(Find('''Speed 1'<60"), "Distance 1"
Else
RV1(1) =0
End if
 
this I want to repeat for different Groups so I've put this in a loop. The channelindex stays the same. I tried to fill in a variable for the groupindex however this returns an error: an invalid text operand is used within the formula.
Does anybody know how to solve this issue??
 
0 Kudos
Message 1 of 8
(3,879 Views)

Hello Robert!

My solution is:

Option Explicit
 
Dim i
Dim n1
Dim n2
 
' loop over all groups
For i=1 To GroupCount
 
  ' get the channel 'Speed 1' in the current group
  n1 = CNo("[" & i & "]/Speed 1")
 
  ' get the channel 'Distance 1' in the current group
  n2 = CNo("[" & i & "]/Distance 1")
 
  If (n1 > 0) and (n2 > 0) then
    ' find value
    RV1(1) = CHD(Find("Ch(" & n1 & " ) < 60"), n2)
  Else
    RV1(1) = 0
  End If
Next
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 8
(3,868 Views)
Hello Robert!
 
Additional Info: You should check if the Find is successfull!
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 3 of 8
(3,863 Views)

hello matthias,

 

This gives an error in the script. It's expecting a statement

 

0 Kudos
Message 4 of 8
(3,857 Views)
Hello Robert!
 
I copied the script from the post to verfiy your problem. It run without a problem.
 
Can you please post the excact error message out of the DIAdem report file.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 5 of 8
(3,854 Views)
Hello again Matthias,
 
The Exact error is:
 
Error in <Noname(1).VBS>(Line:32,Column: 7):
 
Expected Statement
 
the coordinates reference is at the beginning of
 
Option Explicit
0 Kudos
Message 6 of 8
(3,853 Views)
Hello Robert!
 
Did you inserted my code into a existing script?
 
The statement 'Option Explicit' may only appear once in a script before the first statement. Just delete it if it is already in your script.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 7 of 8
(3,845 Views)

OKe thank you very much for this information.

Regards Robert

 

0 Kudos
Message 8 of 8
(3,836 Views)