{$I filename} directive does not support full file path

Hi,

The {$I filename} compiler directive can only take file path which is relative to the script executing .exe file. If I try to use absolute file path, the .exe path is appended to it, resulting in non-existent path.

Using relative path is wrong, because the .exe is normally installed into Program Files folder at end user’s PC; and end user is then would be required to put his/her include files into Program Files, which is prohibited by User Access Control in modern Windows versions.

Telling user to use {$I …\filename} instead of {$I filename} is wrong either.

Regards,
Dmitry.

Hello,
Use TPSScript.OnNeedFile event:

const aIncludePath:String = ‘c:’;

function TForm1.psNeedFile(Sender: TObject; const OrginFileName: AnsiString;
var FileName, Output: AnsiString): Boolean;
var aData:TStringList;
begin
FileName := aIncludePath + FileName;
aData := TStringList.Create;
try
aData.LoadFromFile(FileName);
Output := aData.Text;
Result := True;
finally
aData.Free;
end;
end;

Thank you. I’ll try this.