home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / DVD!FX17.LHA / FrexxEd / fpl / Ispell.FPL < prev    next >
Encoding:
Text File  |  1995-05-31  |  1.8 KB  |  71 lines

  1. void export ISpell()
  2. {
  3.   string result;
  4.   string word = GetWord();
  5.   string check = sprintf("CHECK %s", word);
  6.  
  7.   if(!FindPort("IRexxSpell")) {
  8.     System("run >NIL: ispell >NIL: <NIL: -r");
  9.     if(!FindPort("IRexxSpell", 10)) {
  10.       ReturnStatus("Can't connect to ispell server!");
  11.       return;
  12.     }
  13.   }
  14.   result = ARexxSend("IRexxSpell", check, 10);
  15.  
  16.   if(strcmp("*", result)) {
  17.     /* bad spelling my man!
  18.        catt FrexxEd anotherp ninja pila kung lang qwre */
  19.     string alters[30];
  20.     int numofal=0;
  21.     int startcol=2;
  22.     int endcol;
  23.     int length;
  24.     int add;
  25.     string oldword = word;
  26.     if(strcmp("#", result)) {
  27.       while(endcol>=0) {
  28.         endcol = strstr(result, " ", startcol);
  29.         if(endcol>0) {
  30.           length = endcol-startcol;
  31.         }
  32.         else {
  33.           length = -1;
  34.         }
  35.         alters [ numofal++ ] = substr(result, startcol, length);
  36.         if( numofal == 30) {
  37.           Status("Filled up the alternative array!");
  38.           break;
  39.         }
  40.         startcol=endcol+1;
  41.       }
  42.       RequestWindow("Spell alternatives",
  43.                     "", "A", &alters, &word, numofal,
  44.                     "Perform", "C", &add, "Replace|Add|Skip");
  45.     }
  46.     else
  47.       RequestWindow("Spell alternatives",
  48.                     "Edit", "S", &word,
  49.                     "Perform", "C", &add, "Replace|Add|Skip");
  50.     switch(add) {
  51.       case 0:
  52.         if(!strcmp(word, oldword)) {
  53.           ReturnStatus("Don't replace identical strings!");
  54.           break;
  55.         }
  56.         CursorLeftWord();
  57.         Delete(strlen(oldword));
  58.         Output(word);
  59.         break;
  60.  
  61.       case 1:
  62.         result = ARexxSend("IRexxSpell", sprintf("ADD %s", word), 10);
  63.         break;
  64.       case 2:
  65.         ReturnStatus("Skipped it!");
  66.         break;
  67.     }
  68.   }
  69.   else
  70.     ReturnStatus(sprintf("Correct spelling of the word '%s'!", word));
  71. }