I need to modify function parameter variable (string) in my Pascal Script code and get it in the Delphi function, after the script finish it's work.
My script code:
function OnBroadcastMessage(iCID, iUIN: integer; var sUsersList: string; dtActualTo: double; bMustRead, bReadNotify: boolean; sMsg: string): boolean;
begin
sUsersList := '3';
result := true;
end;
begin
end.
My Delphi XE3 code (only tiny example, without any checks):
var
Compiler: TPSPascalCompiler;
Exec: TPSExec;
ProcNo: cardinal;
ParamList: TIfList;
Data: AnsiString;
begin
Compiler := TPSPascalCompiler.Create;
Compiler.Compile(Script)
Compiler.GetOutput(Data);
Compiler.Free;
Exec.LoadData(Data);
ProcNo := Exec.GetProc('OnBroadcastMessage');
ParamList := TIfList.Create;
ParamList.Add(@iCID);
ParamList.Add(@iUIN);
ParamList.Add(@sUsersList);
ParamList.Add(@dtActualTo);
ParamList.Add(@bMustRead);
ParamList.Add(@bReadNotify);
ParamList.Add(@sMsg);
result := Exec.RunProc(ParamList, ProcNo);
FreePIFVariantList(ParamList);
end;
This solution was wrong, I'm got an error at line "result := Exec.RunProc(ParamList, ProcNo);".
"Project mcserv.exe raised exception class $C0000005 with message 'access violation at 0x00a56823: read of address 0x0000000d'.".
How I do wrong?