My program is calling a scriptfunction which in turn calls a delphi function with a var parameter.
When I run the software the scripts throws an error, see attached picture.
I made a test where one of the scriptfunctions has a fake variable initilization.
This function work with no error.
Here are the two functions :
// runs as it should
function MM_Lotol( FuName: string );
var
d: double;
i: integer;
begin
i := 0; // Fake initilization of i, unneccessary, since i is a var parameter
if Merkmallist.GetMMIdxbyFunctionName( FuName, i ) then begin
d := Merkmallist.Merkmale[i].Lotol;
Result := Merkmallist.Merkmale[i].FormatMMQs( d );
end
else Result := 'MM not found';
end;
// almost same function, throws an error
function MM_Uptol( FuName: string );
var
d: double;
i: integer;
begin
if Merkmallist.GetMMIdxbyFunctionName( FuName, i ) then begin
d := Merkmallist.Merkmale[i].Uptol;
Result := Merkmallist.Merkmale[i].FormatMMQs( d );
end
else Result := 'MM not found';
end;
This is the definition of the called function, its normally compiled in Delphi
function TMerkmallist.GetMMIdxbyFunctionname(Value: string; var mmidx: integer): boolean;
var
i: integer;
begin
Result := false;
mmidx := -1;
if Length(Value) > 0 then
for i := 0 to Count - 1 do begin
if Merkmale[i].Functionname = Value then begin
mmidx := i;
Result := true;
break;
end;
end;
end;
To avoid crashes, I have t initialized parameters to a delphi function.
The parameter might have any value, it is writen by called function no matter what its value is.
But it should not crash.