/**************************************************************************/
/* iaspell.rexx - Interactive spell checking with AlphaSpell              */
/* $VER: iaspell.rexx 1.1 (29 Aug 1995)                                   */
/* Copyright © 1995 Fergus Duniho                                         */
/**************************************************************************/
/* This script can be used to provide interactive spell checking to an    */
/* ARexx capable text editor. To use it, your editor needs a way to read  */
/* the last word typed and a way to pass it to ARexx. This script assumes */
/* that the word to be checked is passed as an argument to the script,    */
/* but you could adapt the script to read the word itself. The only other */
/* capability your editor needs to use this script for interactive spell  */
/* checking is the ability to remap the space bar. To use this script,    */
/* remap the space bar to call this script. When you misspell a word,     */
/* script will beep the screen. You may want to adapt it to also tell you */
/* what word was misspelled. It would do this by displaying the value     */
/* passed to the environment variable Word.                               */
/**************************************************************************/

if exists("libs:rexxarplib.library") then do
    if ~show("L","rexxarplib.library") then
        call addlib("rexxarplib.library",0,-30)
end
else say "You need RexxArpLib.library"

if exists("libs:rxgen.library") then do
    if ~show('L','rxgen.library') then
        call addlib('rxgen.library',0,-30,0)
end
else say "You need rxgen.library"

Parse Arg word

com = "AlphaSpell >ENV:Word -To ENV:ok -d" GetENV("DDIR") "-w" word GetENV("Dict")

ADDRESS COMMAND com

/* Here is one way to get an audible beep whenever you mistype a word.
** You will need jbplay, available from the Aminet in mus/play, and a
** sound sample, such as Shortbeep, found in mods/smpl. You should
** specify a path name for the sample */

/* ADDRESS COMMAND "jbplay Shortbeep" */

IF GetENV("ok") = "0" THEN DO
        LIBS.intuition = '00 00 00 00'x
        LIBS.intuition.OPENCOUNT = 0
        LIBS.intuition.DisplayBeep='FFA0'x||I||'2009'x

        CALL GenOpenLib("intuition",0)
        CALL GenACall("intuition","DisplayBeep",0)
        CALL GenCloseLib("intuition")
END

EXIT
