我现在用axapta 4.0工作了3天,我不能通过快捷方式评论文本。我知道在axapta中没有实现快捷方式,但是有没有一种可能的解决方案,这样我就可以编写一个代码片段或其他东西来注释我的文本。我无法想象以前没有人遇到过这个问题,也没有找到解决方案。
发布于 2015-12-04 13:26:06
这对你来说应该是有用的。它是从其他方法中删减出来的,只是为了复制和粘贴,simple...you可以进行优化。
在此处创建此方法alex_GeneralComment:
Classes\EditorScripts\alex_GeneralComment
然后输入以下代码,您应该能够在编辑器[right click>Scripts>alex>General Comment]中选择代码
它将创建如下所示的注释,并将光标放在//行上。用它做实验。
// (ALEX) (12/03/2015) /-->info(“如果我选择这两行代码,则右键单击并执行");info(”脚本,注释块将如下所示“);//<--
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);
}
}发布于 2018-07-26 04:34:24
除了上面的answer之外:
可以通过键入Alt+R, S打开可用的编辑器脚本菜单
之后,您可以查看EditorScripts类中的getApplicableScripts方法。此方法负责通过返回一个充满编辑器脚本的容器来获取菜单包含的编辑器脚本。您可以根据需要修改该代码。
例如,要将容器修改为仅包含注释和取消注释功能,请在变量声明的正下方添加以下代码:
if (curUserId() == "YourUserId")
{
scripts += "comments_comment";
scripts += "comments_uncomment";
return scripts;
}
//- Some more code这样,您就可以在comment和Alt+R, S, C, U中输入Alt+R, S, C, C。
..。一开始只需要一点练习就能记住。
https://stackoverflow.com/questions/34066984
复制相似问题