L
LIUYECAI
Unregistered / Unconfirmed
GUEST, unregistred user!
当程序运行时try...except..又侦测不到异常只是按 ESC 时出现提示指针操作错误.
代码是这个样子,
var
volt: array[1..20][1..2] of ^double
begin
try
while true do
begin
for i:=1 to 20 do
begin
new(volt[1]);
new(volt[2];
//getmem(volt[1],30)
//use getmem and freemem procedure
//getmem(volt[2],30)
//same error occur
AI_VRead(1,0,gain,volt[1])
//call procedure set volt[1]
AI_VRead(1,1,gain1,volt[2]);//call procedure set volt[2]
end;
for j:=1 to 20 do
begin
if volt[j][1]^ > MaxValue then
begin
CurrValue :=Maxvalue;
Maxvalue :=volt[j][1]^;
volt[j][1]^ := CurrValue;
end
.....//long code
end;
.........
for i:=1 to 20 do
begin
dispose(volt[1]);
dispose(volt[2]);
//freemem(volt[1]);
//freemem(volt[2]);
end;
Application.ProcessMessages;
if ((GetAsyncKeyState(VK_ESCAPE) and $8000) <> 0) or StopOk then
begin
break;
end;
end;
except
showmessage('an error occur!')
//inspect exception
end
代码是这个样子,
var
volt: array[1..20][1..2] of ^double
begin
try
while true do
begin
for i:=1 to 20 do
begin
new(volt[1]);
new(volt[2];
//getmem(volt[1],30)
//use getmem and freemem procedure
//getmem(volt[2],30)
//same error occur
AI_VRead(1,0,gain,volt[1])
//call procedure set volt[1]
AI_VRead(1,1,gain1,volt[2]);//call procedure set volt[2]
end;
for j:=1 to 20 do
begin
if volt[j][1]^ > MaxValue then
begin
CurrValue :=Maxvalue;
Maxvalue :=volt[j][1]^;
volt[j][1]^ := CurrValue;
end
.....//long code
end;
.........
for i:=1 to 20 do
begin
dispose(volt[1]);
dispose(volt[2]);
//freemem(volt[1]);
//freemem(volt[2]);
end;
Application.ProcessMessages;
if ((GetAsyncKeyState(VK_ESCAPE) and $8000) <> 0) or StopOk then
begin
break;
end;
end;
except
showmessage('an error occur!')
//inspect exception
end