However, I would really like the "increasing the buffer" solution to work as I would not need to change my code much. But I have tried that and it did not increase the speed of reading and writing. Maybe because I had to read value in char type variables, as mentioned in the tutorial, but I used ansistring and longint var instead.
No, you don't have to do read(ch); You need to specify a buffer for the read file and a buffer for the write file. FPC will
also use that buffer for
readln and
writeln operations (flushing it to disk when necessary), not just for read(char). You can see this in the source-code at fpc\rtl\inc\text.inc (fpc_ReadLn_End, fpc_Writeln_End and SetTextBuf).
var
Bufin,Bufout : Array[1..60000] of byte;
//....
SetTextBuf (t[1],Bufin);
SetTextBuf (t[2],Bufout);
I tried some sample code with a file with 6.000.000 lines (about 100MB) doing readln and writeln in a loop just takes a few seconds (at most) to completely copy the file (even without setting a larger buffer with SetTextBuf). So I'm guessing you're doing something extra that takes this time. You could try commenting out all the writeln's to see if it speeds up your code.
Otherwise you could strip this code to a working example-program and post it somewhere with a sample file so we can properly debug it (to see where the speed-problem lies).
I remember when i used turbo pascal a few years back the compiler would give me an error and I had to start putting procedures in units but then it could not compile because it did not have enough memory to compile that many units.
LOL, I still get this now and then with the Borland Pascal program we still support. Borland Pascal is DOS and 16bits. The total data-segment (global variables of all units) could only be 65536 bytes. There are more limits with Borland Pascal but with FPC you won't hit the limits of 32bit (or even 64bit) that easy. (2GB for 32bit, or even 3GB with the /3GB parameter)
Dividing you code into logical units will help you keep your code manageable.
O yeah... Gotos ??