|
26.01.2007, 17:50 | #1 |
Участник
|
axcoder: Dynamic analog of abstract macro
Источник: http://axcoder.blogspot.com/2007/01/...act-macro.html
============== Palle Algemark have published an article witch solution of the same task which have been solved by abstract macro in my latest post. He uses table map and reflection code to achieve flexibility. It is good, especially when you have ready to use map for all concrete tables. It is more difficult to create such map id you haven't. For example you can not just declare fact, that you have same name for a field in each table; uou should: either repeatedly add declaration of all field mappings, or generate it by reflection code, or generate it in xpo. The following dynamic code uses only list of tables and the fact, that ItemID has the same name: static void Test_DictTab(Args _args) { container tables = [ tableNum(InventTable), tableNum(InventJournalTable), tableNum(InventJournalTrans) ]; int i; void processTable(TableID _tableID) { SysDictTable table = SysDictTable::newTableId(_tableID); Common record = table.makeRecord(); FieldID itemField = table.fieldName2Id(fieldStr(InventTable, ItemID)); ; while select count(recID) from record where record.(itemField) == '001' { info(strFmt("%1 = %2", table.label(), record.RecId)); } } ; for(i=1; i |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|