Dict+ — File Browser
Dictv1.0 / Dictv1.0 / dict.mrc
dict.mrc — 4.85 KB — Download this file
;1/22/00
;I don't care what you do with this script, just don't edit anything below
;usage: /dict [word]
dialog dict {
title "Dict+"
size %dictpos
text "Look Up:",1, 1 10 96 16, right
edit "",2, 100 5 200 23, autohs
text "Search Type:",3,1 34 96 16, right
combo 4,101 29 250 100, drop
text "Database:",5,1 58 96 16, right
combo 6,101 53 250 100, drop return
button "Define",7, 119 80 80 20,ok default
button "Reset",8,201 80 80 20
edit "",10, 12 102 376 150, read multi vsbar
text "by fubar",9,325 235 44 13
button "Clear",11, 162 254 75 18
box "",12, -3 268 420 100
button "?",13,352 53 21 21,hide
button "Exit",90,328 279 60 20, cancel
}
on *:dialog:dict:init:0: {
if (%dictpos == $null) { dialog -s dict -1 -1 400 300 | %dictpos = -1 -1 400 300 }
var %didy = did -a dict 4
tokenize 32 Return Definitions Match words exactly prefixes substring occurring anywhere in word suffixes POSIX- regular expressions Old (basic) using SOUNDEX algorithm within Levenshtein distance one
did -ac dict 4 $1-2 | %didy $3-5 | %didy $3 $6 | %didy $3 $7-11 | %didy $3 $12 | %didy $13-15 | %didy $16-17 $14-15 | %didy $3 $18-20 | %didy $3 $4 $21-
var %didy = did -a dict 6,%n = 1
tokenize 44 First Match,All,Webster's Dictionary(1913),Wordnet (r) 1.6,U.S. Gazetteer,Jargon File,FOLDOC,The Elements,Easton's 1897 Bible Dictionary,Hitchcock's Bible Names Dictionary (late 1800's)
:looped | var %buck = $ [ $+ [ %n ] ] | if (%buck) { %didy %buck | inc %n | goto looped } | did -c dict 6 1
did -c $dname 7 | did -v $dname 9
if ($defvar(8)) { did -a $dname 2 $defvar(8) | dialog -k $dname }
}
on *:dialog:dict:sclick:6:did $iif($did($did,1).sel > 2,-v,-h) $dname 13
on *:dialog:dict:sclick:7: {
if ($did($did) == Stop) { if ($did(10,2) == $null) { did -r dict 10 } | closedict | return }
if (($did(2)) && ($did(4)) && ($did(6))) {
did -ra dict 10 ** Connecting... | dictbusy -b
defvar 1 $replace($did(4).sel,2,exact,3,prefix,4,substring,5,suffix,6,re,7,regexp,8,soundex,9,lev)
defvar 2 $replace($did(6).sel,10,hitchcock,9,easton,1,*,2,*,3,web1913,4,wn,5,gazetteer,6,jargon,7,foldoc,8,elements)
if ($gettok($did(2),2,32)) defvar 3 " $+ $did(2) $+ "
else defvar 3 $did(2)
if ($did(6).sel == 2) defvar 4 $true
else defvar 4
defvar 5 $true
if ($did(2) == 00-database-info) did -r $dname 2
sockclose dict | sockopen dict dict.org 2628
}
else did -ar dict 10 *** Invalid parameters
halt
}
on *:dialog:dict:sclick:8: did -c dict 6 1 | did -c dict 4 1 | did -rf dict 2
on *:dialog:dict:sclick:11:did -r dict 10 | did -f dict 2
on *:dialog:dict:sclick:13:did -ar $dname 2 00-database-info | dialog -k $dname
on *:dialog:dict:sclick:90:closedict | set %dictpos $dialog(dict).x $dialog(dict).y 400 300
on *:sockopen:dict: if ($socker) { did -a dict 10 ** Socket Error: $sockerr | return } | else did -ra dict 10 ** Connection established, looking up $remove($defvar(3),00-)
on *:sockread:dict: {
if ($socker) { did -a dict 10 ** Socket Error: $sockerr | return }
:read
var %def1
sockread %def1
if (%def1 == $null) %def1 = $chr(160)
mandefine [ %def1 $crlf ]
unset %def1
if ($sockbr) goto read
}
alias -l mandefine {
if ($1 == 250) closedict
if ($1 == 552) { did -ar dict 10 ** No Match for $defvar(3) | putdict quit | return }
if ($defvar(6)) {
if (($1 == .) && ($defvar(4) == $null)) closedict
elseif (($1 == $defvar(2)) && ("* iswm $2)) did -a dict 10 $gettok($1-,2,34) [ $crlf ]
elseif ($1 == 151) {
if ($did(dict,6).sel < 3) did -a dict 10 $str($chr(160),10) *** $gettok($1-,4,34) *** [ $crlf ]
}
else did -a dict 10 $1-
}
if ($1 == 220) {
if ($defvar(1) == 1) {
putdict DEFINE $defvar(2) $defvar(3)
if ($defvar(2) == *) defvar 7 $true
}
else putdict MATCH $defvar(2) $defvar(1) $defvar(3)
}
if (($1 isnum 151-152) && ($defvar(6) == $null)) {
defvar 6 $true
if ($defvar(5)) { did -r dict 10 | defvar 5 }
if ($did(dict,6).sel < 3) {
if ($gettok($1-,4,34)) did -a dict 10 $str($chr(160),10) *** $gettok($1-,4,34) *** [ $crlf ]
elseif (*matches?found* iswm $1-) did -a dict 10 $str($chr(160),10) *** $remove($2-,$crlf) *** [ $crlf ]
}
}
}
on *:sockclose:dict:closedict
alias dict if (%dictpos == $null) set %dictpos -1 -1 400 300 | defvar 8 $1- | dialog $iif($dialog(dict),-v,-md) dict dict
alias -l defvar if (%def == $null) %def = : : : : : : : : : | if ($isid) return $gettok(%def,$1,58) | else set %def $puttok(%def,$iif($2,$2,$chr(32)),$1,58) $+ :
alias -l putdict if ($sock(dict)) sockwrite -n dict $1-
alias -l closedict did -c dict 10 1 | dictbusy -e | unset %def | sockclose dict | return
alias -l dictbusy did -ra dict 7 $iif($1 == -b,Stop,Define) | did $1 dict 8 | did $1 $+ f dict 2 | did $1 dict 4 | did $1 dict 6
on *:load:.remote on | .timer 1 1 /dict