PDA

View Full Version : Array of objects and class typing.


kornalius
10-12-2006, 07:03 PM
Here is how to assign objects to arrays and class type on the fly, this will only work with version 1.05 and up:</p><pre><span style=&quot;color: #0066ff&quot;>#class myclass
* public(v$, x$);</span></pre><pre><span style=&quot;color: #0066ff&quot;>* public proc m
*** ShowMessage(v$ + &quot;,&quot; + x$);
* end;</span></pre><pre></pre><pre><span style=&quot;color: #0066ff&quot;>#class myclass2
* public(v$);</span></pre><pre><span style=&quot;color: #0066ff&quot;>* public proc m
*** ShowMessage(v$);
* end;</span></pre><pre></pre><pre><span style=&quot;color: #0066ff&quot;>proc main
* dim(o$, 10);

* For (i$, 1, 5)
*** #object myclass z$;
*** o$[i$] = z$;
*** o$[i$].x$ = i$ * 2;
*** myclass2(o$[i$]).v$ = i$;* // Classtyping
* end;

* For (i$, 1, 5)
*** o$[i$].m;
*** myclass2(o$[i$]).m;* // Classtyping
* end;
end;</span></pre>