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:
“Error: SyntaxError “;” expected ”(” found”.
Below is the code
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 stuff
end
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:
AssignFile(testfile, 'GetPlayTimeTest.txt'); // the file
was 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.
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 file
end;
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:
Append 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