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

  1.    /************************/
  2.   /*   iSpell.rexx 1.9    */
  3.  /* Brecht Machiels 1999 */
  4. /************************
  5. $VER: iSpell v1.9
  6. $AUTHOR: Copyright © 1999 Brecht Machiels
  7. $DESCRIPTION: Checks spelling in YAM with nice GUI
  8. *********************/
  9.  
  10. SCREEN = 'Workbench'
  11.  
  12. BINPATH = "iSpell:bin/"           /* iSpell binaries path         */
  13. LIBPATH = "iSpell:lib/"           /* iSpell dictionaries path     */
  14.  
  15. LANGUAGE.0 = 2                    /* Number of languages          */
  16. LANGUAGE.1 = "English"            /* Language #1                  */
  17. LANGUAGE.2 = "Nederlands"         /* Language #2                  */
  18.                                   /* You can add languages(upto 9)*/
  19. /*********/
  20.  
  21. Window_PublicScreen =             0x804278e4 /* V6  isg STRPTR */
  22. Group_Rows =                      0x8042b68f /* V4  is. LONG */
  23. Group_Spacing =                   0x8042866d /* V4  is. LONG */
  24.  
  25. MUIV_List_Insert_Bottom = -3
  26.  
  27. /**/
  28.  
  29. OPTIONS RESULTS
  30.  
  31. ADDRESS ISPELLMR
  32.  
  33. window ID MAIN COMMAND 'quit' PORT ISPELLMR TITLE 'iSpell' ATTRS Window_PublicScreen SCREEN
  34.   group HORIZ
  35.     group
  36.         text ID TWORD  LABEL '\n\n\033cLoading dictionary\n\n'
  37.       group HORIZ ATTRS Group_Rows 2 Group_Spacing 0
  38.         button ID NEXT  HELP '"Ignore this word & continue checking"'     LABEL 'Next'
  39.         button ID ACCPT HELP '"Accept this word for this session"'        LABEL 'Accept'
  40.         button ID ADD   HELP '"Add this word to the private dictionary"'  LABEL 'Add'
  41.         button ID RSTRT HELP '"Restart at the beginning of the document"' LABEL 'Restart'
  42.         button ID STOP  HELP '"Stop checking of the document"'            LABEL 'Stop'
  43.         button ID EXIT  HELP '"Stop checking & exit iSpell"'              LABEL 'Exit'
  44.       endgroup
  45.     endgroup
  46.       list ID SLST
  47.   endgroup
  48. endwindow
  49.  
  50. call pragma('D', BINPATH)
  51. call pragma('S', 8192)
  52.  
  53. languages=""
  54. if language.0 > 1 then do
  55.  languages=language.1
  56.  langnr=language.0
  57.  do langnr=2 to language.0
  58.   languages=languages||"|"||language.langnr
  59.  end
  60. end
  61. else languages=language.1
  62.  
  63. languages=languages||"|_Quit"
  64. Address 'YAM' 'REQUEST "Select the language:" "'languages'"'
  65.  
  66. SELECT
  67.  WHEN result=0 then exit
  68.  WHEN result=1 then call SelLang(language.1)
  69.  WHEN result=2 then call SelLang(language.2)
  70.  WHEN result=3 then call SelLang(language.3)
  71.  WHEN result=4 then call SelLang(language.4)
  72.  WHEN result=5 then call SelLang(language.5)
  73.  WHEN result=6 then call SelLang(language.6)
  74.  WHEN result=7 then call SelLang(language.7)
  75.  WHEN result=8 then call SelLang(language.8)
  76.  WHEN result=9 then call SelLang(language.9)
  77.  OTHERWISE call exit
  78. end
  79.  
  80. SelLang:
  81. language=arg(1)
  82. if show('P', 'IRexxSpell') then do
  83.   address 'IRexxSpell' quickcheck LANGUAGE
  84.   if result = 'bad' then do
  85.     address 'IRexxSpell' exit
  86.     address command "run <nil: >nil: "BINPATH"iSpell -d"LANGUAGE" -p"LIBPATH""LANGUAGE" -r >nil: <nil:"
  87.     address command "waitforport IRexxSpell"
  88.   end
  89. end
  90. else do
  91.   address command "run <nil: >nil: "BINPATH"iSpell -d"LANGUAGE" -p"LIBPATH""LANGUAGE" -r >nil: <nil:"
  92.   address command "waitforport IRexxSpell"
  93. end
  94. CALL Start
  95. return
  96.  
  97. Start:
  98. Address 'YAM' 'WRITEEDITOR "'POSITION sof'"'
  99.  
  100. do forever
  101.   Address 'YAM' 'WRITEEDITOR GETCURSOR'
  102.   wordpos = result + 1
  103.   Address 'YAM' 'WRITEEDITOR GETLINE'
  104.   temp = subword(substr(result, wordpos), 1, 1)
  105.   check = compress(temp, '.?!()')
  106.  
  107.   if check = '' then CALL stop
  108.   if verify(check, ';:/_&|@"#''§^ç<>{}°©1234567890[]®', 'm') ~= 0 then
  109.     Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  110.   else do
  111.     Address 'IRexxSpell' 'QUICKCHECK 'check''
  112.     result = checkword
  113.     if checkword = 'bad' then do
  114.       text ID TWORD LABEL '\n\033c"\033b'checkword'\033n" is spelled incorrectly\n\n\033cSelect an option'
  115.       address 'IRexxSpell' check checkwork
  116.       r = result
  117.       r1 = substr(r,1,1)
  118.       select
  119.         when r1 = '#' then suggest = "No_Suggestions"
  120.         when r1 = '&' then do
  121.           rt = space(compress(r,'&1234567890:')
  122.           suggest = rt
  123.         end
  124.         otherwise suggest = checkword
  125.       end
  126.       index = 0
  127.       do index = index + 1 while index ~= words(suggest) + 1
  128.         list ID SLST INSERT POS MUIV_List_Insert_Bottom STRING subword(suggest,index,1)
  129.       end
  130.       do forever
  131.         callhook ID SLST  COMMAND 'CALL ReplaceWord(%s);leave' PORT ISPELLMR
  132.         callhook ID NEXT  COMMAND 'Address 'YAM' 'WRITEEDITOR "'NEXT word'"';leave' PORT ISPELLMR
  133.         callhook ID ADD   COMMAND 'Address 'IRexxSpell' 'ADD 'check'';leave' PORT ISPELLMR
  134.         callhook ID ACCPT COMMAND 'Address 'IRexxSpell' 'ACCEPT 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");leave' PORT ISPELLMR
  135.         callhook ID RSTRT COMMAND 'CALL Start' PORT ISPELLMR
  136.         callhook ID STOP  COMMAND 'exit' PORT ISPELLMR
  137.         callhook ID EXIT  COMMAND 'CALL CleanExit' PORT ISPELLMR
  138.       end
  139.       Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  140.     end
  141.   end
  142. end
  143.  
  144. ReplaceWord:
  145. newword=arg(1)
  146. Address 'YAM' 'WRITEEDITOR "'MARK on'"'
  147. Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  148. Address 'YAM' 'WRITEEDITOR "'CURSOR left'"'
  149. Address 'YAM' 'WRITEEDITOR "'ERASE'"'
  150. Address 'YAM' 'WRITEEDITOR "'TEXT newword'"'
  151. Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
  152. return
  153.  
  154. CleanExit:
  155. Address 'IRexxSpell' 'EXIT'
  156. exit
  157.  
  158.