home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* iSpellAll.rexx © 1999 Brecht Machiels <darklite@flashmail.com> */
- /* */
- /* Checks the spelling of all text in current Write window (YAM) */
- /******************************************************************/
- /*
- $VER: iSpellAll v1.7
- $AUTHOR: Copyright © 1999 Brecht Machiels / Lorens Johansson <SnorsleX@SoftHome.net>
- $DESCRIPTION: Checks all text in Texteditor for spelling mistakes using ISpell.
- */
-
- BINPATH = "iSpell:bin/" /* iSpell binaries path */
- LIBPATH = "iSpell:lib/" /* iSpell dictionaries path */
-
- LANGUAGE.0 = 1 /* Number of languages */
- LANGUAGE.1 = "English" /* Language #1 */
- LANGUAGE.2 = "Nederlands" /* Language #2 */
-
- OPTIONS RESULTS
-
- call pragma('D', BINPATH)
- call pragma('S', 8192)
-
- languages=""
- if language.0 > 1 then do
- languages=language.1
- langnr=language.0
- do langnr=2 to language.0
- languages=languages||"|"||language.langnr
- end
- end
-
- languages=languages||"|_Quit"
-
- if language.0 > 1 then Address 'YAM' 'REQUEST "Select the language:" "'languages'"'
- else do
- call sellang(language.1)
- exit
- end
-
- SELECT
- WHEN result=0 then exit
- WHEN result=1 then call sellang(language.1)
- WHEN result=2 then call sellang(language.2)
- WHEN result=3 then call sellang(language.3)
- WHEN result=4 then call sellang(language.4)
- WHEN result=5 then call sellang(language.5)
- WHEN result=6 then call sellang(language.6)
- WHEN result=7 then call sellang(language.7)
- WHEN result=8 then call sellang(language.8)
- WHEN result=9 then call sellang(language.9)
- OTHERWISE call exit
- end
- exit
-
- sellang:
- language=arg(1)
- if show('P', 'IRexxSpell') then do
- address 'IRexxSpell' quickcheck LANGUAGE
- if result = 'bad' then do
- address 'IRexxSpell' exit
- address command "run <nil: >nil: "BINPATH"iSpell -d"LANGUAGE" -r >nil: <nil:"
- address command "waitforport IRexxSpell"
- end
- end
- else do
- address command "run <nil: >nil: "BINPATH"iSpell -d"LANGUAGE" -r >nil: <nil:"
- address command "waitforport IRexxSpell"
- end
- CALL start
- return
-
- start:
- Address 'YAM' 'WRITEEDITOR "'POSITION sof'"'
-
- do forever
- Address 'YAM' 'WRITEEDITOR GETCURSOR'
- wordpos = result + 1
- Address 'YAM' 'WRITEEDITOR GETLINE'
- temp = compress(subword(substr(result, wordpos), 1, 1), '0a'X)
- check = compress(temp, '.,?!()')
-
- if check = '' then leave
- if verify(check, ';:/_&|@"#''§^ç<>{}°©1234567890[]®', 'm') ~= 0 then
- Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- else do
- Address 'IRexxSpell' 'QUICKCHECK 'check''
- if result = 'bad' then do
- Address 'YAM' 'REQUEST "'check' is spelled incorrectly!" "_Continue|_Lookup|_Accept|A_dd|_Stop"'
- select
- when result = 1 then Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- when result = 2 then do
- Address 'IRexxSpell' 'CHECK 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
- r=result
- r1=substr(r,1,1)
- r3=substr(r,3)
- select
- when r1 = '*' then nop
- when r1 = '+' then nop
- when r1 = '&' then
- if words(r) = 2 then do
- r3=substr(r3,POS(":",r3)+2)
- Address 'YAM' 'REQUEST "Choose a replacement for 'check':" "'r3'|_Cancel"'
- if result=1 then do
- newword=r3
- call ReplaceWord(newword)
- end
- if result=0 then nop
- end
- else do
- r3=substr(r3,POS(":",r3)+2)
- allwords=r3
- x=0
- do UNTIL allwords=""
- x=x+1
- posi=pos(",",allwords)
- if posi ~= 0 then do
- temp.x = left(allwords,posi-1)
- allwords=substr(allwords,posi+2)
- end
- if posi = 0 then do
- temp.x = allwords
- allwords=""
- end
- end
- nums=x
- choose=temp.1
- do x=2 to nums
- choose=choose||"|"||temp.x
- end
- Address 'YAM' 'REQUEST "Choose a replacement for 'check':" "'choose'|_Cancel"'
- nr=result
- if nr ~= 0 then do
- do x=1 to nums
- if nr=x then newword=temp.x
- end
- call ReplaceWord(newword)
- end
- end
- when r1 = '#' then Address 'YAM' 'REQUEST "Could not find anything for 'check'!" "_Ok"'
- otherwise nop
- end
- Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- end
- when result = 3 then do
- Address 'IRexxSpell' 'ACCEPT 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
- Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- end
- when result = 4 then do
- Address 'IRexxSpell' 'ADD 'translate(check, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'
- Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- end
- when result = 0 then exit
- end
- end
- else Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- end
- end
-
- Address 'YAM' 'REQUEST "End of document reached" " _Ok | _Exit ISpell "'
- select
- when result = 1 then nop
- when result = 0 then address 'IRexxSpell' exit
- otherwise nop
- end
- return
-
- ReplaceWord:
- newword=arg(1)
- Address 'YAM' 'WRITEEDITOR "'MARK on'"'
- Address 'YAM' 'WRITEEDITOR "'NEXT word'"'
- Address 'YAM' 'WRITEEDITOR "'CURSOR left'"'
- Address 'YAM' 'WRITEEDITOR "'ERASE'"'
- Address 'YAM' 'WRITEEDITOR "'TEXT newword'"'
- return
-