[fpc-pascal] Open vs dynamic arrays

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sun Apr 22 10:45:37 CEST 2012


I know this is an area of some confusion, and the more explanations I 
read the more I'm confused.

I've got a procedure like this

   procedure ClrDebug(const panels: array of const);

   var     i: integer;

   begin
     for i := 0 to Length(panels) - 1 do
       ClrDebug(panels[i])
   end { ClrDebug } ;


   procedure ClrDebug(panel: integer)...

I want to call it like this

   ClrDebug([DbgKey, DbgCode1, DbgTx]);

Or anything similar. My original declaration used had a type  DbgArray= 
array of integer  but that upset the compiler at the call point, the 
code above throws an exception every time the procedure's called.

What, please, is the correct syntax to use in this sort of case?

FPC 2.6.0 on Linux x86.

-- 
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