PeterPanettone 157 Posted August 10, 2021 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! It would be so nice to be able to write: MyString.SaveToFile(AFilePath); Share this post Link to post
David Schwartz 426 Posted August 10, 2021 Well, there are a few ways to do that, and all just take a few lines of code. Share this post Link to post
PeterPanettone 157 Posted August 10, 2021 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. 1 Share this post Link to post
Der schöne Günther 316 Posted August 10, 2021 (edited) 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 August 10, 2021 by Der schöne Günther 4 Share this post Link to post
Remy Lebeau 1394 Posted August 10, 2021 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! Why should it? Do you know ANY framework where a basic string type has such a method? Share this post Link to post
PeterPanettone 157 Posted August 10, 2021 13 minutes ago, Der schöne Günther said: What's next Maybe: MyString.ToBitCoin? That would make Delphi developers RICH! 3 Share this post Link to post
PeterPanettone 157 Posted August 13, 2021 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
David Heffernan 2345 Posted August 13, 2021 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
Remy Lebeau 1394 Posted August 13, 2021 (edited) 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 August 13, 2021 by Remy Lebeau Share this post Link to post
PeterPanettone 157 Posted August 14, 2021 7 hours ago, Remy Lebeau said: No, it is a collection of strings That's what I said. Share this post Link to post
David Heffernan 2345 Posted August 14, 2021 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
Remy Lebeau 1394 Posted August 16, 2021 (edited) 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 August 16, 2021 by Remy Lebeau Share this post Link to post