01-16-2014 03:09 AM - edited 01-16-2014 03:27 AM
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!
Solved! Go to Solution.
01-16-2014 11:22 AM
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
01-17-2014 07:43 AM - edited 01-17-2014 07:44 AM
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