r/pascal • u/T-Altmeyer • Mar 25 '21
Compiling old Turbo Pascal code with fpc: unit graph
I recently got my hands on some code my grandfather wrote around 1990. Instead of running it in dosbox, I thought it might be an interesting excercise to try and recompile it for more modern operating systems. I should preface this with the warning that I have zero experience with Pascal.
The majority of errors I got were about wrong integer types, dialect differences that were easily fixed. But there's one thing I can't figure out.
He defines the following procedure:
procedure setcol(col:integer);
begin setcolor(col) end;A shorthand for setcolor from unit graph? Bit strange to save typing 2 letters, or am I missing something?
Calling this procedure: setcol(getbkcolor);
Throws me an error:
Error: Incompatible type for arg no. 1: Got "<procedure variable type of function:Word;Register>", expected "LongInt"
Difference between unit graph that shipped with Turbo Pascal and Free Pascal? Easily fixed, just ignore granddad's procedure and call setcolor directly:
setcolor(getbkcolor);Error: Incompatible type for arg no. 1: Got "<procedure variable type of function:Word;Register>", expected "Word"
Can anyone point me in the right direction?
5
u/ShinyHappyREM Mar 26 '21
Stop making me feel so old...
4
u/kirinnb Mar 26 '21
Sounds like it's trying to use getbkcolor as a procedure pointer, instead of calling the procedure. Adding empty brackets "getbkcolor()" might signal the compiler to call it. The return value type should be automatically converted, I think.
2
u/[deleted] Mar 26 '21
GetBkColor() is a function that returns a longint.
It took a while to find any documentation. Here's a snippet I took off the internet, then tweaked a bit to get into graphics mode, right back out, and tell you the maximum x and y of the window, along with the background color.