RTC Forums
January 21, 2019, 06:38:30 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcInfo loop  (Read 87 times)
sstuman
RTC License
***
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 License
***
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: 1768


« 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.022 seconds with 16 queries.