User:Isabella

Create a list of Enums value and names in a table picked by user.
 The result is presented as an excel worksheet. //Input tablename and get a list of enum based tablefields

 static void BaseEnumList(Args _args) {

sysdictfield       dictfield; Sysdictenum        dictEnum; Textbuffer         buffer; com                com; SysexcelApplication excel; SysexcelWorkbooks  books; SysexcelWorkbook   book; SysexcelWorksheets sheets; SysexcelWorksheet  sheet; Dialog             dialog; dialogfield        dialogtableName; Tablename          tablename; fieldName          fieldName; dicttable          dicttable; int                tableid; int    N; // Num of fields int    i;    int     e,l; ;   dialog = new dialog("Description of ENUMs used per table"); dialogtablename = dialog.addField(typeid(tablename));

if (dialog.run) {       // Tablename input tablename = dialogtableName.value; tableid = tablename2id(tablename); if (!tableid) return; dicttable = new dicttable(tableid);

// Use buffer for text until it is pasted in excell buffer = new textbuffer; buffer.setText(strfmt(" Enums used in %1 \n",tablename)); excel  = SysexcelApplication::construct; books  = excel.workbooks; book   = books.add; sheets = book.worksheets; sheet  = sheets.itemFromNum(1); com    = sheet.comObject;

buffer.appendText("Enum\t Num\t name\t \n "); n = dicttable.fieldCnt; for (i=1; i<=n; i++) {           dictfield = new sysdictfield(dicttable.id,dicttable.fieldCnt2Id(i)); if ( dictfield.isSystem) continue; if( dictfield.enumId ) {               dictenum = new Sysdictenum(dictfield.enumId); //Traverse all enum values l = dictEnum.values; for(e=0 ; e < dictenum.values; e++) {                   buffer.appendText(dicttable.fieldName(dicttable.fieldCnt2Id(i))); buffer.appendText("\t"); buffer.appendText(int2str(dictenum.index2Value(e))); buffer.appendText("\t"); buffer.appendText(dictEnum.index2Name(e)); buffer.appendText("\n"); }           }        }        // Fast way to export to excel. buffer.toClipboard; com.paste; excel.visible(true); } }