home *** CD-ROM | disk | FTP | other *** search
- void export ISpell()
- {
- string result;
- string word = GetWord();
- string check = sprintf("CHECK %s", word);
-
- if(!FindPort("IRexxSpell")) {
- System("run >NIL: ispell >NIL: <NIL: -r");
- if(!FindPort("IRexxSpell", 10)) {
- ReturnStatus("Can't connect to ispell server!");
- return;
- }
- }
- result = ARexxSend("IRexxSpell", check, 10);
-
- if(strcmp("*", result)) {
- /* bad spelling my man!
- catt FrexxEd anotherp ninja pila kung lang qwre */
- string alters[30];
- int numofal=0;
- int startcol=2;
- int endcol;
- int length;
- int add;
- string oldword = word;
- if(strcmp("#", result)) {
- while(endcol>=0) {
- endcol = strstr(result, " ", startcol);
- if(endcol>0) {
- length = endcol-startcol;
- }
- else {
- length = -1;
- }
- alters [ numofal++ ] = substr(result, startcol, length);
- if( numofal == 30) {
- Status("Filled up the alternative array!");
- break;
- }
- startcol=endcol+1;
- }
- RequestWindow("Spell alternatives",
- "", "A", &alters, &word, numofal,
- "Perform", "C", &add, "Replace|Add|Skip");
- }
- else
- RequestWindow("Spell alternatives",
- "Edit", "S", &word,
- "Perform", "C", &add, "Replace|Add|Skip");
- switch(add) {
- case 0:
- if(!strcmp(word, oldword)) {
- ReturnStatus("Don't replace identical strings!");
- break;
- }
- CursorLeftWord();
- Delete(strlen(oldword));
- Output(word);
- break;
-
- case 1:
- result = ARexxSend("IRexxSpell", sprintf("ADD %s", word), 10);
- break;
- case 2:
- ReturnStatus("Skipped it!");
- break;
- }
- }
- else
- ReturnStatus(sprintf("Correct spelling of the word '%s'!", word));
- }