Показать сообщение отдельно
Старый 15.03.2011, 07:13   #2  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
kamalblogs: Finding unused labels in Dynamics Ax 2009
Источник: http://kamalblogs.wordpress.com/2011...amics-ax-2009/
==============

The pain of unused labels is felt when you start translating your application to support the global versions. As we were porting our application to German we were seeing every possible way to speed up the translation work, one of it was to avoid translating unused labels.  So we tried a few tools that helps us identify this but unfortunately nothing turned helpful. We then resorted to invent our own strategy ….

I’m just reposting what my colleague had already posted on his blog with little more detail and a few additions …

*This job works only if your cross reference is updated*

X++:
static void FindUnUsedLabels()
{
    str 50          labelId;
    str             labelString;
    int             i;
    //set max label to the highest number of labelId in your application
    int             maxLabel = 2000;
    xRefNames       names;
    XRefReferences  ref;

    ;

    while (i <= maxLabel)
    {
        //Sequential generation
        labelId = "@IFC" + int2str(i);

        //Find if the label id has an cross reference
        //record
        select recid from names
            where names.Name == labelid
        exists join ref
            where names.RecId == ref.xRefNameRecId;

        labelString = SysLabel::labelId2String(labelId);

        //If there is no record in cross reference then log it
        if (! names.RecId &&
        //avoid logging labels that are already deleted (This is because of sequential check like IFC1, IFC2, IFC3 etc...)
            labelString != labelId)
        {
            info(strfmt("%1 - %2\n", labelId, SysLabel::labelId2String(labelId)));
        }

        i++;
    }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.