You could try adding the textfile as a resource (I always do that for external content or config data that changes frequently).
Only caveat is that when you change a resource, you need to make a change to the source that includes it (e.g. add an extra whiteline or delete it).
Or else the build process will not notice the change.
Well, that is cumbersome..Not wrong, it works, but:
The correct way to force a full rebuild is specify -B as command-line parameter.
On subject itself: yes, you better include the text file as a resource.
The other option is to preprocess the file to Pascallify it (escape quotes etc) before you do the suggested
string = {$I text.txt}.
That's basically a about one/two/three line utility program.
Here's one using KOL:
program Pascallify;
{$IFDEF FPC}{$MODE DELPHI}{$H+}{$IFNDEF WINDOWS}{$ERROR this code is windows only!}{$ENDIF}{$ENDIF}
{$APPTYPE CONSOLE}
uses
kol;
var
S:string;
begin
S:= StrLoadFromFile(Paramstr(1)); //assume first parameter on the commandline as input file
S:=String2PascalStrExpr(S); // Basically, this is what makes it work as an include file to assign.
StrSaveToFile(Paramstr(2),S); // Assume second parameter as output file
end.
Of course you should build in some checks
But this is the logic and it works.
The one liner is this, for the horrifying code competition:
program Pascallify;
{$IFDEF FPC}{$MODE DELPHI}{$H+}{$ENDIF}{$APPTYPE CONSOLE}
uses kol;
begin
StrSaveToFile(ParamStr(2),String2PascalStrExpr(StrLoadFromFile(Paramstr(1))));
end.
Compile as: ppc386 -dNOT_USE_RICHEDIT -Rintel -Mdelphi -dVER2 pascallify.dpr
I attached a 7zip binary.
Usage: "Pascallify <input.txt> <output.txt>"
The output can be included as a pascal string usable for internal processing.
NO checks are done! It's the compiled one-liner, with UPX applied. Limit is a 2GB Ansi string file.