在腳本編輯器中,是否可以將所有對用戶定義函數或表達式的調用都設為超鏈接?例如,我希望能夠單擊腳本中某處的“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>