home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / TextEditors&Viewers / Texteditors / FFRED10.LHA / fpl / SimpleHelp.FPL < prev    next >
Encoding:
Text File  |  1994-10-26  |  1.9 KB  |  61 lines

  1. export void SimpleHelp(string doc)
  2. {
  3.   string docfile="Guide:AllNodes";
  4.   int oldbuffer=GetEntryID();
  5.   int buffer;
  6.   string line, file;
  7.   int start=6, stop;
  8.   int flagcase=ReadInfo("search_case");
  9.   int flagforw=ReadInfo("search_forward");
  10.   int flagword=ReadInfo("search_word");
  11.   int found=0;
  12.  
  13.  
  14.   if (strlen(doc)) {
  15.     buffer=New();
  16.     if (buffer) {
  17.       found=1;
  18.       Visible(0);
  19.       CurrentBuffer(buffer);
  20.       Clean(joinstr("Load(\"", docfile, "\");"));
  21.       GotoLine(1, 0);
  22.       SetInfo(0, "search_forward", 1, "search_case", 1, "search_word", 0);
  23.       if (Search(joinstr("\"", doc, "\""))<0) {
  24.         if (Search(joinstr(" ", doc, " "))<0) {
  25.           SetInfo(0, "search_word", 1);
  26.           if (Search(doc)<0) {
  27.             found=0;
  28.           }
  29.         }
  30.       }
  31.       if (found) {
  32.         found=0;
  33.         line=GetLine();
  34.         if (line[start]=='\"')
  35.           stop=strstr(line, "\"", ++start);
  36.         else {
  37.           stop=strstr(line, " ", start);
  38.           if (stop==-1)
  39.             stop=strstr(line, "\n", start);
  40.         }
  41.         if (stop) {
  42.           line=substr(line, start, stop-start);
  43.           SetInfo(0, "search_forward", 0, "search_word", 0);
  44.           if (Search(":\n")>=0) {
  45.             file=substr(GetLine(), 0, ReadInfo("byte_position"));
  46.             System(Sprintf("run >nil: <nil: Amigaguide \"%s\" Document \"%s\" PubScreen \"%s\"", file, line, ReadInfo("current_screen")));
  47.             ReturnStatus(Sprintf("AMIGAGUIDE \"%s\" DOCUMENT \"%s\" PUBSCREEN \"%s\"", file, line, ReadInfo("current_screen")));
  48.             found=1;
  49.           }
  50.         }
  51.       }
  52.       CurrentBuffer(oldbuffer);
  53.       Kill(buffer);
  54.       SetInfo(0, "search_forward", flagforw, "search_case", flagcase, "search_word", flagword);
  55.     }
  56.   }
  57.   if (!found)
  58.     System(Sprintf("run >nil: <nil: Amigaguide FrexxEd:Docs/FrexxEd.guide PubScreen \"%s\"", ReadInfo("current_screen")));
  59. }
  60. AssignKey("SimpleHelp(GetWord());", "'Help'");
  61.