Jump to content
PeterPanettone

No StringHelper for saving to file?

Recommended Posts

I couldn't believe it: Embarcadero's System.SysUtils.TStringHelper in 2021 still does not have a method to save the string to a file! :classic_sad:

 

It would be so nice to be able to write: MyString.SaveToFile(AFilePath); :classic_tongue:

Share this post


Link to post
4 minutes ago, David Schwartz said:

Well, there are a few ways to do that, and all just take a few lines of code.

That is correct - but I LOVE string helpers. :classic_love:

  • Like 1

Share this post


Link to post

Saving to file has nothing to do with the string itself. What's next, myString.SendOverNetworkByUDP(..)?

 

You have TFile.WriteAllText(filePath, fileContent) from System.IoUtils, that should be enough for everybody 😉

Edited by Der schöne Günther
  • Like 4

Share this post


Link to post
1 hour ago, PeterPanettone said:

I couldn't believe it: Embarcadero's System.SysUtils.TStringHelper in 2021 still does not have a method to save the string to a file! :classic_sad:

Why should it?  Do you know ANY framework where a basic string type has such a method?

Share this post


Link to post
13 minutes ago, Der schöne Günther said:

What's next

Maybe: MyString.ToBitCoin? That would make Delphi developers RICH!

  • Haha 3

Share this post


Link to post
On 8/10/2021 at 9:10 PM, Remy Lebeau said:

Do you know ANY framework where a basic string type has such a method?

Yes: Delphi. TStringList (which could be indirectly classified as a basic string type although it is a collection of strings) has a SaveToFile method. So why shouldn't string also have a SaveToFile helper method?

Share this post


Link to post
49 minutes ago, PeterPanettone said:

TStringList (which could be indirectly classified as a basic string type although it is a collection of strings)

No, TStringList is not a basic string type. 

Share this post


Link to post
56 minutes ago, PeterPanettone said:

TStringList (which could be indirectly classified as a basic string type although it is a collection of strings)

No, it is a collection of strings.  It is not itself a string.  Period.  A basic string type would be just a sequence of characters, maybe a length, encoding, etc but certainly not more than that.

Quote

So why shouldn't string also have a SaveToFile helper method?

Because it simply doesn't make sense for something like that to exist, since 99% of people won't be using it.  It is a waste of coding, when the same task is easily accomplished using other readily-available code.  So, I repeat my earlier question again.

Edited by Remy Lebeau

Share this post


Link to post
2 hours ago, PeterPanettone said:

That's what I said.

The question was which framework has methods on a basic string type for loading and saving to file. A collection of strings is not a basic string type. 

Share this post


Link to post
On 8/13/2021 at 10:52 PM, PeterPanettone said:

That's what I said.

...

"TStringList (which could be indirectly classified as a basic string type although it is a collection of strings)"

A "collection of strings" and a single "basic string type" are two completely different concepts.

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×