Recent

Author Topic: File not open??? Why?  (Read 1547 times)

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: File not open??? Why?
« Reply #15 on: January 31, 2023, 09:22:36 am »
Yup, something like that (missing exception handling, though?)
Uhm... the only "error handling" that comes in my mind would be to test if file exists, try to delete, when that succeed write it.
Do you have something different in your mind that I am currently not aware of?
Or you meant a seperate "try/except" around the SaveToFile() ?
As longer I think about, as more strange stuff come in my head  %) (I usual just let the class do the job...)

And of course  ;D count from zero  :D
Absolute! Thats why I noted:
Ofc the record stuff I can't check but at least you see some logic.
( Where I actual meant an array  :-[  :-X  :P )

There's no error handling because my error is placing the close inside the loop.  But that's because I first worked on the loop and then decided to put in the close.  I just clicked after the "WriteLn(FilenameOut" stuff andthe loop.  I forgot to make sure it was outside BOTH loops.

I surely wasn't thinking of IfFileExists, because the ReWrite(FilenameOut) takes care of that.  I would've used that in the GetFileLines because that one uses the Reset(FilenameIn).  It's not really error checking, but I'd get a "File Not Found" runtime error from the Reset function.
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: File not open??? Why? Because I had a BRAIN-FART! :D :D
« Reply #16 on: January 31, 2023, 06:58:45 pm »
Yep, done.  Moved the Close outside the loop and now I have a properly formatted Data file.

The End
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

 

TinyPortal © 2005-2018