Recent

Author Topic: [SOLVED] Run time error 3162112  (Read 817 times)

Wings2018

  • New Member
  • *
  • Posts: 18
[SOLVED] Run time error 3162112
« on: December 01, 2023, 11:24:48 pm »
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;
« Last Edit: December 02, 2023, 10:17:02 am by Wings2018 »

speter

  • Sr. Member
  • ****
  • Posts: 352
Re: Run time error 3162112
« Reply #1 on: December 01, 2023, 11:51:20 pm »
use reset() to read a file's contents;
use rewrite() to write stuff to a file.

Also, I suggest the following changes:

Code: Pascal  [Select][+][-]
  1.  fShareFile : textfile;
and
Code: Pascal  [Select][+][-]
  1.  AssignFile(fShareFile,sShareFile);
and
Code: Pascal  [Select][+][-]
  1.   CloseFile(fShareFile);


cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Wings2018

  • New Member
  • *
  • Posts: 18
Re: Run time error 3162112
« Reply #2 on: December 02, 2023, 12:12:11 am »
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

  • Hero Member
  • *****
  • Posts: 3631
Re: Run time error 3162112
« Reply #3 on: December 02, 2023, 12:42:08 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?
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.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Wings2018

  • New Member
  • *
  • Posts: 18
Re: Run time error 3162112
« Reply #4 on: December 02, 2023, 10:16:46 am »
Hello TRon,

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

 

TinyPortal © 2005-2018