在脚本编辑器中,是否可以将所有对用户定义函数或表达式的调用都设为超链接?例如,我希望能够单击脚本中某处的“myfunc”实例,并让编辑器立即将我带到脚本中定义 myfunc 的位置。当然,我还希望有一个“后退”按钮,将我带回到脚本中最初的位置。表达式也是如此。
你好。 希望现在这样做还不算太晚,但我只是想在我原来的愿望清单项目中添加更多内容:
1.(上面已经提到)双击用户函数或表达式会将用户带到脚本中的定义。
2.(上面已提到)“上一步”按钮可将用户返回到脚本中的原始位置。
3.(新)单击用户函数、表达式或变量将自动突出显示脚本中该项目的所有实例。
4.(新)“下一步”按钮。 假设用户双击功能 A,然后双击功能 B,然后双击功能 C,然后按“上一页”返回到功能 B,则“下一步”按钮会将它们带回到功能 C。
5.(新)如果脚本窗口已分为两部分(例如右/左),我希望上述功能能够在当前处于活动状态的分割上运行,而不是始终仅在左侧分割上运行。
6.(新)脚本窗口中的下拉菜单显示所有用户函数和表达式。 选择其中一项会将用户带到脚本中的该项目。
希望这些都是有道理的、合理的。 谢谢!
你好@尼克尔斯, 谢谢你的建议! 我们已收到您的请求并将予以考虑。
突出显示用户定义的功能并按功能键转到定义会很方便。
你好@gzmorgan0和@尼克尔斯,我刚刚发布了上述脚本的更新版本作为JSL功能列表加入。 检查一下,如果有任何问题请告诉我。
这是我今天使用的仅供参考:
- 突出显示文本并按 Ctrl+F 或编辑>搜索>查找并按查找,或者
- 下面的脚本。 它是 JMP 开发人员提供的预光标脚本。 他可能有更新的版本,我在共享文件和加载项列表中没有看到它。 我没有发布他的名字,但会检查他是否有更新版本。运行时,该脚本会创建所有当前打开的 JSL 脚本的显示并列出函数的行号。 双击即可到达那里。
/*
Author: xxxxxx xxxxxxx
Copyright (c) 2016 by SAS Institute Inc., Cary, NC 27513, USA. All rights reserved.
*/
Names Default To Here( 1 );
getRoots = Function({searchCriteria=""},
wins = Window();
roots = {};
For( iWin = 1, iWin <= N Items( wins ), iWin++,
If( (wins[iWin] << window class name) == "Script",
tmpNode = Tree Node( wins[iWin] << Get Window Title );
tmpNode << Set Data( wins[iWin] );
tmpNode << Set Icon( "ScriptFile" );
If( searchCriteria != "",
If( !Contains( wins[iWin][Script Box( 1 )] << get text, searchCriteria ), Continue() )
);
lines = wins[iWin][Script Box( 1 )] << Get Lines();
For( iLine = 1, iLine <= N Items( lines ), iLine++,
fName = Regex( lines[iLine], "([a-z\d_\s]+)[\s]*=\s*function\s*\(", "\1", IGNORECASE );
/* () collect everything that matches this pattern [a-z alphabetical, \d digit, _ underscore, \s white space]
+ one or many, so there must be at least one of these items
[\s]* this is white space, but * says 0 or many
= must occur, that is, it is a part of the pattern
function must occur
\s* 0 or many instances of white space ( tab, space, new line)
( left parentheses is part of the pattern
If the pattern is found, \1 states to return the collection, that is the function name
*/
//"([a-z\d_=\s]+)[\s]*<<\s*xpath\s*\(", "\1", IGNORECASE );
If( !Is Missing( fName ),
tmpChildNode = Tree Node( Trim( fName ) || ": " || Char( iLine ) );
tmpChildNode << Set Data( iLine );
tmpChildNode << Set Icon( "FunctionIndex" );
tmpNode << Append( tmpChildNode );
);
);
Insert Into( roots, tmpNode );
)
);
Return(roots);
);
roots = getRoots();
goToLine = Function( {sb, lineNum},
sb << Set Line text( lineNum, sb << get line text(lineNum) );
);
nw = New Window( "JSL Function Manager",
H List Box(
Button Box("",<<SET icon=""></SET>