home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR4
/
TEXMAC.ZIP
/
SPELL.SPM
< prev
next >
Wrap
Text File
|
1990-12-31
|
6KB
|
229 lines
LoadSpeller : ; force the speller into memory
if stopped {
if ((0 subchar engine) != 'S') {
status "\nLoading speller..."
set Q0 "speller.eng" NeedDisk
set engine QJ
}
}
0 -> AutoCorrect ; if speller can't load, force autocorrect off
CorrectDoIt : ; Loadspeller must have been done. Passed the flags!
-> int correctflags ; flags for correction
1-> int result ; for the result
if inruler (toeol c 0 return) ; don't do anything in a ruler
if ((previous == '^O') || (previous == '^V') || (current = '@')) {
past istoken
0 return
} ; don't ever lookup formatter words
if ((current < '0')|| (current > '9')) {
do {
correctflags (runengine (past istoken)) -> result
}
while (result & 16)
}
else (0 -> result) ; return false if word not checked
past istoken
result ; return result
CorrectLastBad : LoadSpeller
mark {
if (BadWordPending > 0) {
mark {
to QE
delete past istoken QD
del
}
0 r search QD
58+64 CorrectDoIt
--BadWordPending
}
else (message "\nNo misspelled words have been recorded.")
}
CorrectAllBad : ; correct each misspelling recorded in QE
if !BadWordPending message "\nNo misspelled words have been recorded."
else {
mark {
while (BadWordPending>0) (CorrectLastBad $ WordBack)
message "No more misspelled words recorded."
}
set QE ""
}
CorrectFile : mark {
r toend
LoadSpeller
while (to istoken) {
status "\nChecking spelling..."
if ('^O' isin) ('^N' csearch c) ; don't correct within ^O's
else if stopped(26+64 CorrectDoIt) (setmark abort)
}
message "\nSpell correction complete."
}
CorrectRegionRest : LoadSpeller
if istoken (r past istoken) ; ensure that the current word is included
while ((to istoken) && beforemark) {
status "\nChecking spelling..."
if ('^O' isin) ('^N' csearch c) ; don't correct within ^O's
else if stopped (26+64 CorrectDoIt) (set gmark abort)
}
message "\nSpell correction complete."
CorrectPara : mark {
ParagraphFwd
mark (ParagraphBack CorrectRegionRest)
}
CorrectRegion : if select {
markregion CorrectRegionRest
Unselect
}
else NoBlock
CorrectRest : LoadSpeller
mark {
if istoken r past istoken
if stopped {
while to istoken {
status "\nChecking spelling..."
if ('^O' isin) ('^N' csearch c)
else (26+64 CorrectDoIt)
}
draw
if ask "\nAt end of file. Continue from top? " {
r toend
while ((to istoken) && beforemark) {
status "\nChecking spelling..."
if ('^O' isin) ('^N' csearch c)
else (26+64 CorrectDoIt)
}
}
} {setmark return}
}
message "\nSpell correction complete."
CorrectSent : mark {
SentenceFwd
mark (SentenceBack CorrectRegionRest)
}
CorrectWord : int result
LoadSpeller
mark {
if !istoken (r to istoken) ; if between words, do prev
r past istoken
if !stopped (58+64 CorrectDoIt ->result) {
result == 1 ? message "\nSpelling is correct"
}
}
; set Q0 to contain the name of one of the speller dictionaries
; 0 = Main 1 = User
GetDictionary :
->int x
set Q0 QJ ; get engine params
mark {
to Q0
erase (to iswhite past iswhite) ; engine name
if x { ; get user dict name
erase (to iswhite past iswhite)
}
else {
to iswhite erase toend
}
r toend while (!isend) ToUpper ; return in upper case
erase toend ; remove extension
}
SetDictionary : ; 0 = main, 1 = user in Q0
->int user
set Q0 "speller.eng" NeedDisk
set QD QJ ; preserve so we can restore if error
do {
if user { ; user dictionary
10 set Q0 flist "*.LX2"
if !length Q0 error "No user dictionaries found"
set Q0 fchange "%.LX2" Q0 ; add extension back
}
else { ; main dictionary
10 set Q0 flist "*.LX1"
if !length Q0 error "No main dictionaries found"
set Q0 fchange "%.LX1" Q0 ; add extension back
}
mark {
to QJ ; put new file name in
if user { ; user dic
toend
erase (r to iswhite) ; delete name of old use dict
insert Q0 ; put in new name
}
else { ; main dic
to iswhite past iswhite ; to start of main dict name
erase (to iswhite) ; remove main dict. name
insert Q0 ; put in new one
}
}
if stopped {
status "\nLoading new dictionary..."
set engine QJ ; set new engine parameters
}
{
message "\nDictionary not for spelling correction. Try again."
set QJ QD
}
else break
}
UnLoadEngine :
int keyp
int FileFound
if WasEngine=2 { ; Save User dictionary
if !(2 exist "SPELLER.ENG") { ; speller.eng always in same disk
set Q1 Q0 ; Store actual request in Q1
set Q0 "SPELLER.ENG"
SetQDDiskName
set Q0 Q1 ; Restore Q0
do {
message "\nInsert your \"" QD "\" disk in drive A and press any key (ESC CANCELS)"
KeyGet -> keyp
if(keyp == abortkey || keyp = '^[') abort
2 exist "SPELLER.ENG" -> FileFound
if !FileFound stopped error "That was the wrong disk."
else break
}
}
}
set engine "" ; Unload engine
0->WasEngine ; Reset engine flag
; Use the following macro to assure that a disk with a needed file is there
NeedDisk : ; Q0 = File to look for
int FileFound
int keyp
if (WasEngine && FloppyDisk) UnLoadEngine ; Unload before flip disk
0 QCap
if (2 exist Q0) return
if !FloppyDisk { ; User has a hard-disk, file missing error
mark {
to QD clear
insert "The file '"
insert Q0
insert "' cannot be found."
}
error QD ; Quit with error
}
1 Bell ; alert user if disk not found
; At this step we are sure user has a floppy disk system
SetQDDiskName ; So get the disk label to insert in QD
do {
message "\nInsert your \"" QD "\" disk in drive A and press any key (ESC CANCELS)"
KeyGet -> keyp
if (keyp == abortkey || keyp = '^[') abort
2 exist Q0 -> FileFound
if !FileFound stopped error "That was the wrong disk."
else break
}