Append not working in one programme and working in another lazarus / 66-Unix ---------------------------------------------------------------------- stephanos · 2026-01-03 00:05 Dear All I am adding an append function in a large programme.  I have appended many times before but this time it is not working.  When compiled, I get an error message as follows: Quote“Error: SyntaxError “;” expected ”(” found”.Below is the code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Var      fullpathfilename : Unicodestring;             testfile : TextFile;begin// lots of stuff// iteration starts// lots of stuff     AssignFile(testfile, 'GetPlayTimeTest.txt');  // the file        Append(testfile);       Writeln(testfile, fullpathfilename);       CloseFile(testfile);  // closes the file {* *}  // lots of stuff// iteration ends// lots of stuffend The programme executable is in the same folder on the PC as 'GetPlayTimeTest.txt'. Fullpathfilename changes its content on every iteration.  However, I need to know the content at each iteration.  So I decided to write/append the string to a text file, that I have already made. However, Lazarus 4.0, 64 bit, Linux is producing the error when I compile it. The error is with the opening ( of: Append(testfile); It was expecting a semicolon, which is daft, but got an opening bracket, which is normal.  In addition, when: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i AssignFile(testfile, 'GetPlayTimeTest.txt');  // the filewas before the iteration I got the same error Undeterred I made a new project of a simple form with one button, and on-click the following code executed. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  testfile : TextFile;  message : string;begin//Append each file and its path to a file    AssignFile(testfile, 'GetPlayTimeTest.txt');    Append(testfile);    //Writeln(testfile, 'a string literal');    message := 'a string';    Writeln(testfile, message);    CloseFile(testfile);  // closes the fileend; I tested a string literal, a string, and I changed the string to a unicode string.  The 4 lines of content of ‘GetPlayTimeTest.txt' are: QuoteAppend to this file a string literal a string a 2nd string, that is unicode The new project works.  There is no compiler error.  No conflict with a ; and (.  Moreover, I am using the same computer, the same version of Lazarus, and wearing the same socks, and I have rebooted as well. I have read a lot, both online and in books.  My code is right.  What has occurred should not have. Anyone with a solution will be honoured in tales of bravery and intelligence until the end of time. Thanks and wait to hear ---------------------------------------------------------------------- dseligo · 2026-01-03 01:27 Maybe you have some other procedure/function named 'Append'. Hold Ctrl and click on Append and see where that leads you. Or try: System.Append(testfile); ---------------------------------------------------------------------- Thaddy · 2026-01-03 09:04 Yes, posted crossed, thought the same; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  testfile : Text;  mess : string;begin//Append each file and its path to a file    System.Assign(testfile, 'GetPlayTimeTest.txt');    System.Append(testfile);    //Writeln(testfile, 'a string literal');  mess := 'a string';    Writeln(testfile, mess);    System.Close(testfile);  // closes the fileend;Note: after append the file is write only. You need to re-open it to read. ---------------------------------------------------------------------- Nicole · 2026-01-03 09:21 This is a working way and I used it for a long time. I quit. I prefer to write such things: Var SL: TStringList; begin SL:= TStringList.Create; SL.LoadFile('myFile'); ... SL.Free; end; TStringList offers that many built-in functions I may need as sorting, reversing, checking for duplicates, saveToFile,... that I personally prefer it in the meanwhle. ---------------------------------------------------------------------- Thaddy · 2026-01-03 11:34 @Nicole The idea is to append and that can not be done with TStringlist.LoadFromFile, because that destroys any previous stream. What you can do is use TMemoryStream.loadFromFile and then Append to the TStringlist with TStringlist.Append(TmemoryStream.Text); But his old school approach should also work. ---------------------------------------------------------------------- marcov · 2026-01-03 11:41 Quote from: Thaddy on January 03, 2026, 12:34:47 pmBut his old school approach should also work. And can cope with larger files, and possibly less SSD wear. ---------------------------------------------------------------------- Nicole · 2026-01-03 13:15 Not sure, what about large files, my files are > 20 MB. Sure, there are larger ones. Not sure, if I got the task at all. Case I did, I solve it by: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SL.LoadFromFile('myFile');SL.Insert(0, 'add me as first line');SL.SaveToFile('myFile'); ---------------------------------------------------------------------- stephanos · 2026-01-04 14:20 Dear All Thanks for prompt responses Yes, there was a process called Append.  System.Append() worked Thanks to all