Array of const

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.

Thanks in advance
nomorelogic

Hello,
Can you send us your small testcase? We will retest it.

sure
in attached file both fpc binary and pascal script
to use run from shell as:
./lpitr -s script03.pas

As you can see in script03.pas I wrote 2 procedures: Out_Write and Out_WriteFmt.

The first one runs correctly, the last give a error.
Note also that “Now” (from dateutils) returns an invalid date.

Thanks
nomorelogic

PS:
linux 64 bit
lazarus 1.06
fpc 2.6.0

Hello,
Thanks, issues were logged as #32 and #33.
We will send you a workaround after fixing.

thanks

Hi,

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.

waiting for solution.

Thanks in advance

Hi,

looks like delphi RTTI can’t work with array of const parameters

try this testcase:

program Project13;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, System.Rtti, system.TypInfo;

begin
  var res := Invoke(@Format,
                ['this is string - %s, %d',
                 TValue.FromArray(TypeInfo(TArray<TVarRec>),
                                  ArrayOfConstToTValueArray(['string',123]))],
                ccReg,
                TypeInfo(string),
                true);
  writeln(res.AsString);
end.