Dictionary script by BloodHound
About
It looks up the definition of a word based on the first result from dictionary.reference.com. You can either use this alias or dialog based.
Syntax
/dict : (Alias syntax mentioned above) Echoes the results of the lookup into the active window
/dictd or channel/menubar popups : (Dialog based mentioned above) Opens up a dialog in which you can type in the word to define and have the results dumped in an editbox. Some find this easier than the alias.
alias dict {
if $1 {
sockopen dt dictionary.reference.com 80
set %dt.current $v1
set %dt.method echo -tc info2 $iif($active != Status window,$active)
}
else {
echo -atc info *** Error in /dict: Provide correct syntax.
}
}
alias -l dictd dialog $iif($dialog(dict),-v,-m) dict dict
menu channel,menubar {
Dictionary lookup:dictd
}
on *:sockopen:dt:{
sockwrite -nt dt GET /browse/ $+ %dt.current HTTP/1.1
sockwrite -nt dt Host: dictionary.reference.com
sockwrite -nt dt $crlf
}
on *:sockread:dt:{
if $sockerr {
%dt.method ! Error in socket ! $sock(dt).wsmsg
}
else {
var %dtr, %a = unset %dt. $+ $chr(42) $chr(124) sockclose dt
sockread %dtr
if *No*found* iswm %dtr {
%dt.method *Dictionary Results* No results found.
scon -at1 %a
}
if $regex(%dtr,/1.</td><td valign="top">(.+?)</td>/i) {
%dt.method $regsubex($regml(1),/<(.+?)>/g,$null)
scon -at1 %a
}
}
}
dialog dict {
title "Dictionary look up"
size -1 -1 230 88
option pixels
edit "", 1, 7 9 148 20, autohs
button "Define", 2, 158 6 65 25
edit "", 3, 7 31 218 54, read autovs multi vsbar
}
on *:dialog:dict:sclick:2:{
var %a = did -ra $dname 3
if !$did(dict,1).text { %a Enter a word to define! }
else {
set %dt.method %a
sockopen dt dictionary.reference.com 80
set %dt.current $did(dict,1).text
}
}