[fpc-pascal] Parameters to Format()

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Fri May 25 12:10:33 CEST 2012

Michael Van Canneyt wrote:
> On Fri, 25 May 2012, Mark Morgan Lloyd wrote:
>> How should I put this?
>> procedure TUnyokedFrontendForm.OutputWriteF(const str: widestring; 
>> values: array of variant; fg: TColor= clBlack; bg: TColor= clDefault);
>> var     scratch: widestring;
>> begin
>>  scratch := Format(str, values);
>> As above, I get
>> unyokedfrontendcode.pas(354,32) Error: Incompatible type for arg no. 
>> 2: Got "Open Array Of Variant", expected "Array Of Const"
>> I was caught by this one years ago, and at the time the Delphi 
>> developers I was in contact with had no easy solution.
> That's because there is no easy solution.
> Format uses a different array type, they are not variants. You'll have 
> to convert the arrays.

Roughly translated: "look at the documentation and use the right 
parameter type" :-) Thanks, now working.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list