T
tgzhong
Unregistered / Unconfirmed
GUEST, unregistred user!
谁能帮我看看delphi调用api问题,先谢谢了<br><br>API原型定义<br>C format<br>int32 piar_compvaluesfil( <br>int32 pt,<br>int32 PIPTR * count,<br>int32 times[], <br>float rvals[], <br>int32 istats[], <br>char PIPTR * expression, <br>int32 rev, <br>int32 filt );<br><br>Returns<br>>0<br> System error <br>0<br> Success <br>-1<br> Bad point number <br>-101<br> Date not on line <br>-103<br> No data for this point for the passed time <br>-105<br> Bad time and date <br>-121<br> Invalid count parameter <br>-8xx<br> Expression Parsing Error <br>-9xx<br> Network Error <br><br>Arguments<br><br>pt (passed)oint number<br>count (passed, returned):Number of values<br>times (passed, returned):Time stamps of values<br>rvals (returned):Values in engineering units<br>istats (returned):Integer or status values<br>expression (passed):Expression string<br>rev (passed):Reverse sequence flag; TRUE to go backwards from times[0], FALSE to go forwards<br>filt (passed):Filter status flag, TRUE to return FilterFailStatus and FALSE to skip values at times when the expression is not satisfied.<br><br>//以下为我接口定义和调用的方式<br><br>//接口单元声明<br>type<br> int32 = Longint;<br> float64 = double;<br> TDynamicInt32Array = array of int32;<br> TDynamicSingleArray = array of Single;<br><br>function piar_compvaluesfil( pt:int32;var count:int32;times:TDynamicInt32Array;<br> rvals:TDynamicSingleArray; istats:TDynamicInt32Array;<br> expressionChar;rev:int32;filt:int32):int32;stdcall;external 'piapi32.dll';<br><br>//调用<br> var<br> expstrchar;<br> i:integer;<br> ret,scount,rev:int32;<br> times,istats:TDynamicInt32Array;<br> rvals:TDynamicSingleArray;<br>begin<br> setLength(times,2000);<br> setLength(istats,2000);<br> setLength(rvals,2000);<br><br> scount :=strtoint(Edit4.Text);<br> times[0] := DateTimetoUnix(StrToDateTime(Edit2.Text));<br> times[scount-1] :=DateTimetoUnix(Now);<br> New(expstr);<br> expstr :='''DCS01GEN900'''+'> 200';<br> Ret:=piar_compvaluesfil(13898,scount,times,rvals,istats,expstr,0,0);<br><br> if Ret = 0 then //此返回值为0正确,但我的返回值-12300。好像是expression不对,但该函数没有该错误信息<br> Memo2.clear;<br> for i:=0 to scount-1 do<br> begin<br> Memo2.Lines.Add(inttostr(i)+' || '+datetimetostr(UnixtoDatetime(times))+' || '+formatfloat('0.00',rvals));<br> end;