[fpc-pascal] Adding file to string to the RTL

Marco van de Voort fpc at pascalprogramming.org
Tue Oct 6 10:07:59 CEST 2020


Op 2020-10-05 om 20:45 schreef Ryan Joseph via fpc-pascal:
> I often need to use a function which reads a file into a string, as is so common in so many scripting languages. Can it be considered to add something like this to the RTL? Since we have a refcounted Ansistring type it's natural for this to be a one-liner. Not saying we should use TStringList but that's the closest thing I found in the RTL.
>
> function ReadFile(path: Ansistring): Ansistring;
> var
>    list: TStringList;
> begin
>    list := TStringList.Create;
>    list.LoadFromFile(ExpandFileName(path));
>    result := list.Text;
>    list.Free;
> end;
Stringlist static method loadstringfromfile ?


More information about the fpc-pascal mailing list