James Hellums 0 Posted February 26, 2021 Please be kind! Lol. I am trying to learn Lazarus. I am using ver 2.01. I have searched Google for my answer, but it's always about strings to a listfilebox. I just want to know how to ADD text file contents to a memobox. My program lets the user select a txt file and it shows the content. They can open multiple text files and save them all as .mtf files. I just need an example or code to show me. I tried memobox1.add.lines(Openfromfile) with error. Help! Thank you. Share this post Link to post
TraumTaenzerDieter 0 Posted February 26, 2021 Just call memobox1.lines.loadfromfile(YourFileName) Share this post Link to post
Remy Lebeau 1394 Posted February 26, 2021 (edited) 12 hours ago, James Hellums said: I just want to know how to ADD text file contents to a memobox. FreePascal/Lazarus's RTL/LCL frameworks are fairly API-equivalent to Delphi's RTL/VCL, about on par with Delphi 7-ish, with a few 2009+ features thrown in (UnicodeString, etc). So, if you have something already working in VCL, it will likely port as-is (or close to it) to Lazarus. Edited February 26, 2021 by Remy Lebeau Share this post Link to post
James Hellums 0 Posted February 27, 2021 (edited) hey Traum! I added memobox1.lines.loadfromfile(OpenDialog1.FileName); after if OpenDialog1.execute then begin and still got an error! My program will load a text file, but it won't let me append. it always replaces the file. got the program to run, but it still will only accept 1 file. it still replaces the file rather than appending. If I ever figure this out with someone's help, I will never forget it! I have been searching for this solution for 2 months. Guess the default is to replace. So I need to over ride that! But how? Edited February 27, 2021 by James Hellums g Share this post Link to post
TraumTaenzerDieter 0 Posted February 27, 2021 Hello james, append another file to your memo: load the file with a temporary stringlist and then call memo.lines.addstrings(temporary stringlist) Share this post Link to post
James Hellums 0 Posted March 1, 2021 Had to rem the memobox1.lines(loadfromfile) to get the exe. Here's what I have so far. When clicking on open text file, it displays the text file contents. When I click again, I want to add a hyphenated line as a divider. It does that. If the user does not choose a file, a showmessage alerts them that they did not choose a text or multi file. But when i click on open text file, the new one replacing the old one. I need to be able to add up to 150 more text files. I have open and save working for the text and multi files with showmessages. Just can't get the files to append. Thanks, Traum! Share this post Link to post