Delphi 11.3 problem with var string parameter

Hello,

we have problem with "var string" parameter in Delphi 11.3. Delphi 10.2 is ok. After upgrade to 11.3 we see Invalid Class Typecast when we call published method in script and one has var string parameter.

In code:

function myClass.myMethod(ACISF, ARID: integer; AVID: string; var AFileName: string): integer;

myClass is published using DefineClassByRTTI.

In script:

var F:string;

myClass.myMethod(0,0,'MojeDOCX',F)

Execution hangs in
TatCustomScripter.ScrPrepareValue

Is there any problem with Delphi 11.3?

Thank you
Zdenek

Could you please send us a small sample project reproducing the issue?

scripttest.zip (90.2 KB)
Attached

Any news on this issue?
Thank you

We will investigate this issue as soon as possible. Will answer here when we find out what's going on.

Any news on this issue?
Thank you

Scripter variables are Variants and never initialized. Thus, you need to initialize them yourself:

 IDEScripter1.SourceCode.Text:='var S:string;'#13#10+
                               'begin'#13#10+
                               ' S := '''''#13#10+
                               ' TC.TestCall(10,S);'#13#10+
                               'end;';

So make sure S is a string by initializing it to an empty string, and your script should work.

Perfect. It works.
Thank you

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.