<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Giuliano Colla via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> schrieb am Mi., 12. Apr. 2023, 22:54:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Il 12/04/2023 21:17, Bo Berglund via fpc-pascal ha scritto:<br>
</p>
<blockquote type="cite">
<pre>And if so, what is the rule for <b><span>*</span>when<span>*</span></b> to use var in function call argument
lists for items that will be changed inside the called function and used
afterwards?</pre>
</blockquote>
Your Wargs is defined as an open array, i.e. its length is unknown
at compile time. Therefore the compiler cannot pass it in the
subroutine call other than a pointer to the array. It cannot pass
the array content because it doesn't know its length.<br>
In that case you may omit the var specifier.<br>
But if one day you change your mind, and decide to establish a size
for your array, without var the compiler may decide to pass the full
array data to the procedure, and therefore whatever you do in your
procedure is done on the local copy of the array and not in the
original array. <br>
My suggestion is to specify "var" whenever your procedure is
expected to modify the data passed. It makes the program more
readable, even if "var" is redundant. <br></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">There is *no* open array in the example given. Also even if there were changing the length of an open array would not work... </div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Sven </div></div>