Wednesday, 9 November 2011

Job to dump Ax menu structure to Excel

The following code produces an Excel (CSV) dump of the Ax menu structure. This works with all versions, including 2012.

static void DumpMenuStructure(Args _args)
{    
    // Dump menu structure to temp CSV file. 
    
    TreeNode    rootNode;    
    CommaIo     outFile;
    str         filename;
    container   line;
    
    void recurseNode(TreeNode node)
    {
        int             childIdx;
        TreeNode        childNode;
        int             spacerIdx;
        TreeNodeType    nodeType = node.treeNodeType();
        ;
        
        line += node.AOTName();
        outFile.write(line);                                
        
        // Recurse sub-menus
        childNode = node.AOTfirstChild();   
        if(childNode)
        {
            while(childNode)
            {            
                recurseNode(childNode);            
                childNode = childNode.AOTnextSibling();            
            }
        }
        else
        {
            // Possible menu reference
            childNode = TreeNode::findNode('\\Menus\\' + node.AOTname());   
            if(childNode)
                recurseNode(childNode);
        }
        line = conDel(line,conLen(line),1);
    }
    
    ;
    
    filename    = WinAPI::getTempFilename(winAPI::getTempPath(),'') + '.csv';
    outFile     = new CommaIo(filename,'w');
    
    recurseNode(TreeNode::findNode('\\Menus\\MainMenu'));
    
    outFile = null; 
    WinAPI::shellExecute(filename);
    
}

Job to output menu structure to Excel (CSV)

No comments:

Post a Comment