I don't know if it's related to the fact that TEdit.CaretPos.X (or Y) is read only, or as Mattias said, the with syntax cannot work with record anyway... :-)<div><br></div><div>This should be a problem (if any) with lazarus not fpc.</div><div><br></div><div>Shannon<br><br>
在 三, 1月 9, 2013 at 8:27 下午,Andreas Schneider <aksdb@gmx.de> 写道:<br>
<blockquote type="cite">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
body {font-family: "Segoe UI", Helvetica, arial, freesans, clean, sans-serif; font-size: 10pt; color: #000000; background-color: #ffffff}
</style>
Interesting. IIRC that worked correctly in Delphi 2010 (it's been a
while ...). This <i>might </i>be a bug in FPC.<br>
<br>
The root of the problem is how properties are handled. Afaics
however, the use of <i>with</i> should cause it to assign the final
record afterwards. Apparently it doesn't - at least not always.
Could be by design, could be a bug. I'll check the bug tracker later
and may report that. (You can do that yourself, if you want, but
sooner or later I would like that functionality to work too, so I've
a personal interest in this and therefore would not mind to report
it :-))<br>
<br>
Greetings,<br>
Andreas<br>
<br>
<br>
<div class="moz-cite-prefix">On 09.01.2013 13:19, xrfang wrote:<br>
</div>
<blockquote class=" cite" id="mid_50ed6061_e5ca440a_3667_ffffe478_mx_google_com" cite="mid:50ed6061.e5ca440a.3667.ffffe478@mx.google.com" type="cite">Hi Adreas,
<div><br>
</div>
<div>I just tried, your method did not work as expected. It
compiled ok, but didn't put the cursor at the end of the line as
I wanted. However, assign CaretPos a new TPoint worked.</div>
<div><br>
</div>
<div>Regards,<br>
<br>
在 三, 1月 9, 2013 at 4:47 下午,Andreas Schneider
<a class="moz-txt-link-rfc2396E" href="mailto:aksdb@gmx.de"><aksdb@gmx.de></a> 写道:<br>
<blockquote class=" cite" id="Cite_0" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<style type="text/css">#Cite_0 { font-family: "Segoe UI",Helvetica,arial,freesans,clean,sans-serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); }
</style>
<div style="font-size: 10pt; font-family:
Helvetica,arial,freesans,clean,sans-serif; color: rgb(34,
34, 34); background-color: rgb(255, 255, 255); border:
medium none; line-height: 1.2;" data-md-original="Hi,<br><br>you could also use
the with-statement, that is pretty handy in such
cases:<br><br>```delphi<br><tt>with
Edit1.CaretPos
do</tt><tt><br></tt><tt>begin</tt><tt><br></tt><tt>
X :=
0;</tt><tt><br></tt><tt>
Y :=
0;</tt><tt><br></tt><tt>end;<br>```<br></tt><br><div
class="moz-cite-prefix">Best
Regards,<br>Andreas</div>" class="markdown-here-wrapper" id="markdown-here-wrapper-53346">
<p style="margin: 1em 0px;">Hi, </p>
<p style="margin: 1em 0px;">you could also use the
with-statement, that is pretty handy in such cases: </p>
<pre style="font-size: 0.85em; font-family: Consolas,Inconsolata,Courier,monospace;font-size: 1em; line-height: 1.2em; overflow: auto;margin: 1em 0px;"><code style="font-size: 0.85em; font-family: Consolas,Inconsolata,Courier,monospace;margin: 0px 0.15em; padding: 0px 0.3em; white-space: nowrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-radius: 3px 3px 3px 3px; display: inline;white-space: pre; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em 0.7em;display: block; padding: 0.5em; color: rgb(51, 51, 51); background: none repeat scroll 0% 0% rgb(248, 248, 255);" class="lang-delphi delphi"><span style="color: rgb(51, 51, 51); font-weight: bold;" class="keyword">with</span> Edit1.CaretPos <span style="color: rgb(51, 51, 51); font-weight: bold;" class="keyword">do</span>
<span style="color: rgb(51, 51, 51); font-weight: bold;" class="keyword">begin</span>
X := <span style="color: rgb(0, 153, 153);" class="number">0</span>;
Y := <span style="color: rgb(0, 153, 153);" class="number">0</span>;
<span style="color: rgb(51, 51, 51); font-weight: bold;" class="keyword">end</span>;</code></pre>
<p style="margin: 1em 0px;">Best Regards,<br>
Andreas</p>
</div>
<div class="moz-cite-prefix"><br>
On 08.01.2013 16:30, xrfang wrote:<br>
</div>
<blockquote class=" cite" id="mid_50ec3b97_6689440a_2a58_ffffa7c7_mx_google_com" cite="mid:50ec3b97.6689440a.2a58.ffffa7c7@mx.google.com" type="cite">Hi,
<div><br>
</div>
<div>Is there "record literal in FPC? e.g. normally, you do:</div>
<div><br>
</div>
<div>var</div>
<div> cp : TPoint;</div>
<div><br>
</div>
<div>cp.X := 0;</div>
<div>cp.Y := 0;</div>
<div>Edit1.CaretPos := cp;</div>
<div><br>
</div>
<div>I would like to use literal directly, such as:</div>
<div><br>
</div>
<div>Edit1.CaretPos := (X: 0, Y: 0); </div>
<div><br>
</div>
<div>But the above syntax is wrong. Is there such thing
exists?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Shannon</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">--
_______________________________________________
Lazarus mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">--
_______________________________________________
Lazarus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
</blockquote>
<br>
</blockquote><br></div>