[fpc-pascal] Runtime error 217 on array of Variant

Xiangrong Fang xrfang at gmail.com
Thu Sep 5 06:18:39 CEST 2013


Hi there,

I would like to use TVarRec as Variants, after some googling I found this:

http://stackoverflow.com/questions/3733640/how-to-convert-between-tvarrec-and-variant

However, it generated Runtime error 217.  My original code (runs OK) is:

  1 program test;
  2 {$mode objfpc}{$H+}
  3 procedure vart(par: array of const);
  4 var
  5   i: Integer;
  6 begin
  7   i := par[0].VInteger;
  8   WriteLn('first param=', i);
  9 end;
 10 begin
 11   vart([1, 2, 3]);
 12 end.

Modified code (runtime error 217) is:

  1 program test;
  2 {$mode objfpc}{$H+}
  3 procedure vart(par: array of Variant);
  4 var
  5   i: Integer;
  6 begin
  7   i := par[0];
  8   WriteLn('first param=', i);
  9 end;
 10 begin
 11   vart([1, 2, 3]);
 12 end.

Any ideas? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130905/2b932d5a/attachment.html>


More information about the fpc-pascal mailing list