hi guys
first of all congratulation for your work, very very well done!
I’m a fpc programmer and I’m experimenting with your interpreter, so, sorry if I ask trivial things.
With free pascal I wrote a function like:
procedure Out_WriteFmt(Data: string; const Args : array of const);
begin
ScriptOutput.Text:= ScriptOutput.Text + Format(Data, Args);
end;
The purpose is to provide the potential of the Format function to my script.
I can use it properly (both compilation and runtime), but at the end of runtime I get an Access Violation.
I guess it depends on the parameter: const Args: array of const.
I don’t think that it is not supported (function produces output that I expect) but I cannot understand the access violation.
facing the same problem with array of const when using in Format(Data, Args);
Am not getting the access violation, but getting weird characters in place of original arguments.
After some hours digging into fewer documentation and writing some test codes. I found the correct way to do the Rtti invoke call with array of const parameters
procedure F3(a: array of const);
var
i: Integer;
begin
Writeln('F3: Length of a is ' + IntToStr(Length(a)));
for i := Low(a) to High(a) do begin
if a[i].VType = vtUnicodeString then
Writeln(IntToStr(i) + ': UnicodeString ' + UnicodeString(a[i].VUnicodeString))
else if a[i].VType = vtInteger then
Writeln(IntToStr(i) + ': Integer ' + IntToStr(a[i].VInteger));
// and other types...
end;
end;
procedure CallF3ThroughRtti(a: array of const);
var
Args: TArray<TValue>;
begin
SetLength(Args, 2);
Args[0] := TValue.From(@a[0]);
Args[1] := TValue.From(High(a));
Invoke(@F3, Args, ccReg, nil, True);
end;
Hope this can help others entering into this topic later.