Hello everyone
It is an honour to join this community. I have come to ask for help in understanding what is going on

I have a funny problem. I have never been and will never be a professional programmer, but every time I try to learn a programming language I encounter an error in the introduction and it discourages me. And it's been like that for 30 years

This time I didn't give up, and I'm "struggling" with Pascal. I found a source, which should write all graphic modes of the card in the computer to a file. I will describe in order what I noticed.
1. the source copied from www does not compile
https://www.freepascal.org/docs-html/rtl/graph/modes.htmlExample
Program GetModeRange_Example;
Errors:
Hint: (11030) Start of reading config file D:\lazarus\fpc\3.2.0\bin\i386-win32\fpc.cfg
Hint: (11031) End of reading config file D:\lazarus\fpc\3.2.0\bin\i386-win32\fpc.cfg
Free Pascal Compiler version 3.2.0 [2021/02/21] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
(1002) Target OS: Win32 for i386
(3104) Compiling C:\Users\ABRONO~1\AppData\Local\Temp\project1.lpr
C:\Users\ABRONO~1\AppData\Local\Temp\project1.lpr(40,29) Error: (3069) Call by var for arg no. 3 has to match exactly: Got "LongInt" expected "SmallInt"
D:\lazarus\fpc\3.2.0\units\i386-win32\graph\graph.ppu:modes.inc(371,15) Hint: (5039) Found declaration: GetModeRange(SmallInt;var SmallInt;var SmallInt);
C:\Users\ABRONO~1\AppData\Local\Temp\project1.lpr(43,36) Warning: (5037) Variable "low" does not seem to be initialized
C:\Users\ABRONO~1\AppData\Local\Temp\project1.lpr(43,60) Warning: (5037) Variable "high" does not seem to be initialized
C:\Users\ABRONO~1\AppData\Local\Temp\project1.lpr(62,9) Error: (3208) Illegal assignment to for-loop variable "c"
D:\lazarus\fpc\3.2.0\units\i386-win32\graph\graph.ppu:graph.inc(2130,13) Hint: (5039) Found declaration: InitGraph(var SmallInt;var SmallInt;const ShortString);
project1.lpr(85) Fatal: (10026) There were 2 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: D:\lazarus\fpc\3.2.0\bin\i386-win32\ppc386.exe returned an error exitcode
I change this:
var low, high : smallint;
Next error:
project1.lpr(63,9) Error: Illegal assignment to for-loop variable "c"
in this for loop
for c := low to high do
begin
append(t);
writeln(t,' testing mode nr ',c);
close(t);
initgraph(gd,c,'');
res := graphresult;
workaround:
temp vars for this loop
tmp := c;
tmp2 := gd;
initgraph(tmp2,tmp,''); !!!!!!!!!!!!!{in this line}!!!!!!!!!!!!!!!!!!!!!!!
res := graphresult;
append(t);
{ An error occurred when entering the mode? }
if res <> grok then
writeln(t,grapherrormsg(res))
else
begin
write(t,'maxx: ',getmaxx,', maxy: ',getmaxy);
Writeln(t,', maxcolor: ',getmaxcolor);
closegraph;
end;
writeln(t);
WriteRes(gd);
close(t);
and in this part of source I need to REM line closegraph, because I received a message "Project GetModeRange raised exception class 'External: SIGSEGV'. At address 7774F583"
begin
write(t,'maxx: ',getmaxx,', maxy: ',getmaxy);
Writeln(t,', maxcolor: ',getmaxcolor);
// closegraph; {!!!!!!!!!!!!! this line!!!!!!!!!!!!!!!!}
end;
After all this, the program started and entered the available graphic modes into the file

What am I doing wrong that the examples from the FreePascal website don't want to work for me and I have to change the sources?