DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

an invalid text operand 0 is used within the index operation of the formula chd(1,0)

Hello,

 

I have written a small program as below. My data portal is loaded with example file Example.tdm with the channels time,speed,revs and torque respectively. I would like to create a channel with the calculation as below but when I excute I am getting the error as

"an invalid text operand 0 is used within the index operation of the formula chd(1, 0)".

Pls help me to solve this issue.

The script written is as below.

 

Dim i
Globaldim ("diacalG")
Globaldim ("Read")
Globaldim ("WR")
Globaldim ("Length")
  Length = chnlength("Revs")
 Call chnalloc("diacalG",Length,1,datatypefloat64,,Targetgroupindex,5)
 For i = 1 To Length
 Read = chd(1,"channel2")
 Write = 1.11824*exp(-5)*31*Read^2
 chd(1,"diacalG") = Write
 Next

0 Kudos
Message 1 of 3
(5,543 Views)

You have to specify the group when using the channel name of Chd, so "group1/diacalG" or "[1]/diacalG"  Depends on what group your channel is in.  

 

This would do what you want MUCH faster

 

Call Calculate("Ch(""[1]/diacalG"")= 1.11824*exp(-5)*31*Ch(""[1]/channel2"")^2")

 

Replace the 1 with the group number you are using.  

 

 

The calculate function uses diadems built in calculator.  To use calculate you have to send it a string , so Call Calculate(Your string).  The Ch function just returns the channel.  Since the ch function needs strings as well, you have to use 2 double quotes to put a single quote in a string.  So, MsgBox("Hello World") will output Hello World, but if you used MsgBox("Hello ""The"" World"), you would get Hello "The" World.  You could also use Ch(1) for the first channel in the index.  

 

0 Kudos
Message 2 of 3
(5,527 Views)

Thank you very much Mr.Russel

It is working.

0 Kudos
Message 3 of 3
(5,516 Views)