Recent

Author Topic: Lazarus is a shit about opening text files  (Read 6123 times)

Antony

  • Guest
Lazarus is a shit about opening text files
« on: December 10, 2004, 01:46:58 am »
I have this code
Code: [Select]

                     assignFile(tf, flnm);
                     {$I-}
                       reset(tf);
                     {$I+}
         
                     if IORESULT <> 0
                     then return := ERROR
                     else begin
                                     ....
                            end;


in a function, and the exact code in another function, BUT, in one of those functions IT DOES NOT WORK

while executing I receive invalid dile handler...

any suggestion?

Adam.Pilorz

  • Jr. Member
  • **
  • Posts: 67
    • http://www.pilotmp3.devtown.net
Lazarus is a shit about opening text files
« Reply #1 on: December 10, 2004, 09:35:35 am »
Well, I had never any problems opening text files realy... And on the other hand it is not Lazarus, only Free Pascal Compiler, what can eventualy create such problem. Lazarus is only IDE and graphical component's library, nothing more. I suggest that you should put this question in a Free Pascal forum or mailing list, but first try to compare twice that codes in different situations (try both when the file exist and both, when not).

Lightning

  • Sr. Member
  • ****
  • Posts: 422
Lazarus is a shit about opening text files
« Reply #2 on: December 14, 2004, 02:29:36 pm »
This was discussed before, search the forum.
I strongly suggest using higher level components, they are easier to use and safer.
See StringList, Memo, etc.
You can load a file with just one line of code, manipulating strings is also verry easy.
Lazarus is as "shit" as Delphi is, personally i find it easy to use for simple tasks like loading files :)
The future must be... Fast and OpenSource so...
Think Open and Lightning Fast!

Adam.Pilorz

  • Jr. Member
  • **
  • Posts: 67
    • http://www.pilotmp3.devtown.net
Lazarus is a shit about opening text files
« Reply #3 on: December 15, 2004, 04:17:36 pm »
Well, using higher level components have one bad thing: You must load whole file to memory, what can be very unwanted when the file is big and you don't need to load all the file to get your informations. But AssignFile works fine to me...

RudieD

  • Full Member
  • ***
  • Posts: 234
Lazarus is a shit about opening text files
« Reply #4 on: December 15, 2004, 05:27:39 pm »
Antony,
Instead of just Reset why don't you use
...
if FileExists(flnm) then  {--
  Reset(tf)  {-- Open File--}
else
  Rewrite(tf); {-- Create File --}
...
The FRED Trainer. (Training FRED with Lazarus/FPC)

Lightning

  • Sr. Member
  • ****
  • Posts: 422
Lazarus is a shit about opening text files
« Reply #5 on: December 17, 2004, 01:28:29 pm »
Streams are high level components and extremly fast, useful for many kinds of data manipulation including text, hmm i had no problems using the pascal way for text files :?:
I do little text output, mostly settings wich can be stored in ini or xml files, sometimes streams for fast low level processing, almost all components use streams to load and save data/text so i think it's the best way to go if you can't use the existing components.
The future must be... Fast and OpenSource so...
Think Open and Lightning Fast!

 

TinyPortal © 2005-2018