home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Help / scriptContextHelp.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  1.7 KB  |  81 lines

  1. !!Script
  2. // Copyright ⌐ 1997-1999 - Modelworks Software
  3. // @Modified build 289 cm19990416 - implemented Script help
  4. // @Modified build 291 cm19990430 - added MINDS checks in ShowHelp
  5.  
  6. // This script lets you get help on Scripts.
  7. // To use it select a keyword in a script file and then run
  8. // this script.
  9.  
  10. var gOutput = getOutput();
  11.  
  12. function DoCommand()
  13. {
  14.     // Use built-in help
  15.     var keyword = "";
  16.     var editor = getActiveEditor();
  17.     if (editor)
  18.     {
  19.         var selection = editor.getSelection();
  20.         if (selection.empty())
  21.         {
  22.             var keyword = GetKeywordAtCaret(editor, selection)
  23.             ShowHelp(keyword)
  24.         }
  25.         else
  26.         {
  27.             var keyword = editor.copy(selection);
  28.             ShowHelp(keyword)
  29.         }
  30.     }
  31. }
  32.  
  33. function ShowHelp(keyword)
  34. {
  35.     if (Application.isMindsInstalled())
  36.     {
  37.         if (Application.isMindsLoaded())
  38.         {
  39.             if (keyword == "" || !Application.showHelp(keyword, "script"))
  40.             {
  41.                 alert("No help found for \"" + keyword + "\"");
  42.             }
  43.         }
  44.         else
  45.         {
  46.             alert("The MINDS engine not yet loaded.\r\nTry again when MINDS is loaded.");
  47.         }
  48.     }
  49.     else
  50.     {
  51.         alert("The MINDS engine is not installed. To use\r\nrestart the IDE without the /nominds option.");
  52.     }
  53. }
  54.  
  55. function GetKeywordAtCaret(editor, selection)
  56. {
  57.     var lineData = editor.copy(selection.startLineIndex);
  58.     var index = selection.startCharIndex;
  59.     while (index >= 0)
  60.     {
  61.         var c = lineData.charAt(index);
  62.         if (c == ' ' || c == '\t' || c == '.' 
  63.             || c == '[' || c == '(' 
  64.             || c == '"' || c == "'")
  65.         {
  66.             index += 1;
  67.             break;
  68.         }
  69.         index -= 1;
  70.     }
  71.     //gOutput.writeLine("Index = " + index);
  72.     var result = searchInString(lineData, "[A-Z|a-z|0-9]*", index, true);
  73.     if (result)
  74.     {
  75.         return result.key;
  76.     }
  77.     return "";
  78. }
  79.  
  80. !!/Script
  81.