:dictionary
:module
:help.m

@ dict.serv = [dict.org]
@ dict.port = 2628
eval addhelp dict&dict $(c4)[$(c3)word$(c4)]&defines the specified word.
alias dict {
	if (![$0]) {
		/chelp dict
	}	
	{
		^exec -9 %dict
		@ dword = [$*]
		^exec -name dict telnet $dict.serv $dict.port
		^on ^exec "dict *" { xecho -c $fparse(format_midbar $strip({} $1-)) }
		^on ^exec "dict Trying *" #
		^on ^exec "dict *Trying *" #
		^on ^exec "dict Connected to *" #
		^on ^exec "dict *Connected to *" #
		^on ^exec "dict Escape character is '^]'." { 
			^exec -in %dict DEFINE * $dword 
		}
		^on ^exec "dict *definitions retrieve*" { xecho -c $fparse(format_header dict $dword) }
		^on ^exec "dict *220*" #
		^on ^exec "dict *250*" { 
			xecho -c $fparse(format_footer dict $dword)
			^exec -9 %dict
		}
		^on ^exec "dict *150*" #
		^on ^exec "dict *151*" #
		^on ^exec "dict ?" { 
			xecho -c $fparse(format_footer dict $dword)
			^exec -9 %dict 
		}
		^on ^exec "dict ?DEFINITION 0" { 
			^exec -9 %dict 
			xecho -c $fparse(format_footer dict $dword)
		}
		^on ^exec "dict *552 no match*" { 
			xecho -c $fparse(format_header dict $dword)
			xecho -c $fparse(format_midbar no match for $dword)
                        xecho -c $fparse(format_footer dict $dword)
			^exec -9 %dict 
		}
		^on ^exec "dict SPELLING 0"{
			xecho -c $fparse(format_header dict $dword)
			xecho -c $fparse(format_midbar $dword$(c4):$(cl) No suggestions given.)
			xecho -c $fparse(format_footer dict $dword)
			^exec -9 %dict 
		}
		^on ^exec "*connection closed by foreign host*" {
			echo $fparse(format_footer dict $dword)
		}
	}
        ^restub dict dict.m
}	