home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1999 - Modelworks Software
- // @Modified build 289 cm19990416 - implemented Script help
- // @Modified build 291 cm19990430 - added MINDS checks in ShowHelp
-
- // This script lets you get help on Scripts.
- // To use it select a keyword in a script file and then run
- // this script.
-
- var gOutput = getOutput();
-
- function DoCommand()
- {
- // Use built-in help
- var keyword = "";
- var editor = getActiveEditor();
- if (editor)
- {
- var selection = editor.getSelection();
- if (selection.empty())
- {
- var keyword = GetKeywordAtCaret(editor, selection)
- ShowHelp(keyword)
- }
- else
- {
- var keyword = editor.copy(selection);
- ShowHelp(keyword)
- }
- }
- }
-
- function ShowHelp(keyword)
- {
- if (Application.isMindsInstalled())
- {
- if (Application.isMindsLoaded())
- {
- if (keyword == "" || !Application.showHelp(keyword, "script"))
- {
- alert("No help found for \"" + keyword + "\"");
- }
- }
- else
- {
- alert("The MINDS engine not yet loaded.\r\nTry again when MINDS is loaded.");
- }
- }
- else
- {
- alert("The MINDS engine is not installed. To use\r\nrestart the IDE without the /nominds option.");
- }
- }
-
- function GetKeywordAtCaret(editor, selection)
- {
- var lineData = editor.copy(selection.startLineIndex);
- var index = selection.startCharIndex;
- while (index >= 0)
- {
- var c = lineData.charAt(index);
- if (c == ' ' || c == '\t' || c == '.'
- || c == '[' || c == '('
- || c == '"' || c == "'")
- {
- index += 1;
- break;
- }
- index -= 1;
- }
- //gOutput.writeLine("Index = " + index);
- var result = searchInString(lineData, "[A-Z|a-z|0-9]*", index, true);
- if (result)
- {
- return result.key;
- }
- return "";
- }
-
- !!/Script
-