/* $VER: Online Dictionary and Thesaurus 2.5 (12.11.00) This script uses the Merriam-Webster site . www.m-w.com requires AWNP 2.52+ */ if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then exit(20) if show('P','DICTTHESAR') then do address DICTTHESAR 'front' exit end rxPort = address() if abbrev(rxPort,'AWEB.') then do 'get screen var screen' screen=' ps 'screen' ' end else screen='' nl='a'x delaybub=0 call setdefaults() call buildgui() do while ~eof(ca) call checkrx() if delaybub>0 then do delaybub=delaybub-1 if delaybub=0 then do bubbleon=newbub call topipe('bubble top 'bubx 'left 'buby 'gt "'help.newbub'"') end end call topipe('tick 50') in= readln(ca) parse var in in1 in2 in3 in4 in5 . if (in1='help' & helpon~=0 ) then do call bubble(in2) end if in1='active' then call bubble(0) if in1='key' then call key() if in1='gadget' then call gadget() if in1='iconify' then call iconify(in2) if in1='menu' then call menu() if in1='close' then call windowclosed() if in1='arexx' then call rxhst() end exit key: scrpos=topipe('id 'txtgad) if (in2=77) then do do i=0 for pcnt if poslist.i>scrpos then break end if i=pcnt then i=i-1 call topipe('id 'txtgad' scroll -1') call topipe('id 'txtgad' scroll' poslist.i) end if (in2=76) then do do i=0 for pcnt if scrpos<=poslist.i then break end if i>0 then i=i-1 call topipe('id 'txtgad' scroll' poslist.i) end return gadget: call bubble(0) if in2=wordgad then do parse var in . . w logon=1 call getword(w) end if in2=quitgad then exit if in2=levelgad then level=in3 if in2=bookgad then book=in3 if in2=cleargad then call clearlog() if in2=savegad then do call writeln(ca,'id 'filegad' s 1 save 1 fn "'filename'"') parse value readln(ca) with res1 '"' res2 '"' if (res1>0) then do filename=res2 call writeln(ca,'id 'txtgad' read') len=readln(ca) data=readch(ca,len) if( open(out,res2,'W')) then do call writech(out,data) call close(out) end end end return windowclosed: exit return setdefaults: parse source . . called . logging=1 oldpos=0 poslist.0=0 pcnt=1 level=0 book=0 filename='' scrpos='' prono='' theno='' envname='onlinedictionary' call getenv() abouttx=' Online Dictionary & Thesaurus *nVers 2.5 *nArexx Host DICTTHESAR*nAuthor William Parker*nGUI by AWNPipe:' return buildgui: call open(ca,"awnpipe:dict/-2052/xc") call topipe(screen 'it "Dict Thesa" "Online Dictionary & Thesaurus" sk v defg ig h state m a 'window' ii "'called'"' ) lay1=topipe(' layout weih 0') call topipe(' label gt "_Word: " ua') wordgad=topipe('string chl lj') help.wordgad=' Enter word to look up ' levelgad=topipe('chooser cl "First|Major|All" pu weiw 0') help.levelgad='Select look up depth*n First Entry*n Major Entries*n All Entries' bookgad=topipe('chooser cl "Dictionary|Thesaurus" pu weiw 0') help.Bookgad='Select book to search in*n Dictionary definition*n Thesaurus information' call topipe(' le') txtgad=topipe('textfield ro arrows') help.txtgad=' This area displays the retrieved definitions. It is read only *n but you may drag and copy the results to the clipboard. *n The cursor keys can be used to scroll the information.' lay2=topipe(' layout weih 0') abortgad=topipe('button pb gt "_Abort" dis 1') help.abortgad=' Abort multiple retrieval*navailable for major and all*noptions' savegad=topipe('button gt "_Save Log"') help.savegad=' Save retrieved definitions to a file ' cleargad=topipe('button gt "_Clear Log"') help.cleargad=' Remove all retrieved definitions ' quitgad=topipe('button gt "_Quit"') help.quitgad=' Quit the dictionary ' call topipe(' layoutend') filegad=topipe('getfile save ua') men0gad= topipe('Menu gt "Project|Window|$@SSnapshot|$@UUnsnapshot|@AAbout|@H^&Bubble Help|-|@QQuit"') call pragma('W','N') if (showlist('A','MIAMI')|(showlist('P','MIAMI.1'))) then do men1gad= topipe('Menu gt "Miami|Online|Offline|Status|Hide GUI|Show GUI|-|Quit Miami"') miamifound=1 end call pragma('W') call topipe("open") call open(rxfh,'awnpipe:rx/xc') call rxpipe('nowindow m') call rxpipe('ARexx gt "DICTTHESAR|front|quit|word|save|clear|book|level|iconify|logging"') call rxpipe("open") return topipe: parse arg out call writeln(ca,out) res=readln(ca) parse var res res1 res2 res3 if res1='ok' then return(res2) say 'error from: 'out say ' responce: ' in exit rxpipe: parse arg out call writeln(rxfh,out) res=readln(rxfh) parse var res res1 res2 res3 if res1='ok' then return(res2) say 'error from: 'out say ' responce: ' in exit trans: if testtcp() then return savetx='0a'x||'---------------'||'0a'x newword=w call topipe('id 0 s 8 gt " Connecting for *"'newword'*""') savew=w w=urlencode(w) if book=0 then t1='book=Dictionary&va='w else t1='book=Thesaurus&va='w t2=length(t1) t2='Content-Length: 't2 if open(net,'tcp:www.m-w.com/80') then do call topipe('id 0 s 8 gt " Getting information for *"'newword'*""') call writeln(net,"POST /cgi-bin/dictionary HTTP/1.0") call writeln(net,"User-Agent: MSIE/4.0; (Spoofed by AWNPdictthing (2.5))") call writeln(net,"Accept: */*;q=1") call writeln(net,"Host: www.m-w.com") call writeln(net,t2) call writeln(net,"Content-Type: application/x-www-form-urlencoded") call writeln(net,"") call writeln(net,t1) call writeln(net,"") def='' do while ~eof(net) if length(def)< 54000 then def=def||readch(net,10000) end call close(net) savedef=def call getdef() end else do savetx=savetx||'0a'x||'Connect Failed for 'newword||'0a'x call Showtx(0,"Could not connect to m-w.com") end return(0) getdef: call topipe('id 0 s 8 gt " Parsing result for *"'newword'*""') if book=0 then parse var def 'Main Entry:' thisword '0a'x d1 '' else parse var def 'Entry Word:' thisword '0a'x d1 '' thisword=htmltotx(thisword) txt=htmltotx(d1) if txt='' then txt= 'not found' if book=0 then savetx=savetx||'0a'x||' (dict) >>>> 'newword' <<<<'||'0a0a'x||' Entry: '||thisword||txt||'0a0a'x else savetx=savetx||'0a'x||' (thes) >>>> 'newword' <<<<'||'0a0a'x||' Entry: '||thisword||txt||'0a'x if savedef~='' then call extradef() call topipe('id 0 s 8 gt " Online Dictionary & Thesaurus"') return showtx: call open(ptx,'awnpipe:kctxt/xc') call writeln(ptx,screen 'db dg "D&T info" q cm v m a ') call writeln(ptx,'layout defn 2 weiw 10 si fpat="5555aaaa" cj v b 0'nl'space trans minh 2'nl'laYOUT DEFN 2 fpat="5555aaaa" cj b 0'nl'space trans minw 5'nl'layout weih 0 weiw 0 so'nl'label gt " *n'arg(2)'*n "') call writeln(ptx,'le'nl'space trans minw 5'nl'le'nl'button gt " OK " c weiw 0'nl'le'nl'open'nl) if arg(1)~=0 then call writeln(ptx,'tick 'arg(1)) else call writeln(ptx,'m') call close(ptx) return(0) menu: if in2=1 then do if ~show('P','MIAMI.1') then do if in3=1 | in3=1 | in3=6 then do call showtx(200,' Miami is not running ') return() end address command 'Run >NIL: Miami:Miami ' do 5 while ~show('P','MIAMI.1') address command 'waitforport MIAMI.1' end if rc=5 then return() end if in3=1 then address MIAMI.1 'OFFLINE' if in3=6 then address MIAMI.1 'QUIT' if in3=0 then address MIAMI.1 'ONLINE' if in3=3 then address MIAMI.1 'HIDE' if in3=4 then address MIAMI.1 'SHOW' if in3=2 | in3=0 | in3=1 then do address MIAMI.1 'ISONLINE' if rc then call showtx(400,' Miami is online ') else call showtx(400,' Miami is offline ') end end if in2=0 then do if in3=0 then do if in4=0 then call setenvarc() if in4=1 then call unsetenvarc() end if in3=1 then call showtx(800,abouttx) if in3=2 then do helpon=in5 if helpon=0 then call bubble(0) end if in3=4 then exit end return() iconify: if arg(1)=1 then call topipe('id 0 s 32') else call topipe('id 0 s 64') call bubble(0) return getenv: if(open(env,'env:'envname,'R')) then do windows=readln(env) filename=readln(env) call close(env) parse var windows wl wt ww wh . window= 'top' wt 'left' wl 'width' ww 'height' wh end else window='tl width 400 height 200' return setenv: call writeln(ca,'id 0 read') windowr=readln(ca) parse var windowr wl wt ww wh . if (datatype(wt,N) &datatype(wl,N) &datatype(ww,N) & datatype(wh,N) ) then do call open(env,'env:'envname,'W') call writeln(env,windowr) call writeln(env,filename) call close(env) end return(0) setenvarc: call setenv() address command 'copy env:'envname' envarc:'envname '>nil:' return unsetenvarc: call setenv() if exists('envarc:'envname) then delete('envarc:'envname) if exists('env:'envname) then delete('env:'envname) return testtcp: call pragma('W','N') if ~showlist(H,'TCP') then do if miamifound=1 then call showtx(0,'You must be on line to use*n the dictionary or thesauris.*n *nYou can start Miami from the menus.') else call showtx(0,'Can not find TCP device*n *nYou must be on line to use*n the dictionary or thesauris.') savetx='' call pragma('W') return(1) end call pragma('W') if (showlist('P','MIAMI.1')) then do address MIAMI.1 'ISONLINE' if ~rc then do call showtx(0,'Miami is not on line*n *nYou must be on line to use *n the dictionary or thesauris.*n *nYou can start Mimai from the menus.') savetx='' return(1) end return(0) end if (showlist('P','AMITCP')) then do /*hmmm*/ end return(0) bubble: newbub=arg(1) if newbub=-1 then newbub=0 if (bubbleon=newbub) then return() if bubbleon~=0 then call topipe('bubble') if newbub=0 then delaybub=0 else do bubx=in3 buby=in4 delaybub=3 end return extradef: parse var savedef '