Ryan Vancity Gosling Ryan Vancity Gosling - 4 years ago 253
Pascal Question

Pascal - Whats causing this runtime error(216)?

Whenever I run SafteyDepositBox.SetNewCode I get a runtime error 216. Any idea whats causing this?
This is the error :

Runtime error 216 at $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.

MK. MK.
Answer Source

OMG you just made me remember Pascal!

This is how you call the object constructor:

SafetyDepositBox := SDB.Create();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download