Pascal - 是什么导致了这个运行时错误 (216)?
Pascal - Whats causing this runtime error(216)?
每当我 运行 SafteyDepositBox.SetNewCode
我得到一个 runtime error 216
。知道是什么原因造成的吗?
这是错误:
Runtime error 216 at [=13=]401EFC
[=13=]401EFC
[=13=]40153D
[=13=]401596
[=13=]406E31
program Boxy;
{$MODE OBJFPC}
{$M+}
type
SDB = class
private
State : string;
Code : string;
public
Constructor Create();
procedure SetNewCode(newcode:string);
function Valid(s:string):boolean;
end;
constructor SDB.Create();
begin
State := 'Open-NoCode';
Code := '';
end;
procedure SDB.SetNewCode(newcode:string);
begin
Code := newcode;
writeln(Code);
end;
function SDB.Valid(s:string):boolean;
var
IsValid : boolean;
begin
If (length(s) = 4) then
IsValid := true
else
IsValid := false;
Valid := IsValid;
end;
var
SafetyDepositBox : SDB;
begin
SafetyDepositBox.Create();
SafetyDepositBox.SetNewCode('r2d2');// runtime error 216 here
end.
天哪,你让我想起了 Pascal!
这是调用对象构造函数的方式:
SafetyDepositBox := SDB.Create();
每当我 运行 SafteyDepositBox.SetNewCode
我得到一个 runtime error 216
。知道是什么原因造成的吗?
这是错误:
Runtime error 216 at [=13=]401EFC
[=13=]401EFC
[=13=]40153D
[=13=]401596
[=13=]406E31
program Boxy;
{$MODE OBJFPC}
{$M+}
type
SDB = class
private
State : string;
Code : string;
public
Constructor Create();
procedure SetNewCode(newcode:string);
function Valid(s:string):boolean;
end;
constructor SDB.Create();
begin
State := 'Open-NoCode';
Code := '';
end;
procedure SDB.SetNewCode(newcode:string);
begin
Code := newcode;
writeln(Code);
end;
function SDB.Valid(s:string):boolean;
var
IsValid : boolean;
begin
If (length(s) = 4) then
IsValid := true
else
IsValid := false;
Valid := IsValid;
end;
var
SafetyDepositBox : SDB;
begin
SafetyDepositBox.Create();
SafetyDepositBox.SetNewCode('r2d2');// runtime error 216 here
end.
天哪,你让我想起了 Pascal!
这是调用对象构造函数的方式:
SafetyDepositBox := SDB.Create();