I found the following code in an old document (1977!) and need to run it. However I get the following error message from FreePascal (2.6.4, Win64) at the first 'new':
(14, 9) Fatal: Syntax error, "identifier" expected but "TRUE" found
According to this('new') and this('record'), it should work, but it doesn't. Any suggestions?
program prog(input, output);
type ptr = ^node;
node = record position: 1 .. 512; fathers: array [0.. 4] of ptr;
case (* internal: *) boolean of
true: (ub: (minus, undef, plus);
left, right: 0..5;
rank: 0.. 4);
false: (present: boolean; pred, succ: ptr);
end;
procedure initialize(level: integer);
var v: ptr;
begin if level > 0 then
new(v,true)
else
new(v,false);
end
In your code you're calling the New procedure passing boolean values into its second parameter which for Free Pascal compiler signals to choose this overload:
procedure New(var P: Pointer; Cons: TProcedure);
which is used for allocating objects, where the second Cons parameter is used for passing the object's constructor method. So in this case the compiler was expecting a method, not a boolean value.
Since you are not allocating objects but records, you can call the New procedure just this way:
New(v);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With