03-04-2015 03:56 AM
Dear all,
During the work with Diadem I got two troubles. Could you please take a look and show me the wrong if you find the issue?
1.) Here is my trouble as we see the photo below. It is most important problem which I have. I really have no idea why it could happened. It is alway happened to find a value with decimal type's variable, and even that variable is changed to "str()".
setlocale("en-gb") dim Min_point,Index_low,result Min_point=val(Data.Root.ChannelGroups(1).Channels("CopyYangle").Properties("minimum").Value) Min_point=round(Min_point,6) Min_point=str(Min_point) msgbox("The Min.Value is: "&Min_point) Index_low=Chnfind("ch(""CopyYangle"")<="&Min_point&"", 1) msgbox("Index No. of Min. Value is: "&Index_low) Index_low=Chnfind("ch(""CopyYangle"")<=-0.11374 ", 1) msgbox("Index No. of Min. Value is: "&Index_low)
2.) Still the problem with ChnFind() or ChnFindreverse(). If I change the Rounds off a number to the nearest integer with the function "Round()" it might not work in ChnFindreverse(). Such like it works under 4, 6, 8 and even 7 but doesn't work with 3 and 5. Is this logical?
setlocale("en-gb") Dim XE, Xchannel, Ychannel,round_N0 Xchannel = "[2]/Right" T1 = Xchannel R1 =val(Data.Root.ChannelGroups(2).Channels("Right").Properties("maximum").Value) round_N0=4 ' <========= 3 and 5 Not work, 4, 6, 7, 8 .... work R1 =round(R1,round_N0) ' <========= msgbox("Max. point is: " &R1 &VbCrlf& "Round Nr is: "&round_N0) L1 = ChnFindReverse ("Ch(T1)>=R1",0) msgbox("Index number for Max.Point is: "&L1 &VbCrlf& "Round Nr is: "&round_N0)
.tdx is a valid extensions for an attachement?
If you couldn't open the TMD file. Please remove ".tdv" the attacments file name to make sure it is "ChnFind.tdx" but not "ChnFind.tdx.tdv".
Kind regards / Mit freundlichen Grüßen
J.Huang
03-05-2015 05:34 PM
Hello J.Huang,
I downloaded the files and was able to get it to work. It looks like when you format the minimum value to a string, you loose precision and then ChnFind doesn't find the value your are looking for. He is an example which worked for me :
Set oChnY = Data.Root.ChannelGroups(2).Channels("Right") sgValue = str(oChnY.Properties("minimum").Value,"d.ddddddddddddddd") Index = ChnFindReverse("Y<="&sgValue,,Array("Y"),Array(oChnY)) LogFileWrite(Index)
Using symbols (parameters 3 and 4) is not necessary to get the solution. The key is teh second value for "str" which formats using more digits. As soon as you reduce the number of digits, you may no longer get a result.
Ther is an alternative to ChnFind, in case there is only one occurance in teh signal which has the minimum value
Set oChnY = Data.Root.ChannelGroups(2).Channels("Right") Index = PNo(oChnY,oChnY.Properties("minimum").Value) LogFileWrite(Index)
I hope one of the two options works for you. I tested the approach with teh first channel too and it worked as well
03-06-2015 08:23 AM
Hallo AndreasH_Ha,
Thank you very much for your help!
Yes ,it is working now.
Thanks
Best regards,
J.Huang