======== SPELLING CMDS ======

Start spell-checking mode by loading in the dictionary table.
<rAmiga-1:  if (spellerUp) goto label(0)
            if (not startSpell("Udtable","Udict",1)) {
                putMsg("No memory or dictionary not found")
                returnFalse
            }
            label(0)
            putMsg("Speller is up") >

Find first misspelled word, starting at cursor.  Abort with Amiga-ESC.
<rAmiga-2:      if (not spellerUp) {
                    putMsg("Speller not up")
                    returnFalse
                }
				putMsg(" ")
                if (not spell(curFile)) putMsg("Not in dict.") >

Spell-check from cursor fwd.  Mark bad words with "@".
<rAmiga-3:      if (not runKey(rAmiga-1)) returnFalse
                putMsg("Spell checking ... abort with Amiga-ESC")
                while (not spell(curFile)) insertChar(curFile,"@") >

Force file saving to finish so buffer is unlocked
<104:
label(99)
                    getStackSize(n99,n99,n98)
                    if (gtNum(n98,0)) { delay(5) goto label(99) } >

Load supplemental dictionary & spell from cursor fwd.  Add to supplement.
<rAmiga-4:   if (not runKey(rAmiga-1)) returnFalse
             equateNum(n54,curFile)
             putMsg("Dict supplement to use (pmESC = UdSupplement)")
             freebuf(buf54)
             equateNum(n99,0)
             if (inputString(buf54))  {
                if (not loadFile(buf54)) goto label(3)
             } else {
label(3)
                if (not loadFile("UdSupplement")) {
                    if (not newFile) {
                        putMsg("Close a file for me!")
                        returnFalse
                    }
                    setFileName(curfile,"UdSupplement")
                }
             }
             putMsg("Spell checking ... abort with Amiga-ESC")
             if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
label(0)
             while (not spell(buf[n54])) {
                moveCursor(buf[n54],sWord)
                freeBuf(buf54)
                insertRgn(buf54,eFile,buf[n54],word)
                moveCursor(buf[n54],eWord)
                moveCursor(buf54,sFile)
                if (not is(buf54,"'")) if (not is(buf54,alpha)) goto label(0)
				moveCursor(buf54,eFile)
                
                putMsg(buf54)                 .. remove for faster speed
                
                insertChar(buf54,eLine)
                moveCursor(curFile,eFile)

label(4)        .. could remove this block but it helps hugely in speed.
                setSearch(buf54)
                if (search(curFile,locA,locB,-1)) {
                    if (is(curFile,sWord)) goto label(0)
                    moveCursor(curFile,sWord)
                    goto label(4)
                }
                moveCursor(buf54,sChar)
                clearChar(buf54) .. remove eline
                
                ..  this sect for speed
                moveCursor(buf54,sFile)
                copyChar(buf54,n47)      .. copy 1st char of word
                freeBuf(buf52)
                insertChar(buf52,eLine)  .. load in eline-1stchar
                insertChar(buf52,n47)
                moveCursor(curFile,eFile).. search for starting place
				setSearch(buf52)
                search(curfile,locA,locB,-1)
                moveCursor(curFile,eWord).. move fwd, so sWord works
                
                if (is(curFile,sFile)) goto label(1)
                while (nothing) {
                    moveCursor(curFile,sWord)
                    freeBuf(buf53)
                    insertRgn(buf53,eFile,curFile,word)
                    stringComp(n53,buf54,buf53,1)       .. ignore case
                    if (eqNum(n53,0)) goto label(0)     .. found it, continue
                    if (gtNum(n53,0)) {
label(1)
                        moveCursor(curFile,eWord)
                        moveCursor(curFile,eChar)
label(2)
                        insertRgn(curFile,atCursor,buf54,all)
                        insertChar(curFile,eLine)
                        updateDisplay                 .. remove for faster speed
                        incNum(n99)
                        if (gtNum(n99,19)) {
                            fileSize(curFile,n99)  .. force buffer packing
                            equateNum(n99,0)
                        }
                        goto label(0)
                    }
                    if (is(curFile,sFile)) goto label(2)
                }
            }
            moveCursor(curFile,sFile)
            putMsg("These words weren't in dictionary")
            .. stopSpell       .. use if want speller removed
            >

Merge dict supplement with dict-files.  dict.A-Z must be in Current Directory.
<rAmiga-5:  if (isEmpty(curFile)) returnFalse
            moveCursor(curFile,sFile)
            freeBuf(buf52)
            freeBuf(buf54)
            insertRgn(buf54,eFile,"dh0:spell/private/dict. ",all)
            if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
            equateNum(n50,0)
            while (nothing) {
                moveCursor(curFile,eWord)
                moveCursor(curFile,sWord)
                freeBuf(buf53)
                if (not insertRgn(buf53,eFile,curFile,word)) {
label(6)
                        if (getFlag(buf52,changed)) saveFile(buf52)
                        runKey(104) .. force save to complete
                        goto label(0)
                }
                moveCursor(buf53,sFile)
                toUpper(buf53)
                copyChar(buf53,n54)   .. copy 1st letter of word A-Z
                toLower(buf53)
                if (eqNum(n54,39)) equateNum(n54,65)  .. apost becomes 'A'
                else {
                    if (gtNum(n54,90)) goto label(1)  .. must be A-Z
                    if (gtNum(65,n54)) goto label(1)
                }
                moveCursor(buf54,eFile)
                moveCursor(buf54,sChar)
                swapChar(buf54,n54) .. make it "dict.A" etc.
                
                if (not eqNum(n54,n50)) {
                    if (not eqNum(n50,0)) 
                        if (getFlag(buf52,changed)) saveFile(buf52)
                    runKey(104) .. force save to complete
                    clearRgn(buf52,all)
                    fileSize(buf52,n49) .. make it pack buffer
                    if (not insertFile(buf52,eFile,buf54)) {
                    putMsg("Can't find dict.A-Z!")
                        returnFalse
                    }
                    setFileName(buf52,buf54)
                    if (getFlag(buf52,changed)) flipFlag(buf52,changed)
                    equateNum(n50,n54)  .. save dict-letter
                }
                .. put word in dict.
                moveCursor(buf53,eFile)
                putMsg(buf53)
                insertChar(buf53,eLine)
                moveCursor(buf52,eFile)
label(2)
                setSearch(buf53)
                if (search(buf52,locA,locB,-1)) {
                    if (is(buf52,sWord)) goto label(1)
                    goto label(2) .. continue searching
                }
                .. didn't find it.  Do the slow scan & insert the word.
                moveCursor(buf53,eFile)
                moveCursor(buf53,sChar)
                clearChar(buf53) .. remove eLine
                moveCursor(buf52,eFile)
                equateNum(n49,1)
label(4)
                while (nothing) {
                    if (eqNum(n49,1)) do(n48,1,40) moveCursor(buf52,sWord)
                    moveCursor(buf52,sWord)
                    freeBuf(buf51)
                    insertRgn(buf51,eFile,buf52,word)
                    stringComp(n53,buf53,buf51,1)       .. ignore case
                    if (eqNum(n53,0)) goto label(1)     .. found it, continue
                    if (gtNum(n53,0)) {
                        if (eqNum(n49,1)) goto label(5)
                        moveCursor(buf52,eWord)
                        moveCursor(buf52,eChar)
label(3)
                        insertRgn(buf52,atCursor,buf53,all)
                        insertChar(buf52,eLine)
                        goto label(1)
                    }
                    if (is(buf52,sFile)) {
                        if (eqNum(n49,1)) {
label(5)
                            equateNum(n49,0)
                            do (n48,1,41) moveCursor(buf52,eWord)
                            goto label(4)
                        }
                        goto label(3)
                    }
                }

label(1) .. next word
                moveCursor(curFile,eLine)
                moveCursor(curFile,eChar)
                updateDisplay
                if (is(curFile,eFile)) goto label(6)
            }
label(0)
            putMsg("Done.  Run Udbuild to rebuild working dict & table")
            freeBuf(buf52)
>

Remove words from dict-files.  dict.A-Z must be in Current Directory.
<rAmiga-6:  if (isEmpty(curFile)) returnFalse
            moveCursor(curFile,sFile)
            freeBuf(buf52)
            freeBuf(buf54)
            insertRgn(buf54,eFile,"dicts/dict. ",all)
            if (getFlag(curFile,searchCaps)) flipFlag(curFile,searchCaps)
            equateNum(n50,0)
            while (nothing) {
                moveCursor(curFile,eWord)
                moveCursor(curFile,sWord)
                freeBuf(buf53)
                if (not insertRgn(buf53,eFile,curFile,word)) {
label(6)
                        if (getFlag(buf52,changed)) saveFile(buf52)
                        runKey(104) .. force save to complete
                        goto label(0)
                }
                moveCursor(buf53,sFile)
                toUpper(buf53)
                copyChar(buf53,n54)   .. copy 1st letter of word A-Z
                toLower(buf53)
                if (eqNum(n54,"'")) equateNum(n54,"A")  .. apost becomes 'A'
                else {
                    if (gtNum(n54,"Z")) goto label(1)  .. must be A-Z
                    if (gtNum(65,n54)) goto label(1)
                }
                moveCursor(buf54,eFile)
                moveCursor(buf54,sChar)
                swapChar(buf54,n54) .. make it "dict.A" etc.
                
                if (not eqNum(n54,n50)) {
                    if (not eqNum(n50,0)) 
                        if (getFlag(buf52,changed)) saveFile(buf52)
                    runKey(104) .. force save to complete
                    clearRgn(buf52,all)
                    fileSize(buf52,n49) .. make it pack buffer
                    if (not insertFile(buf52,eFile,buf54)) {
                        putMsg("Can't find dict.A-Z!")
                        returnFalse
                    }
                    setFileName(buf52,buf54)
                    if (getFlag(buf52,changed)) flipFlag(buf52,changed)
                    equateNum(n50,n54)  .. save dict-letter
                }
                .. remove word from dict.
                moveCursor(buf53,eFile)
                putMsg(buf53)
                insertChar(buf53,eLine)
                moveCursor(buf52,eFile)
label(2)
                setSearch(buf53)
                if (search(buf52,locA,locB,-1)) {
                    if (is(buf52,sWord)) {
                        clearRgn(buf52,loc)
                        goto label(1) .. next word
                    }
                    goto label(2) .. continue searching
                }

label(1) .. next word
                moveCursor(curFile,eLine)
                moveCursor(curFile,eChar)
                if (is(curFile,eFile)) goto label(6)
                updateDisplay
            }
label(0)
            putMsg("Done.  Run Udbuild to rebuild working dict & table")
            freeBuf(buf52)
>

Stop spell-checking mode.  (Frees up about 12k of memory.)
<rAmiga-8:   if (spellerUp) { stopSpell putMsg("Speller removed") } >

========== Split Windows =========

Remove current split window
<lAmiga-0:  splitWindow(curFile,0)>

Split window to show current file
<lAmiga-c:  splitWindow(curFile,splitSize)>

Split window to show Undo buffer
<lAmiga-1:  splitWindow(buf45,splitSize)>

Split window to show search buffer
<lAmiga-2:  splitWindow(buf49,splitSize)>

Split window to show replace buffer
<lAmiga-3:  splitWindow(buf48,splitSize)>

Split window to show copied-hilite buffer
<lAmiga-4:  splitWindow(buf47,splitSize)>

Split window to show copied-invert buffer
<lAmiga-5:  splitWindow(buf46,splitSize)>

Split window to show copied-columnar buffer
<lAmiga-6:  splitWindow(buf37,splitSize)>

Split window to show directory names
<lAmiga-7:  splitWindow(buf38,splitSize) >

Set split window size
<lAmiga-8: putMsg("# lines in split window (2 or more):")
           if (inputNum(n54)) if (geNum(n54,2)) equateNum(splitSize,n54)
           putMsg(" ")>
Switch to next window split
<lAmiga-9: toggle(windowSplit)>

