<div dir="ltr"><div><div><div><div>Thanks,  this works, sort of.  But does not meet my needs, I will pass in either an int value or an object, but Variant is not compatible with TObject.<br><br></div>Alternatively,  this also does NOT work:  array [0..1] of const; no matter it is a type definition or used as function parameter.<br>

<br></div><div>This is a trivial problem, I can just go with array of const, I am just curious if pascal can do this, because it will make the function definition more strict and my code cleaner.<br><br></div><div>Regards,<br>

</div><div>Xiangrong<br><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/24 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, 24 Sep 2013, Xiangrong Fang wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi There,<br>
<br>
If you declare this:<br>
<br>
procedure proc(param: array of const);<br>
<br>
Then you can pass any type of varaible to param, however, only in an array, such as proc([1, 2]);<br>
<br>
Is it possible to achieve the effect of the code below (which is wrong):<br>
<br>
procedure proc(p1: const; p2: const);<br>
<br>
So that: 1) p1 and p2 is translated by the compiler to TVarRec inside the function; 2) I do not need to pass an array to the function, in another word, the number of params<br>
for the procedure is *fixed*, but the *type* of each param is not.<br>
</blockquote>
<br></div></div>
Use variants:<br>
<br>
Procedure Proc (Var A,B : variant);<br>
<br>
Michael.<br>
<br>
______________________________<u></u>_________________<br>
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.<u></u>org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/<u></u>mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br></div>