I was able to reproduce the situation. It arises (on the Import sample) if you use TPSPreProcessor and do
xpre.PreProcess(xpre.MainFileName, s);
and
xpre.AdjustMessages(x1);
Try to do without it - and you will get right error position.
If you really need to use it then add Enter after the last end; in script. Or modify:
procedure TMainForm.New1Click(Sender: TObject);
begin
if not SaveTest then
exit;
Memo1.Lines.Text := ‘Program Test;’#13#10’Begin’#13#10’End.’#13#10;
Memo2.Lines.Clear;
fn := ‘’;
end;
Note, if you Compile scripts from .rops files from this sample you will get right error position too, because all .rops files have Enter (#13#10) after the last end.
If you save your script - error position will be right. But compiling script that was not saved give you wrong error position. And again, this situation arises only if you use TPSPreProcessor and do AdjustMessages.
The issue was logged as #49926, thanks for the report.