<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 11/4/2018 5:24 PM, Sven Barth via
fpc-devel wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAFMUeB9KYdykP-575bOY961FuhgBpPDt1uq5jPQbjEO8wf9_2Q@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="auto">
<div>
<div class="gmail_quote">
<div dir="ltr">Am So., 4. Nov. 2018, 20:36 hat Gennady
Agranov <<a href="mailto:gennadyagranov@gmail.com"
moz-do-not-send="true">gennadyagranov@gmail.com</a>>
geschrieben:<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">
<div class="m_-8615399095145634521moz-cite-prefix">On
11/4/2018 11:24 AM, Sven Barth via fpc-devel wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">
<div>
<div class="gmail_quote">
<div dir="ltr">Am So., 4. Nov. 2018, 12:23 hat
Schindler Karl-Michael <<a
href="mailto:karl-michael.schindler@web.de"
target="_blank" rel="noreferrer"
moz-do-not-send="true">karl-michael.schindler@web.de</a>>
geschrieben:<br>
</div>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex"><br>
<br>
> Am 04.11.2018 um 12:00 schrieb Ben
Grasset <<a
href="mailto:operator97@gmail.com"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">operator97@gmail.com</a>>:<br>
> <br>
> From: Ben Grasset <<a
href="mailto:operator97@gmail.com"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">operator97@gmail.com</a>><br>
> To: FPC-Devel users discussions <<a
href="mailto:fpc-devel@lists.freepascal.org"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">fpc-devel@lists.freepascal.org</a>><br>
> Subject: Re: Array assignment operator<br>
> Message-ID: <<a
href="mailto:CAL4d7FjPfX-ysT6Z3--fhPR9Pts-N47ksFN6m2pHD7SunzwpJg@mail.gmail.com"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">CAL4d7FjPfX-ysT6Z3--fhPR9Pts-N47ksFN6m2pHD7SunzwpJg@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset="utf-8"<br>
> <br>
> On Sat, Nov 3, 2018 at 4:44 PM Gennady
Agranov <<a
href="mailto:gennadyagranov@gmail.com"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">gennadyagranov@gmail.com</a>><br>
> wrote:<br>
> <br>
>> Hi,<br>
>> <br>
>> Leaving aside the reason why the
MiSchi's solution doesn't work the main<br>
>> question is still not answered :)<br>
>> <br>
>> If you have integer dynamic array
"MyArray" is there a way for the<br>
>> following statement to compile and
work correctly:<br>
>> <br>
>> MyArray := 5;<br>
>> <br>
> <br>
> Uh, yes? That's what my example showed.<br>
<br>
In your example the length of the array was
set to the number and the elements of the
array assigned to their index, whereas my
intention is to keep the length of the array
and fill all elements to the same number.<br>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">The operator always creates a new
array and does not modify the existing one. </div>
<div dir="auto">You'd need to abuse a binary
operator (e.g. >< or even <=) for this. </div>
<div dir="auto"><br>
</div>
<div dir="auto">Regards, </div>
<div dir="auto">Sven </div>
<div dir="auto">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex"> </blockquote>
</div>
</div>
</div>
<br>
<fieldset
class="m_-8615399095145634521mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
fpc-devel maillist - <a class="m_-8615399095145634521moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org" target="_blank" rel="noreferrer" moz-do-not-send="true">fpc-devel@lists.freepascal.org</a>
<a class="m_-8615399095145634521moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" target="_blank" rel="noreferrer" moz-do-not-send="true">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<p>I was thinking that type helper might work - e.g.
MyArray.SetValue(5) and with using properties
MyArray.Value := 5</p>
<p>But seems that even simple type helper is not working
anymore?</p>
<p>E.g. I was not able to compile example from <a
class="m_-8615399095145634521moz-txt-link-freetext"
href="http://wiki.freepascal.org/Helper_types"
target="_blank" rel="noreferrer"
moz-do-not-send="true">http://wiki.freepascal.org/Helper_types</a>
:(<br>
</p>
<pre class="m_-8615399095145634521de1">TTypeHelper <span class="m_-8615399095145634521sy3">=</span> <span class="m_-8615399095145634521kw1">type</span> helper <span class="m_-8615399095145634521kw1">for</span> <span class="m_-8615399095145634521kw4">Integer</span>
<span class="m_-8615399095145634521kw1">procedure</span> SetZero<span class="m_-8615399095145634521sy1">;</span>
<span class="m_-8615399095145634521kw1">end</span><span class="m_-8615399095145634521sy1">;</span></pre>
</div>
</blockquote>
</div>
</div>
<div dir="auto">Did you add {$modeswitch typehelpers}? </div>
<div dir="auto"><br>
</div>
<div dir="auto">If so, what is the error you get? </div>
<div dir="auto"><br>
</div>
<div dir="auto">Regards, </div>
<div dir="auto">Sven </div>
<div dir="auto">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<p>My error was caused by the fact that I was using delphi mode -
when I used the mode switch it worked perfectly :)</p>
<p>The original problem is solved - at least the way I see it - in
FPC you can add method to the array :)</p>
<p>Cool!</p>
<p>Thanks!<br>
</p>
<p>{$MODESWITCH TYPEHELPERS}<br>
<br>
program arrayset;<br>
<br>
type<br>
abc = array of integer;<br>
abc_helper = type helper for abc<br>
procedure SetValue(value: integer);<br>
procedure Print; <br>
end;<br>
<br>
procedure abc_helper.SetValue(value: integer);<br>
var<br>
i: integer;<br>
begin<br>
for i := Low(self) to High(self) do<br>
self[i] := value;<br>
end;<br>
<br>
procedure abc_helper.Print;<br>
var<br>
i: integer;<br>
begin<br>
for i := Low(self) to High(self) do<br>
Writeln('[',i,'] = ',self[i]);<br>
end;<br>
<br>
var<br>
a: abc;<br>
begin<br>
SetLength(a,10);<br>
a.SetValue(5);<br>
a.Print; <br>
end.</p>
</body>
</html>