Chaque fois que je cours SafteyDepositBox.SetNewCode
je reçois un runtime error 216
. Une idée de ce qui cause cela? C'est l'erreur:Pascal - Qu'est-ce qui cause cette erreur d'exécution (216)?
Erreur d'exécution 216 à 00401EFC $
$ 00401EFC
$ 0040153D
00.401.596 $
$ 00406E31
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.
Voir cette question posée hier: http://stackoverflow.com/questions/42064576/pascal-access-violation-when-calling-a-variable -in-a-class –
Vous pouvez également compiler avec les options FPC '-gp -gl' pour obtenir un peu plus d'aide plutôt qu'une copie de pile brute. – tonypdmtr