Create Temporary table with dynamic fields?

KeeperRUKeeperRU Member Posts: 58
Which is the best method to create your own virtual structures like tables?

I create physical tables with fields like: CodeField1 (Text 250), Codefield2 (Text 250)....., DecimalField1....
This works great, but code hard to maintain in a long-term. There are always not enough fields or keys.. because I have much tasks with Buffers.

For example:
IF Item.FINDSET THEN
REPEAT
  IF NOT TempTable.GET(Item.Type, Item.Location) THEN BEGIN
    TempTable.CodeField1 := Item.Type; //KEY
    TempTable.CodeField2 := Item.Location; //KEY
    TempTable.INSERT
  END;
  
  TempTable.DecimalField1 += Item.GetLocationAmount();
  ...
  TempTable.DecimalField15 += Item.GetLocationQuantity();

  TempTable.MODIFY;	
UNTIL (Item.NEXT = 0);

Then:
TempTable.SETCURRENTKEY(DecimalField1);
IF TempTable.FINDSET THEN
REPEAT
  ExcelBuffer.AddCell(RowNo, ColNo, TempTable.DecimalField1);
  ..
  ExcelBuffer.AddCell(RowNo, ColNo+14, TempTable.DecimalField15);

  RowNo +=1;
UNTIL (TempTable.NEXT = 0);

Maybe XML, DotNet list, etc.? Need some link with best practices.
Method should be really fast, with sorting, filtering, etc.

Best Answer

Answers

  • KeeperRUKeeperRU Member Posts: 58
    parm wrote: »

    Hi, thank you.
    This answer give me some ideas to increase transparency of my "Buffers" code.
Sign In or Register to comment.