In my example, you can use Items[], but in my real project it is a record with <br><br><br>发送自魅族MX<br><br>-------- 原始邮件 --------<br>发件人:Sven Barth <pascaldragon@googlemail.com><br>时间:3月16日 17:12 周六<br>收件人:FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org><br>主题:Re: [fpc-pascal] a proposal about "with" syntax<br><br><p>Am 16.03.2013 07:14 schrieb "Xiangrong Fang" <<a href="mailto:xrfang@gmail.com">xrfang@gmail.com</a>>:<br>
><br>
> Suppose I have the following class:<br>
><br>
> 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>
><br>
> I would like to do this:<br>
><br>
> with MyClassInstance as mci, SomethingElse do begin<br>
> Caption := 'A new caption';<br>
> for i := 0 to Count - 1 do<br>
> mci[i] := UpperCase(mci[i]);<br>
> end;<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.</p>
<p>This was already requested multiple times and also reported on the bugtracker... Nevertheless in your specific case you can just use "Items[i]" instead of "mci[i]".</p>
<p>Regards,<br>
Sven</p>