Array of arbitrary objects

58 views
Skip to first unread message

Sebastian Götz

unread,
Jan 23, 2025, 7:48:51 AM1/23/25
to innosetup

Hello group.

 

I want to introduce a logging layer in front of the Log() method in Inno Setup.

Instead of writing

Log(Format('There was a disturbance of the force on planet %s with strength %d', [planet, strength]));

 

I would like to have

 

LogDebug('There was a disturbance of the force on planet %s with strength %d', [planet, strength]);

 

My declaration of 'LogDebug' looks like this:

 

procedure LogDebug(const msg: string; const args: array of Variant);

begin

  Log(Format(msg, args));

end;

 

This produces a 'Type Mismatch' error at runtime in the Format() call. As Format() offers the same functionality, can someone tell me how the correct type declaration for the array must like like?

 

I also tried

procedure LogDebug(const msg: string; const args: array of const);

adopting the declaration of Format() in the docs. But that doesn’t even compile.

Bill Stewart

unread,
Jan 23, 2025, 2:25:10 PM1/23/25
to innosetup
It seems you can't pass an array of arbitrary values using  [item[, [...]] syntax as a parameter to a function - at least in the version of PascalScript that Inno Setup is using.

Bill Stewart

unread,
Jan 7, 2026, 9:20:25 AM (2 days ago) Jan 7
to innosetup
On Thursday, January 23, 2025 at 5:48:51 AM UTC-7 Sebastian Götz wrote:

I want to introduce a logging layer in front of the Log() method in Inno Setup.

Instead of writing

Log(Format('There was a disturbance of the force on planet %s with strength %d', [planet, strength]));

I would like to have

LogDebug('There was a disturbance of the force on planet %s with strength %d', [planet, strength]);

...

Thanks to Martijn we now have the LogFmt function[1] so we don't have to write

Log(Format(...))

any more. Looks like LogFmt was added in 6.5.2.

Reply all
Reply to author
Forward
0 new messages