Axapta 4.0注释快捷方式

Axapta 4.0注释快捷方式,axapta,x++,Axapta,X++,我现在使用axapta 4.0工作3天,无法通过快捷方式对文本进行评论。我知道axapta中没有实现快捷方式,但是否有一种可能的解决方案,以便我可以编写一个代码段或一些注释文本的内容。我无法想象以前没有人遇到过这个问题,也没有找到解决方案。这应该可以帮到你。它有点像是从其他方法中砍下来的,只是为了简单的复制和粘贴…你可以优化 创建此方法alex\u GeneralComment此处: Classes\EditorScripts\alex\u GeneralComment 然后输入此代码,您应该能

我现在使用axapta 4.0工作3天,无法通过快捷方式对文本进行评论。我知道axapta中没有实现快捷方式,但是否有一种可能的解决方案,以便我可以编写一个代码段或一些注释文本的内容。我无法想象以前没有人遇到过这个问题,也没有找到解决方案。

这应该可以帮到你。它有点像是从其他方法中砍下来的,只是为了简单的复制和粘贴…你可以优化

创建此方法alex\u GeneralComment此处:

Classes\EditorScripts\alex\u GeneralComment

然后输入此代码,您应该能够在编辑器中选择代码,
[右键单击>脚本>alex>一般评论]

它将创建一个如下所示的注释,光标位于
/
行。用它做实验

/(亚历克斯)(12/03/2015)
// 
//-->
信息(“如果我选择这两行代码,然后右键单击并执行该操作”);
信息(“脚本,注释块看起来像这样”);
// 除上述内容外:

通过键入
Alt+R,S

之后,您可以查看
EditorScripts
类中的
getapplicatablescripts
方法。此方法负责通过返回一个装满编辑器脚本的容器来获取菜单包含的编辑器脚本。您可以根据需要修改该代码

例如,要将容器修改为仅包含注释和取消注释功能,请在变量声明的正下方添加以下代码:

if (curUserId() == "YourUserId")
{
    scripts += "comments_comment";
    scripts += "comments_uncomment";

    return scripts;
}

//- Some more code
这样,您可以键入
Alt+R,S,C,C
进行注释,并键入
Alt+R,S,C,U


。。。刚开始需要一点练习来记住

你是说源代码的注释吗?有
EditorScripts
类,但我不确定它是否已经在版本4中可用。您看过Axaptapedia页面了吗?它至少从3.0开始提供。是否可以添加快捷键,如ctrl+k、c或类似的内容?在AX2012中,可以添加选项卡快捷键,在这里您可以键入任何您想要的内容,例如
mycom
,然后按
tab
。看看这个博客,他们在哪里使用这个。但是在AX4.0中,它已经有将近10年的历史了,也许不是。我读了这篇文章,但它似乎不是我的真正意思。例如,我指的是VS2013中的注释函数。标记一些文本并按ctrl+k,c,标记的文本将被注释掉。但是你的回答仍然很好,因为这是另一件困扰我的事情。所以无论如何,谢谢你。如果你有关于注释标记文本的更多信息,我将不胜感激。哦,对于AX4.0来说,它看起来不存在。4.0是,AX 2012是
public void alex_GeneralComment(Editor _editor)
{
    #define.YourCompanyName("ALEX")
    str         selText = EditorScripts::getSelectedText(_editor, false);
    str         selFirstLine;
    int         startLine = _editor.selectionStartLine()+1;
    int         endLine   = _editor.selectionEndLine()+1;
    int         startCol  = _editor.selectionStartCol();
    str         name      = XUserInfo::find(False, curUserId()).name ? XUserInfo::find(False, curUserId()).name : XUserInfo::find(False, curUserId()).networkAlias;
    xppSource   xppSource;

    str getSelectedText(Editor e, boolean takeAllIfEmpty = true)
    {
        int i;
        str text;
        str line;
        int _startLine = e.selectionStartLine()+1;
        int _endLine   = e.selectionEndLine()+1;
        int _startCol  = e.selectionStartCol();
        int endCol    = e.selectionEndCol();

        if (_startLine == _endLine && _startCol == endCol)
        {
            // This method returns the selected text, and if the user selects
            // no text, then it returns nothing.  So we want to return the
            // entire code block if the parameter is set
            if (!takeAllIfEmpty)
                return text;

            e.firstLine();
            while (e.moreLines())
            {
                text += e.getLine()+'\r\n';
                e.nextLine();
            }
        }
        else
        {
            e.firstSelectedLine();
            for (i = _startLine; i <= _endLine; i++)
            {
                line = e.getLine();
                if (i == _startLine && i == _endLine)
                {
                    line = subStr(line, _startCol, endCol-_startCol);
                }
                else
                if (i == _endLine)
                {
                    line = subStr(line, 1, endCol-1);
                }
                else
                if (i == _startLine)
                {
                    line = strRep(' ', _startCol-1)+subStr(line, _startCol, strLen(line));
                }

                text += line + '\r\n';
                e.nextSelectedLine();
            }
        }
        return text;
    }

    boolean isSelectionNonEmpty(str s)
    {
        // delete all special symbols
        return strLen(strRem(strRem(strRem(s," "),"\n"),"\r"))>0;
    }

    if(isSelectionNonEmpty(selText))
    {
        startLine = _editor.selectionStartLine()+1;
        _editor.firstSelectedLine();
        selFirstLine = _editor.getLine();

        startCol  = strLen(selFirstLine) -strLen(strLTrim(selFirstLine));
        xppSource = new xppSource(startCol);
        _editor.insertLines(strFmt("// ("+#YourCompanyName+") (%1)", date2str(today(), 213, 2, 4, 2, 4, 4, DateFlags::None))+"\n");
        _editor.insertLines(xppSource.indent()+strFmt("// \n"));
        _editor.insertLines(xppSource.indent()+strFmt("//-->\n"));

        // If it's one line, indent it, otherwise paste as-is
        if (startLine == endLine)
            _editor.insertLines(xppSource.indent() + selText);
        else
            _editor.insertLines(selText);

        _editor.insertLines(xppSource.indent()+strFmt("//<--"));
        _editor.gotoLine(startLine);
        _editor.gotoCol(strLen(_editor.getLine())); // Go to the comments section
    }
    else
    {
        startCol = _editor.columnNo();
        xppSource = new xppSource(startCol);
        _editor.insertLines(strFmt("// ("+#YourCompanyName+") (%1)", date2str(today(), 213, 2, 4, 2, 4, 4, DateFlags::None))+"\n");
        _editor.insertLines(xppSource.indent()+strFmt("// \n"));
        _editor.insertLines(xppSource.indent()+strFmt("//-->\n"));
        _editor.insertLines(xppSource.indent()+strFmt("\n"));
        endLine = _editor.currentLineNo(); // Line we want to end on
        _editor.insertLines(xppSource.indent()+strFmt("//<--"));
        _editor.gotoLine(endLine);
        _editor.gotoCol(startCol+1);
    }
}
if (curUserId() == "YourUserId")
{
    scripts += "comments_comment";
    scripts += "comments_uncomment";

    return scripts;
}

//- Some more code