<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I also think this would be useful, but for other reasons, often times I end up with code like the following:</div><div><br></div><div>With BigLongThingIDontWantToWriteOutEverySingleTime do</div><div> begin</div><div> Height := 100;</div><div> Width := 200;</div><div> ...</div><div> SomeOtherObject.Submit(BigLongThingIDontWantToWriteOutEverySingleTime);</div><div> end;<br><div><br></div><div>Notice how I have to write the long thing out again at the bottom. There must be a way around that (Something like "Self", but that refers to whatever you are using in With). In Xiangrong's example, this could be mci, but even it it was a static name it would be useful. (If this exists and I am just not aware, please let me know!)</div><div><br></div><div>Thank you,</div><div> Noah Silva</div><div><br><div><div>On 2013/03/16, at 15:13, Xiangrong Fang <<a href="mailto:xrfang@gmail.com">xrfang@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span style="font-family:courier new,monospace">Suppose I have the following class:<br><br><span style="color:rgb(0,0,153)">type<br> TMyClass = class<br> public<br> property Caption: string read FCaption write FCaption;<br>
property Items[Index: Integer]: string read GetItem write SetItem; default;<br> function Count: Integer;<br> end;<br></span><br>I would like to do this:<br><span style="color:rgb(0,0,153)"><br>with MyClassInstance <span style="color:rgb(255,0,0)">as mci</span></span></span><span style="font-family:courier new,monospace"><span style="color:rgb(0,0,153)"><span style="color:rgb(255,0,0)"><span style="font-family:courier new,monospace"><span style="color:rgb(0,0,153)">, SomethingElse</span></span></span> do begin<br>
Caption := 'A new caption';<br> for i := 0 to Count - 1 do<br> <span style="color:rgb(255,0,0)">mci</span>[i] := UpperCase(<span style="color:rgb(255,0,0)">mci</span>[i]);<br>end;</span><br><br>That is, to add an optional "as" clause to the with statement so that access array element in a structure is made easier.<br>
</span>
_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a></blockquote></div><br></div></div></body></html>