0

i need to have this ini file which i mentioned it in my dynamic ttabsheet which i created it dynamically ! as you see ini file , it has three parts each start with 001-002-003 and then let those which start with 001 in first tabsheet , those start with 002 in second tabsheet and those start with 003 in thired tabsheet in my page control .

  procedure TDlg_XRechnung.INIDatei_einlesen;
var NeueSeite : TTabSheet;
  i,l: Integer;
begin
  try
    INIDatei                := TIniFile.Create(INIDateiname);
    Version                 := INIDatei.ReadInteger('INI','Version', 1);
    DebugMode               := INIDatei.ReadInteger('INI','DebugMode', 0);
    PDFDatei                := INIDatei.ReadString('PDF','PDFName', '');
    XRechnungDatei          := INIDatei.ReadString('PDF','XInvoice', '');
    Edit_LeitwegeID.Text    := INIDatei.ReadString('InvData','BT-10', '');
    Edit_Bestellnummer.Text := INIDatei.ReadString('InvData','BT-13', '');
    Edit_Projektreferenz.Text := INIDatei.ReadString('InvData','BT-11', '');
    Edit_Vertragsnummer.Text := INIDatei.ReadString('InvData','BT-12', '');
    Edit_Rechnungsnummer.Text := INIDatei.ReadString('InvData','BT-1', '');
    Edit_Rechnungsdatum.Date := INIDatei.ReadDate('InvData','BT-2', now);
    Edit_Leistungsdatum.Date := INIDatei.ReadDate('InvData','BT-9', now);
    Edit_Bemerkung.Text := INIDatei.ReadString('InvData','BT-22', '');
    Edit_Rechnungsersteller_Name.Text := INIDatei.ReadString('InvErst','BT-27', '');
    Edit_Rechnungsersteller_UST_ID.Text := INIDatei.ReadString('InvErst','BT-31', '');
    Edit_Rechnungsersteller_Adresse.Text := INIDatei.ReadString('InvErst','BT-35', '') + INIDatei.ReadString('InvErst','BT-36', '');
    Edit_Rechnungsersteller_PLZ.Text := INIDatei.ReadString('InvErst','BT-38', '');
    Edit_Rechnungsersteller_Ort.Text := INIDatei.ReadString('InvErst','BT-37', '');
    Edit_Rechnungsersteller_Land.Text := INIDatei.ReadString('InvErst','BT-40', '');
    Edit_Rechnungsempfänger_Name.Text := INIDatei.ReadString('InvEmp','BT-44','');
    Edit_Rechnungsempfänger_Adresse.Text := INIDatei.ReadString('InvEmp','BT-50', '') + INIDatei.ReadString('InvEmp','BT-51', '');
    Edit_Rechnungsempfänger_PLZ.Text := INIDatei.ReadString('InvEmp','BT-53', '');
    Edit_Rechnungsempfänger_Ort.Text := INIDatei.ReadString('InvEmp','BT-52', '');
    Edit_Rechnungsempfänger_Land.Text := INIDatei.ReadString('InvEmp','BT-55', '');

    AnzahlPositinen := INIDatei.ReadInteger('POS','AnzPos', 1);
    for i := 1 to AnzahlPositinen do
    begin
      NeueSeite := TTabSheet.Create(PC_Positionen);
      NeueSeite.PageControl := PC_Positionen;
      NeueSeite.Caption := 'Position ' + IntToStr(i);




    end;

  finally
    INIDatei.Free;
  end;
end;

this is my ini file

[POS] 
AnzPos=3 
 
;xxx ist die Zähl-Nr der Positionen mit Vornull 
001BT-155=643 
001BT-153=EID32 REI90-XC1-AN5C Bereich D  
001BT-129=219,85
001BT-130=M2 
001BT-152=19 
001BT-146=43,50 
001BT-154=EID 32/120 Spannbetondeckenplatte; d = 32 cmg 
001BT-131=9563,48 
001BT-132=11380,54 

002BT-155=299 
002BT-153=Auflagerstreifen 10X70X10 
002BT-129=7 
001BT-130=MTR
002BT-152=19
002BT-146=42,5 
002BT-154=Hartgummiauflagerstreifen 10 x 70 mm auf 10 m Roll 
002BT-131=297,5 
002BT-132=354,03 

003BT-155=40 
003BT-153=Stahlwechsel, grundiert (F0 
003BT-129=411.04 
001BT-130=CMT
003BT-152=19 
003BT-146=3,8 
003BT-154=Stahlwechsel, grundiert (Flachstahl) Netto- nicht rabattierfähig. 
003BT-131=1561.95
003BT-132=1858,72

i dont know how to do !? any idea ?

Thanks

maxfido
  • 45
  • 5
  • 1
    I am utterly confused about what you want to do exactly. Maybe because of translation from German to English. Could you try to edit `now i need to back to ini file ` and `then pu each position in tabsheet` ? Maybe illustrate with a picture ? Otherwise it's difficult to understand what your question is. – MyICQ Apr 03 '21 at 15:41
  • Welcome to StackOverflow! I don't understand what XML has to do here. Also I don't understand what you want to do with the data you show. Maybe you should ask with a simplified data set, show the data set and show the visual effect you need. Avoid using German word anywhere, use English so that we understand. – fpiette Apr 03 '21 at 16:18
  • forget about the xml part please ! i need to have this ini file which i mentioned it above in my tabsheet which i created it dynamically ! as you see ini file , it has therre part each start with 001-002-003 and then let thoease which start with 001 in first tabsheet , those start with 002 in secenod tabsheet and those start with 003 in third tabsheet in my page control . is it clear ! – maxfido Apr 03 '21 at 17:48
  • What is stopping you from putting together the key names for the ini read methods? You already have a counter value. – Delphi Coder Apr 03 '21 at 18:40
  • Please stop trying to explain in comments, and instead [edit] your question. If you want us to *forget about the XML part*, then take it out of the question. I've read your question and your comment, and still have no idea what you're asking, so you're going to really need to work on improving your question if you want us to help. – Ken White Apr 03 '21 at 19:21
  • The key `001BT-130` occurs three times - are you sure about this? Also: Is this related to [#45](https://www.ausschreiben.de/katalog/elbedelcon/position/45) and [#49](https://www.ausschreiben.de/katalog/elbedelcon/position/49) which have the same various typos and mistakes? – AmigoJack Apr 04 '21 at 00:54
  • @AmigoJack Looks like a copy & paste error – Delphi Coder Apr 04 '21 at 05:04
  • You don't show an INI file. You show some text. An INI file has sections. Please re-read all the comments and do exactly what is asked. This is the only way to have a chance to get a correct answer. If you don't, chances are that your question is simply closed. – fpiette Apr 04 '21 at 07:00

1 Answers1

2

You have every data in the [POS] section in the INI file you show while your code expact section [InvData]. Fix that.

In your PageControl, it is not enough to create TabSheet, you must also create a new frame instance to be hosted into each page. All frames are the same class and host edit, checkbox and so on to host data.

Then you must read the data, except count, inside you for-loop to create the page control. To read the data, you must combine the loop variable with fixed part to build the key. Something like this:

Edit1.Text := IniFile.ReadString('POS', Format('%03.3dBT-154', [I]), 'Some default value');

In my example, Edit1 is one field of the frame.

fpiette
  • 11,983
  • 1
  • 24
  • 46