Like so:<br><br>procedure Test;<br>var<br> SomeType: TClass;<br> SomeObject: TObject;<br>begin<br> SomeType := TStringList;<br> SomeObject := SomeType.Create;<br> (SomeObject as TStrings).Add('Hello World');<br>
ShowMessage((SomeObject as TStrings)[0]);<br> SomeObject.Free;<br>end;<br><br><div class="gmail_quote">On Mon, Aug 23, 2010 at 7:05 PM, Frank Church <span dir="ltr"><<a href="mailto:vfclists@gmail.com">vfclists@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>I did this kind of thing some time ago, but have forgotten the details.<br><br>Let us say you have something like TBaseType(Variable).Method, you want to let TBaseType be a variable so you can have some code like this.<br>
<br>procedure (value:someType)<br>var<br> variableType: TClass; //not quite sure here<br> variableType := TypeOf(value);<br><br>then further on you execute something like<br><br>variableType(Variable).Method, rather than TBaseType(Variable).Method because you can't hard code TBaseType because can't tell what it will be at runtime. I remember doing something like that with Delphi of old, probably Delphi 3 or Delphi 7<br>
<br>Can someone help me with this, with some use cases as well?<br><br>Thanks<br><font color="#888888"><br>-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com" target="_blank">http://devblog.brahmancreations.com</a><br>
</font><br>_______________________________________________<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" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div><br>