Export of information from the directory of structural elements to a file

Material from ADGroupWiki
Go to navigation Go to search

File:ExportElems.rar

uses Classes, SysUtils;
 const
   razdel='|';
   nl=#$0D#$0A;
 var 
   ke:TKonElem; 
   kei:TKonElemInfoItem;
   i:integer;
   f:TStringStream; 
   st,st2:string;   
 begin    
   f:=TStringStream.Create;                        
   // the first line - headers
   st:=;
   st:=st+'ID_Elem'+razdel;
   st:=st+'Name'+razdel;
   st:=st+'Type ID'+razdel;
   st:=st+'Type'+razdel;
   st:=st+nl;
   f.WriteString(st);   
   //  
   for i:=0 to gd.ElemsDB.Items.Count-1 do
   begin
     ke:=gd.ElemsDB.Items.GetByNum(i);
     st:=;     
     st:=st+intstostr(ke.Id)+razdel+ke.Name+razdel+intstostr(ke.Typ)+razdel;   
     st2:=;
     kei:=gd.KonElemInfo.Items.GetById(ke.Typ);
     if assigned(kei)then st2:=kei.Name;
     st:=st+st2+razdel;
     st:=st+nl;          
     f.WriteString(st);   
   end;    
   f.SaveToFile('elems.txt');
   f.Free;
 end;