DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

CHD : string is used as index, change of datatype? String to double?

Solved!
Go to solution

Hi,

I'm new to Diadem. I'm trying to read the row-numbers of a channel and afterwards to read data from a channel which is in the same row of another channel. 

Therefore I use the function CHD but my index doesn't seem to fit. What do I have to change in the code?

 

error:

CHD(2,NOVALUE):=785 wird die Textvariable "..CHD(2,>N<OVALUE).." als Index verwendet. Diese Verwendung ist unzulässig.

 

code:

 

DIM intloop, zeilenwerte
DIM zeile, aktwert, index
Call ChnAlloc("zeilenwerte", lang, 1, DataTypeFloat64)          'create channel,  "lang" is the size of a channel
index = 0 for index = 1 to lang index=index+1 aktwert = zeit(index) 'get value which is going to be compared in PNO in the next code line zeile=PNo(myChannel, aktwert) 'it returns the row no by comparing aktwert with a value in myChannel CHD(zeile,zeilenwerte)=intloop ' <--- here the error occurs. try to get the value in a row @index do the datatypes not match? what is to do then? Next

 

 

Thank you a lot for your help!

-
0 Kudos
Message 1 of 3
(6,007 Views)
Solution
Accepted by topic author budist

Hi budist,

 

It looks to me like you'd be better off using "Linear Mapping" in the ANALYSIS palette "Curve fitting", but you should be able to get your code to work by passing the channel name in that second parameter instead of an empty channel variable.  You'd have noticed this if you had OPTION EXPLICIT as the first line of your code-- always a good idea.

 

CHD(zeile,"zeilenwerte")=intloop 

 

Brad Turpin

DIAdem Product Support Engineer
National Instruments

Message 2 of 3
(5,974 Views)

beside other things I had a missunderstanding of the CHD command.

Now I have a solution:

 

index = 1
for index = 1 to lang     
  aktwert = zeit(index)       
  zeile=PNo(myChannel, aktwert)   
  neuwert=CHD(zeile,weg)          'get value at "zeile" and put into "neuwert"
  CHD(index,"wegwerte") = neuwert 'write "neuwert" into channel
Next

 Thank you!

 

addition: if someone needs to read from a text file with a dialog:

 

Call FileNameGet("DATA","FileRead","..path.." & ".txt","name of data type" [you see the exact name, when the dialog opens, e.g. "labview.....file" for a .txt file]) 
If (DlgState = "IDOk") Then   
DataDrvUser = "..path..."
Call DataFileLoad(FileDlgFile & ".TXT")
End If

 

-
0 Kudos
Message 3 of 3
(5,946 Views)