dialog sc {
title "Spell Check"
size -1 -1 96 78
option dbu
edit "", 1, 2 3 92 10, autohs
button "Check", 2, 63 14 28 12
text "Spelled Correct:", 3, 6 17 39 8, hide
text "", 4, 46 17 8 8, hide
list 6, 0 28 96 50, size hsbar vsbar
}
on *:DIALOG:sc:init:*:{
did -f sc 1
did -t sc 2
}
on *:DIALOG:sc:sclick:2:{
if ($did(1)) {
if ($sock(spell)) {
if ($input(The Spell Check socket is already connected $+ $crlf $+ $crlf $+ Close the socket and continue search?,yw,Connected)) {
sockclose spell
goto end
}
halt
}
:end
did -r sc 6
did -h sc 3,4
sockopen spell www.spellcheck.net 80
}
else { noop $input(Supply a word/phrase to spell check,ow,Supply) }
}
on *:DIALOG:sc:dclick:6:{
if ($did(6).seltext) {
if (!$dialog(define)) { dialog -md define define }
if ($sock(def)) {
if ($input(The definition socket is already open $+ $crlf $+ $crlf $+ Close socket and continue?,wy,Already connected)) {
sockclose def
goto end
}
else {
dialog -x define
halt
}
}
:end
did -ra define 1 $did(6).seltext
did -r define 3
did -a define 3 Searching for $qt($did(6).seltext) $+ ...
did -z define 3
sockopen def wordnet.princeton.edu 80
}
}
on *:SOCKOPEN:spell:{
sockwrite -n $sockname GET /cgi-bin/spell.exe?action=CHECKWORD&string= $+ $replace($did(sc,1),$chr(32),+) HTTP/1.1
sockwrite -n $sockname Host: www.spellcheck.net
sockwrite -n $sockname $+($crlf,$crlf)
}
on *:SOCKREAD:spell:{
if ($sockerr) { did -ra sc 6 Socket Error $qt($sockerr) }
else {
var %read
sockread %read
if ( isin %read) {
sockmark spell
sockclose spell
}
if ($sock(spell).mark == continue) {
did -a sc 6 $remove(%read,
)
did -z sc 6
}
if (*
"*" is spelled correctly.
* iswm %read) {
did -v sc 3,4
did -ra sc 4 Yes
did -a sc 6 $did(sc,1)
did -z sc 6
sockclose spell
}
if (*
"*" is misspelled.* iswm %read) {
did -v sc 3,4
did -ra sc 4 No
}
if (*
Here are some suggestions:
* iswm %read) { sockmark spell continue } if (*