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*
01static void FindUnUsedLabels()
02{
03    str 50          labelId;
04    str             labelString;
05    int             i;
06    //set max label to the highest number of labelId in your application
07    int             maxLabel = 2000;
08    xRefNames       names;
09    XRefReferences  ref;
10 
11    ;
12 
13    while (i <= maxLabel) 
14    {
15        //Sequential generation
16        labelId = "@IFC" + int2str(i);
17         
18        //Find if the label id has an cross reference
19        //record
20        select recid from names
21            where names.Name == labelid
22        exists join ref
23            where names.RecId == ref.xRefNameRecId;
24 
25        labelString = SysLabel::labelId2String(labelId);
26         
27        //If there is no record in cross reference then log it
28        if (! names.RecId &&
29        //avoid logging labels that are already deleted (This is because of sequential check like IFC1, IFC2, IFC3 etc...)
30            labelString != labelId)
31        {
32            info(strfmt("%1 - %2\n", labelId, SysLabel::labelId2String(labelId)));
33        }
34 
35        i++;
36    }
37 
38}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.