Results 1 to 5 of 5

Thread: transferring data to list item.

  1. #1

    transferring data to list item.

    Hello,

    The following problem has arisen:

    I have created a complex record
    [pascal]
    Foo2 = record
    __foo2byte: array of byte;
    end;

    Foo1 = record
    __Foo1: array of Foo2;
    end;

    PTest = ^TTest;
    TTest = record
    _1: array of Foo1;
    end;


    var
    Ttest_1 : TTest;
    [/pascal]
    filling Ttest_1 with data, I set all arrays in the program using setlength and fill in the data. I also have created a linked list, of the pointer type Ptest. Now, I want to fill a new item of the list with Ttest_1.

    Question:

    - How can the new instance of the list 'know' all the dimensions of the array's I set in Ttest_1?
    - Is there a fast way to fill in all the data of Ttest_1 in the new list item?
    Marmin^.Style

  2. #2

    transferring data to list item.

    I'm not really sure if thats what you need.. but here it goes anyway
    Code:
    For I:= Low(Ttest_1._1) to High(Ttest_1._1) do
      Ttest_1._1[I].....
    Why don't you use TObjectList, A little bit more work on class design/write but your main code will look a lot nicer!
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  3. #3

    transferring data to list item.

    Thanks for the reply!
    Well, as for object Pascal I think the only bug-free solution is to set all dynamic arrays of the new list item just like I do with Ttest_1. And use a for..next loop to transfer the data. It's pain because I have to do it every time I create a new item!.
    I could also use an Object and a TList.. but I'd like to avoid o.o.p. A.M.A.P. :lol: I want to understand the fundament.
    Marmin^.Style

  4. #4

    transferring data to list item.

    You can create other types of data structures that are more efficient then O(n) , as I don’t know what you need it for I can’t direct you to a specific method.
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  5. #5

    transferring data to list item.

    Surprise me.. I have a (fixed) array of weapon types, and an in-game linked list of weapons. Each time a weapon is fired, an item is added to the list, and the specific weapon type data from the array, is put into this new list item (which is of course of the same type). No OOP! :lol:
    Marmin^.Style

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •