Forum > General

[SOLVED] Run time error 3162112

(1/1)

Wings2018:
Hello everybody,

I've a really simple procedure below, but for whatever reason I get run time error 3162112. When changing the name of 'fShareFile' to 'fFile' the program keeps failing on line containing 'writeln()', but with a different runtime error, so I guess the run time error is a memory location.

I used the construction mentioned below many times before and it simply works. No clue at all why it is not working anymore. In my original code - part of a bigger program - I got run time error 624 before on this construction, but can't find that error code anywhere too. Can somebody support here, thanks?

procedure test();
var

  fShareFile: text;

  sShareFile: ansistring;

begin

  sShareFile:= 'e:\test.txt'; { this empty file is present on my disk }

  assign(fShareFile,sShareFile);

  reset(fShareFile);

  writeln(fShareFile,'test');

  close(fShareFile);

end;

speter:
use reset() to read a file's contents;
use rewrite() to write stuff to a file.

Also, I suggest the following changes:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- fShareFile : textfile; and

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- AssignFile(fShareFile,sShareFile); and

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  CloseFile(fShareFile);

cheers
S.

Wings2018:
Hello speter

You're right, I made a stupid mistake here. It should have been 'rewrite' - it's getting late here and I probably need to go to bed  ;)

The recommendations on using AssignFile and CloseFile aren't accepted by the compiler v3.0.4, and I also can't find them in the manual. What are their differences to the Assign and Close I use?

TRon:

--- Quote from: Wings2018 on December 02, 2023, 12:12:11 am ---The recommendations on using AssignFile and CloseFile aren't accepted by the compiler v3.0.4, and I also can't find them in the manual. What are their differences to the Assign and Close I use?

--- End quote ---
They are the same, see wiki and available in/with mode objfpc (or similar/better). They are there to avoid confusion with other use of the words assign and close.

Also note IOResult which should be used to verify/check the results of the old style file functionality.

Wings2018:
Hello TRon,

Thanks, will have a look. As my problem is solved I'm going to close this ticket.

Navigation

[0] Message Index

Go to full version