Recent

Author Topic: Howto save tlist with object distinct in a file?  (Read 2230 times)

fsemonetti

  • Newbie
  • Posts: 1
Howto save tlist with object distinct in a file?
« on: September 07, 2021, 02:01:08 am »
Good night! first, sorry about my english, my native language is portuguese..

Look under sample :

Code: Pascal  [Select][+][-]
  1. Tline = class
  2.           pa : tpoint;
  3.           color :  integer;
  4.           End
  5.  
  6. Tbox = classs
  7.           pa,pb : tpoint;
  8.           Color : integer;
  9.           End;
  10.  
  11.   ....
  12.             Var
  13.            Lista : tlist;
  14.           a       : tline;
  15.           b       : tbox;
  16.  
  17.      Begin
  18.      lista:=tlist.create();
  19.     a:=tline.create();
  20.     b:=tbox.create();
  21.  
  22.     lista.add(a);
  23.     lista.add(b);

   how save lista to file ?

[Edited to add code tags: please see How to Use the Forum.]
« Last Edit: September 07, 2021, 03:35:41 am by trev »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Howto save tlist with object distinct in a file?
« Reply #1 on: September 07, 2021, 03:33:58 am »
Welcome!

ListA.Items.SaveToFile('lista.txt');

Sorry - should have paid attention to the content of TList.
« Last Edit: September 07, 2021, 12:00:15 pm by trev »

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Howto save tlist with object distinct in a file?
« Reply #2 on: September 07, 2021, 10:11:48 am »
Code: Pascal  [Select][+][-]
  1. ListA.Items.SaveToFile('lista.txt');

I don't think this will magiacally write the infor that fsemonetti needs* to the file, I suspects it writes pointers (untested hypothesis).

* I assume he wants the points, (coördinates) and colors of each box and each line in his file.
Not a difficult task, but I suspect not as trivial as you suggest.

Bart

 

TinyPortal © 2005-2018