home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER:English/German-Translator 1.5▀ (21.03.99) C.Birchinger (Joker)
- License: GPL (so people stop ask me if they can use this code)
- */
-
- maxhits=5 /* Default max.hits */
- boldtxt=1 /* Use bold */
-
- /* --------------------------------------------------------------*/
-
- parse arg argument
- revarg=reverse(argument)
- parse var revarg hits word
- hits=reverse(hits);word=reverse(word)
- if datatype(hits)~='NUM' then do
- word=word||hits
- hits=maxhits
- end
-
- if word='' then do
- "echo P="d2c(27)"b½e/g╗ Usage: trans <words> [<max.hits>]"
- exit
- end
- else hits=strip(hits);word=strip(word)
- findword=translate(word,'+',' ')
-
- "echo P="d2c(27)"b½e/g╗ Translating '"||d2c(2)||word||d2c(2)||"' (Max."hits")"
- if open(x,'tcp:131.159.72.13/80') then do
- writeln(x,'GET /?search='findword)
- do until index(line,"search result")>0
- line=readln(x)
- if eof(x) then do
- "echo P="d2c(27)"b½e/g╗ Search for '"||d2c(2)||word||d2c(2)||"' produced no results."
- exit
- end
- end
- parse var line '<STRONG>'foundhits dummy
- if foundhits=1 then "echo P="d2c(27)"b½e/g╗ "foundhits" search result for '"||d2c(2)||word||d2c(2)||"'"
- else "echo P="d2c(27)"b½e/g╗ "foundhits" search results for '"||d2c(2)||word||d2c(2)||"'"
- line=readln(x);line=readln(x)
- if foundhits>hits then do
- foundhits=hits
- end
- do i=1 to foundhits
- line=strip(readln(x))
- call htmlout(line)
- end
- call close(x)
- end
- else
- "echo P="d2c(27)"b½e/g╗ Error: 'http://www.leo.org/cgi-bin/dict/dict-search.pl' is down or TCP: not mounted."
- exit
- end
- exit
-
- htmlout:
- output=arg(1)
-
- parse var output dummy 'VALIGN=\"TOP\">' lines '</TD><TD VALIGN=\"TOP\">' linee
- output=lines||'-'||linee
- do until (index(output,'<B>')=0)
- cut=index(output,'<B>')
- if cut~=0 then output=insert(d2c(2),delstr(output,cut,3),cut-1,1)
- cut=index(output,'</B>')
- if cut~=0 then output=insert(d2c(2),delstr(output,cut,4),cut-1,1)
- end
-
- if boldtxt=0 then 'echo P='d2c(27)'b½e/g╗' compress(output,d2c(2))
- else 'echo P='d2c(27)'b½e/g╗' output
-
- return
-