I need to check for the existence of a file at startup and, if not present, then create it. I put this code in the UserMain->OnPubLoaded procedure but I am getting an error on compilation.
function OnPubLoaded: Boolean;
var
s: interger;
T: TStringList;
begin
// When the publication is starting.
// Set Result to True if you want to exit immediately without any warning.
Result := False;
SetGlobalVar("register", "1",TRUE);
s := GetGlobalVar("counter", "7");
if s = 1 then SetGlobalVar("register", "0", TRUE)
else
begin
s := s-1;
SetGlobalVar("counter", s, TRUE);
end;
// Clear the return to indexpage variable
SetGlobalVar("indexpage", "-1", TRUE);
// Check the notes file is in place
S := GetGlobalVar("HEPubStorageLocation", "");
fs := IncludeTrailingBackslash(S) + "notes.ini";
if Not FileExists(fs) then
begin
T := TStringList.Create;
// Sets the contents.
T.Text := "";
// Saves the file.
T.SaveToFile(fs);
T.Free;
end;
end;
ERROR is - Unknown identifier or variable is not declared:‘TStringList’. Source position: 42:26
Line 42 is this - T := TStringList.Create;
Any thoughts gratefully accepted. Many thanks.
John