2017-02-07 15 views
2

SafteyDepositBox.SetNewCodeを実行すると、いつでもruntime error 216と表示されます。どのようなアイデアがこれを引き起こしていますか? これはエラーです:あなたはちょうど私がパスカルを覚えて作られたOMGパスカル - このランタイムエラー(216)の原因は何ですか?

ランタイムエラー216 $ 00401EFC
$ 00401EFC
$ 0040153D

$ 00401596
$ 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. 
+0

を参照してください。この質問は昨日尋ね:

これは、オブジェクトのコンストラクタを呼び出す方法ですhttp://stackoverflow.com/questions/42064576/pascal-access-violation-when-calling-a-variable -in-a-class –

+0

'-gp -gl' FPCオプションでコンパイルして、生のスタックダンプではなく、もう少しの助けを得ることもできます。 – tonypdmtr

答えて

3

で!

SafetyDepositBox := SDB.Create(); 
+0

Ikr。私は自分でC#コーダーです。これは学校用のものです。 –

関連する問題