home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / MUI / MCC_TextEditor / iSpell / Rexx / iSpellAll.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-09-07  |  5.8 KB  |  176 lines

  1. /******************************************************************/
  2. /* iSpellAll.rexx © 1999 Brecht Machiels <darklite@flashmail.com> */
  3. /*                                                                */
  4. /* Checks the spelling of all text in current Write window (YAM)  */
  5. /******************************************************************/
  6. /*
  7. $VER: iSpellAll v1.7
  8. $AUTHOR: Copyright © 1999 Brecht Machiels / Lorens Johansson <SnorsleX@SoftHome.net>
  9. $DESCRIPTION: Checks all text in Texteditor for spelling mistakes using ISpell.
  10. */
  11.  
  12. BINPATH = "iSpell:bin/"           /* iSpell binaries path         */
  13. LIBPATH = "iSpell:lib/"           /* iSpell dictionaries path     */
  14.  
  15. LANGUAGE.0 = 1                    /* Number of languages          */
  16. LANGUAGE.1 = "English"            /* Language #1                  */
  17. LANGUAGE.2 = "Nederlands"         /* Language #2                  */
  18.  
  19. OPTIONS RESULTS
  20.  
  21. call pragma('D', BINPATH)
  22. call pragma('S', 8192)
  23.  
  24. languages=""
  25. if language.0 > 1 then do
  26.  languages=language.1
  27.  langnr=language.0
  28.  do langnr=2 to language.0
  29.   languages=languages||"|"||language.langnr
  30.  end
  31. end
  32.  
  33. languages=languages||"|_Quit"
  34.  
  35. if language.0 > 1 then Address 'YAM' 'REQUEST "Select the language:" "'languages'"'
  36. else do
  37.  call sellang(language.1)
  38.  exit
  39. end
  40.  
  41. SELECT
  42.  WHEN result=0 then exit
  43.  WHEN result=1 then call sellang(language.1)
  44.  WHEN result=2 then call sellang(language.2)
  45.  WHEN result=3 then call sellang(language.3)
  46.  WHEN result=4 then call sellang(language.4)
  47.  WHEN result=5 then call sellang(language.5)
  48.  WHEN result=6 then call sellang(language.6)
  49.  WHEN result=7 then call sellang(language.7)
  50.  WHEN result=8 then call sellang(language.8)
  51.  WHEN result=9 then call sellang(language.9)
  52.  OTHERWISE call exit
  53. end
  54. exit
  55.  
  56. sellang:
  57. language=arg(1)
  58. if show('P', 'IRexxSpell') then do
  59.   address 'IRexxSpell' quickcheck LANGUAGE
  60.   if result = 'bad' then do
  61.     address 'IRexxSpell' exit
  62.     address command "run <nil: >nil: "BINPATH"iSpell -d"LANGUAGE" -r >nil: <nil:"
  63.     address command "waitforport IRexxSpell"
  64.   end
  65. end
  66. else do
  67.   address command "run <nil: >nil: "BINPATH"iSpell -d"LANGUAGE" -r >nil: <nil:"
  68.   address command "waitforport IRexxSpell"
  69. end
  70. CALL start
  71. return
  72.  
  73. start:
  74. Address 'YAM' 'WRITEEDITOR "'POSITION sof'"'
  75.  
  76. do forever
  77.   Address 'YAM' 'WRITEEDITOR GETCURSOR'
  78.   wordpos = result + 1
  79.   Address 'YAM' 'WRITEEDITOR GETLINE'
  80.   temp = compress(subword(substr(result, wordpos), 1, 1), '0a'X)
  81.   check = compress(temp, '.,?!()')
  82.  
  83.   if check = '' then leave
  84.   if verify(check, ';:/_&|@"#''§^ç<>{}°©1234567890[]®', 'm') ~= 0 then
  85.     Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  86.   else do
  87.     Address 'IRexxSpell' 'QUICKCHECK 'check''
  88.     if result = 'bad' then do
  89.       Address 'YAM' 'REQUEST "'check' is spelled incorrectly!" "_Continue|_Lookup|_Accept|A_dd|_Stop"'
  90.       select
  91.         when result = 1 then Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  92.         when result = 2 then do
  93.             Address 'IRexxSpell' 'CHECK 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
  94.             r=result
  95.             r1=substr(r,1,1)
  96.             r3=substr(r,3)
  97.             select
  98.               when r1 = '*' then nop
  99.               when r1 = '+' then nop
  100.               when r1 = '&' then
  101.                 if words(r) = 2 then do
  102.                   r3=substr(r3,POS(":",r3)+2)
  103.                   Address 'YAM' 'REQUEST "Choose a replacement for 'check':" "'r3'|_Cancel"'
  104.                   if result=1 then do
  105.                     newword=r3
  106.                     call ReplaceWord(newword)
  107.                   end
  108.                   if result=0 then nop
  109.                 end
  110.                 else do
  111.                   r3=substr(r3,POS(":",r3)+2)
  112.                   allwords=r3
  113.                   x=0
  114.                   do UNTIL allwords=""
  115.                     x=x+1
  116.                     posi=pos(",",allwords)
  117.                     if posi ~= 0 then do
  118.                       temp.x = left(allwords,posi-1)
  119.                       allwords=substr(allwords,posi+2)
  120.                     end
  121.                     if posi = 0 then do
  122.                       temp.x = allwords
  123.                       allwords=""
  124.                     end
  125.                   end
  126.                   nums=x
  127.                   choose=temp.1
  128.                   do x=2 to nums
  129.                    choose=choose||"|"||temp.x
  130.                   end
  131.                   Address 'YAM' 'REQUEST "Choose a replacement for 'check':" "'choose'|_Cancel"'
  132.                   nr=result
  133.                   if nr ~= 0 then do
  134.                     do x=1 to nums
  135.                       if nr=x then newword=temp.x
  136.                     end
  137.                     call ReplaceWord(newword)
  138.                   end
  139.                 end
  140.               when r1 = '#' then Address 'YAM' 'REQUEST "Could not find anything for 'check'!" "_Ok"'
  141.                 otherwise nop
  142.             end
  143.             Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  144.           end
  145.         when result = 3 then do
  146.             Address 'IRexxSpell' 'ACCEPT 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
  147.             Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  148.           end
  149.         when result = 4 then do
  150.             Address 'IRexxSpell' 'ADD 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
  151.             Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  152.           end
  153.         when result = 0 then exit
  154.       end
  155.     end
  156.     else Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  157.   end
  158. end
  159.  
  160. Address 'YAM' 'REQUEST "End of document reached" "       _Ok       |  _Exit ISpell  "'
  161. select
  162.   when result = 1 then nop
  163.   when result = 0 then address 'IRexxSpell' exit
  164.   otherwise nop
  165. end
  166. return
  167.  
  168. ReplaceWord:
  169. newword=arg(1)
  170. Address 'YAM' 'WRITEEDITOR "'MARK on'"'
  171. Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  172. Address 'YAM' 'WRITEEDITOR "'CURSOR left'"'
  173. Address 'YAM' 'WRITEEDITOR "'ERASE'"'
  174. Address 'YAM' 'WRITEEDITOR "'TEXT newword'"'
  175. return
  176.