RTC Forums
November 21, 2024, 01:50:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcInfo loop  (Read 5368 times)
sstuman
RTC Expired
*
Posts: 6


« on: December 24, 2018, 05:20:14 AM »

    serversList := TRtcInfo.Create;

    with serversList do
    begin
      NewChild('{ACC2EE017-C7E6-45F7-A853-9064A81B723D}');
      NewChild('{BCC2EE017-C7E6-45F7-A853-9064A81B723D}');
      NewChild('{CCC2EE017-C7E6-45F7-A853-9064A81B723D}');
      SetNil('{BCC2EE017-C7E6-45F7-A853-9064A81B723D}');
    end;

How to loop serversList?

Example for i := 0 to serverList.Childs.Count - 1 do.... but no Childs property...
Logged
sstuman
RTC Expired
*
Posts: 6


« Reply #1 on: December 24, 2018, 06:18:01 AM »

var
  f: TRtcRecord;
begin
  f := TRtcRecord.Create;
  f.AutoCreate := False;
  f.NewBoolean('111');
  f.asBoolean['111'] := True;
////////////////////////////////f.Count = 1
  f.NewBoolean('222');
  f.asBoolean['222'] := True;
////////////////////////////////f.Count = 2
  f.isNull['111'] := True;
////////////////////////////////f.Count = 2 How to delete field from record?
  FreeAndNil(f);
endl
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: December 24, 2018, 08:05:23 AM »

1. "asObj", "asPtr" and "NewChild" methods of the "TRtcInfo" class store objects in a quick-search-tree, which only keeps the original string and the object pointer. There is no integer index associated with each element, so there is no way to find these objects by an integer index and there are no iteration functions to loop through "asObj", "asPtr" and/or "Child" elements.

2. Even though the object assigned to a "TRecord" field is released from memory if you set "isNull" to TRUE, the name of the field and its integer index (allocated while creating the field) remain occupied and will be re-used if you assign a different value to the field. There is no way to remove the field name and/or reduce the field count after assigning a field to a record, without destroying the entire record. The purpose of this "limitation" (no field deletion after creation) is (A) to make it possible to store and transfer record fields containing the value "NULL" (=NIL) while keeping the field type information preserved, and (B) to make sure the index of a field inside a record (which can be used to access fields by integer and enumerate through all fields) never changes once a field was created, even if there is no data stored inside the field (field value is "NULL").
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 16 queries.