我正在尝试检查数组中是否存在整数值,但是即使该数组中存在整数,该函数也会返回false。
这是我正在使用的代码。错误为404,但返回false:
const
cErrors: array [0 .. 3] of integer = (401,404,409,411);
function isInError(const error: integer; const sArray: array of integer): Boolean;
var
i: integer;
begin
Result := False;
for i in sArray do
if sArray[i] = error then
Result := True;
ShowMessage(error.ToString);// it's returining false always and this showmessage is just verify the error code
end;
我这样称呼它:
if (isInError(sPdf.LastErrorCode,cErrors)) then
ShowMessage(sPdf.LastErrorCode.toString);