miércoles, 6 de julio de 2011

A few interesting string sizes

...Well they're interesting to *me* at least.

EDT NameString SizeNotes
Title10 
XXXString2020I make generic strings for myself.
NameAlias20 
String3030Don't forget to create a new Label and HelpText
String5050Don't forget to create a new Label and HelpText
Str6060Don't forget to create a new Label and HelpText
Name60 
Description60 
ErrorTxt80 
NotesLine254 
CCNotesShort500'Note', 10 lines high on the forms
SysImportDescription1000 
LabelString1999 
Notes(Memo)If you use lots of these babies consider creating a separate 0..1 table

A few observations. CCNotesShort is module specific and there aren't that many generic strings that we can use. When making any new EDT we prepend our vendor code to it. Mega CorpMEGString20.  I'd prefer to make our own 'generic' EDT such as in the previous example rather than use NameAlias for a 20 length string.  The important thing is to reuse them once they're created.

There's more[+]
Rajdip Das has publicised his job for iterating through the EDT looking for strings of a certain length.  As is always the case, I can't just copy and paste it, I have to tinker...
/// http://dax-world.blogspot.com/2010/01/edt-find-with-string-length-value.html
/// IDS:20110701 EVE
static void EVE_Raj_EDTStringfind(Args _args)
{
    Dictionary dict;
    DictType dictType;
    TreeNode treeNode = TreeNode::findNode("Data Dictionary\\Extended Data Types\\ABCModelType");

    #AviFiles
    sysExcelApplication excel;
    SysExcelWorkbooks books;
    SysExcelWorkbook book;
    SysExcelWorkSheets sheets;
    SysExcelWorkSheet sheet;
    com com;
    Integer row = 2;

    Dialog d = new Dialog("Input Box");
    DialogField dfStrValue;
    Integer tmpStringLen = 0;
    Integer tmpStringLenMax, tmpStringLenMin;                       // IDS:20110701 EVE

    SysOperationProgress progress = new SysOperationProgress();
    ;

    // Dialog initialised and accept value and asign
    dfStrValue = d.addField(typeId(Integer),"Enter EDT String Length");
    if(!d.run())
        return;

    tmpStringLen = dfStrValue.value();
    tmpStringLenMax = tmpStringLen + real2int(tmpStringLen * 0.25);  // IDS:20110701 EVE
    tmpStringLenMin = tmpStringLen - real2int(tmpStringLen * 0.25);  // IDS:20110701 EVE

    if(!tmpStringLen)
        throw error("Plaese Enter Valid Number.");

    // Excel Object initialisations
    excel = sysExcelApplication::construct();
    books = excel.workbooks();
    book = books.add();
    sheets = excel.worksheets();
    sheet = sheets.itemFromNum(1);
    com = sheet.comObject();

    // Heading Initialisations
    sheet.cells().item(2,1).value("EDT Name");
    sheet.cells().item(2,5).value("Str Size");
    sheet.cells().item(2,6).value("Label");

    // Progress Bar Initialisations
    progress.setCaption("Generating Lines");
    progress.setAnimation(#AviTransfer);
    progress.setTotal(500);


    // loop for searching EDTs
    while(treeNode)
    {
        dict = new Dictionary();
        dictType = dict.typeObject(dict.typeName2Id(treeNode.treeNodeName()));

        //if(dictType.stringLen() == tmpStringLen)
        if(dictType.stringLen() >= tmpStringLenMin                  // IDS:20110701 EVE
            && dictType.stringLen() <= tmpStringLenMax)
        {
            row++;
            sheet.cells().item(row,1).value(treeNode.treeNodeName());
            sheet.cells().item(row,5).value(dictType.stringLen());
            sheet.cells().item(row,6).value(dictType.label());

            progress.setText(strfmt('Copying EDT %1.', treeNode.treeNodeName()));
            progress.setCount(row);
        }

        treeNode = treeNode.AOTnextSibling();
    }

    sheet.cells().item(1,1).value(strfmt("Found EDT: %1.", row)); // Count & Print for Filtered EDT

    box::info(strfmt("Total EDT Found: %1.", row), "Information");
    excel.visible(true);
}
Have I missed any generic strings that you occasionally use?

No hay comentarios:

Publicar un comentario