Recent

Author Topic: Save text into a txt file  (Read 30769 times)

Sora-Kun

  • Full Member
  • ***
  • Posts: 162
  • I can smell your presence ...
    • Sora-Kun
Re: Save text into a txt file
« Reply #15 on: December 14, 2010, 09:40:00 am »
 :D i forgot it
TStringList  is the better solution for you case man ;D
Thanks for reminding me captain jaster
 :-*
LinkOS
if nothing suites you, make it your self!
The Revolution, Genesis. The next generation IDE.
If you want to help, PM me.

Made in Lazarus.
Soon, in The WWW.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Save text into a txt file
« Reply #16 on: December 14, 2010, 12:44:15 pm »
Depending on how much text do you want to deal with. For too large text, for example, TStringList is not usable.
« Last Edit: December 14, 2010, 02:46:44 pm by typo »

captian jaster

  • Guest
Re: Save text into a txt file
« Reply #17 on: December 14, 2010, 06:13:38 pm »
Depending on how much text do you want to deal with. For too large text, for example, TStringList is not usable.
Over 2 gigs won't work
But still, until he actually needs to worry about that
TStringList
is always there..

If he does he can learn to use a FileStream

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: Save text into a txt file
« Reply #18 on: December 15, 2010, 12:19:40 am »
The initial question was how to add text from a memo to a textfile.
From a puristic perspective all solutions that first read the file in a buffer (TStringList or any other kind), then append the text to said buffer and then recreate the file, are undesirable because of the side effects (memory consumption, decreasing performance when the file grows, OS overhead in recreating the file).
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

captian jaster

  • Guest
Re: Save text into a txt file
« Reply #19 on: December 15, 2010, 12:36:39 am »
The initial question was how to add text from a memo to a textfile.
From a puristic perspective all solutions that first read the file in a buffer (TStringList or any other kind), then append the text to said buffer and then recreate the file, are undesirable because of the side effects (memory consumption, decreasing performance when the file grows, OS overhead in recreating the file).
So a memorystream instead?

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: Save text into a txt file
« Reply #20 on: December 15, 2010, 09:00:36 pm »
So a memorystream instead?
%)

Do not load the file in memory at all!
Not in a memorystream, not in a TStringList, not anywhere.

Only open the file for appending, write the text and close the file.
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Save text into a txt file
« Reply #21 on: December 15, 2010, 09:07:25 pm »
Your solution applies only for appending text to the end of a text file.
« Last Edit: December 15, 2010, 09:10:37 pm by typo »

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: Save text into a txt file
« Reply #22 on: December 16, 2010, 08:28:54 am »
Your solution applies only for appending text to the end of a text file.
That's what I said 2 posts ago  %)
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

 

TinyPortal © 2005-2018