Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - FAQ - Zum CC1-Forum - Zum CC-Pro-Forum

Re: combined data types Kategorie: Programmierung (von André H. - 15.05.2005 21:54)
Als Antwort auf combined data types von Bart Jansen - 10.03.2005 11:26
Ich nutze:
C-Control II Unit, C164CI-ControllerBoard, CC2-Application-Board, CC2-StarterBoard, CC2-ReglerBoard, OSOPT V3.0
Hallo Bart,
 
> First of all, does anybody know a forum which is in English?

Sorry, there ist no forum in english language.
This ist the (real) only forum for C-Control II.
But, here you can ever write in english.

> Secondly, I'm trying the following code, which results in a type mismatch error on the last line.
> Do I understand correctly that the only solution to assign a compound data type to an index in an array is
> copying of all the data (bitems[0].x = r.x; bitems[0].y = r.y;)?
>
> Thanks a lot for your help
>
> type Bitem
> {
> int x;
> int y;
> }
>
> function boo()
> {
>  Bitem bitems[10];
>  Bitem r;
>  r.x = 5;
>  r.y = 7;
>  bitems[0]= r;
> }

It's not realy possible to "copy" all Data of an defines Datatype with one line.
Normaly you must copy each value.
But, there ist a simple trick to copy the whole content of a defines Datatype:
You can use the a modified Version of mem.copypos(). :
inline function _copyBitem(Bitem destination, int destpos, Bitem source, int sourcepos, int len)
{
 inline vmcodes.VM_INLINE_SYSCALL+mem.Segment;
 inline mem._COPY;
}
function copyBitem(Bitem destination, Bitem source)
{
 _copyBitem(destination, 0, source, 0, 4); // len = 4 Bytes (=2 Integers)
}


Now you can use this function like this:
copyBitem(bitems[0], r);

André H.



Antworten bitte nur ins Forum!
Fragen per EMail auf Forum-Postings werden nicht beantwortet!

Das macht meine Heizung gerade


    Antwort schreiben


Antworten: