M
may158
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL中函数间变量引用问题?
DLL编程
问题:在函数B_BOT()中如何引用函数B_TOP()中的XX?
不用全局变量.
unit FUNCLIST;
interface
uses
Math, DATADEF, SysUtils;
implementation
function B_TOP(pData: pTagCALCINFO): integer
stdcall;
var
i, last: integer;
xx: array of integer;
top: array of Single;
begin
last := pData^.m_nNumData - 1;
SetLength(top, last * SizeOf(Single));
SetLength(xx, last * SizeOf(Single));
xx[0] := 1;
for i := 0 to last do begin
top := pData^.m_pData.m_fHigh;
if top > top[i - 1] then begin
pData^.m_pResultBuf := top;
xx := 1;
end else
xx := 0
end;
SetLength(top, 0);
SetLength(xx, 0);
Result := 0;
end;
function B_BOT(pData: pTagCALCINFO): integer
stdcall;
var
i, last: integer;
bot: array of Single;
begin
last := pData^.m_nNumData - 1;
SetLength(bot, last * SizeOf(Single));
for i := 0 to last do begin
bot := pData^.m_pData.m_fLow;
if xx = 1 then begin //引用上边函数B_TOP中的xx作为限制条件-如何引用???
pData^.m_pResultBuf := bot;
end;
end;
SetLength(bot, 0);
SetLength(xx, 0);
Result := 0;
end;
exports //DLL输出函数
B_TOP,
B_BOT;
end.
DLL编程
问题:在函数B_BOT()中如何引用函数B_TOP()中的XX?
不用全局变量.
unit FUNCLIST;
interface
uses
Math, DATADEF, SysUtils;
implementation
function B_TOP(pData: pTagCALCINFO): integer
stdcall;
var
i, last: integer;
xx: array of integer;
top: array of Single;
begin
last := pData^.m_nNumData - 1;
SetLength(top, last * SizeOf(Single));
SetLength(xx, last * SizeOf(Single));
xx[0] := 1;
for i := 0 to last do begin
top := pData^.m_pData.m_fHigh;
if top > top[i - 1] then begin
pData^.m_pResultBuf := top;
xx := 1;
end else
xx := 0
end;
SetLength(top, 0);
SetLength(xx, 0);
Result := 0;
end;
function B_BOT(pData: pTagCALCINFO): integer
stdcall;
var
i, last: integer;
bot: array of Single;
begin
last := pData^.m_nNumData - 1;
SetLength(bot, last * SizeOf(Single));
for i := 0 to last do begin
bot := pData^.m_pData.m_fLow;
if xx = 1 then begin //引用上边函数B_TOP中的xx作为限制条件-如何引用???
pData^.m_pResultBuf := bot;
end;
end;
SetLength(bot, 0);
SetLength(xx, 0);
Result := 0;
end;
exports //DLL输出函数
B_TOP,
B_BOT;
end.