tglogo.png

Downloading File

Filename: Thesaurus
dialog thesaurus {
  title "Thesaurus"
  size -1 -1 137 176
  option dbu
  text "Thesaurus", 1, 57 5 25 8
  edit "", 2, 7 27 54 10
  button "Look Up", 3, 76 27 53 10, default
  box "Synonyms", 4, 4 45 60 111
  button "Close", 6, 51 162 35 9, ok cancel
  list 7, 7 53 54 100, size hsbar vsbar
  box "Antonyms", 5, 73 45 60 111
  list 8, 76 53 54 100, size hsbar vsbar
  box "Word", 9, 4 19 60 21
}

alias thesaurus dialog $iif($dialog(thesaurus),-v,-m) thesaurus thesaurus

alias htmlfree return $regsubex($1-,/^[^<]*>|<[^>]*>|<[^>]*|$|&[^;]+;/g,$null) 

menu * {
  Thesaurus: thesaurus
}

on *:dialog:thesaurus:*:*:{
  if ($devent == sclick && $did = 3) {
    if ($did(2).text) {
      if ($sock(thesaurus)) sockclose $v1
      sockopen thesaurus thesaurus.reference.com 80
      sockmark thesaurus $did($dname,2).text
      did -r $dname 7-8
    }
    else noop $input(You must enter a word!,oh,Error!)
  }
}

on *:sockopen:thesaurus:{
  if ($sockerr) {
    echo -a Socket error: $sock($sockname).wsmsg
    sockclose $sockname
    halt
  }
  sockwrite -nt $sockname GET /browse/ $+ $sock($sockname).mark HTTP/1.1
  sockwrite -nt $sockname Host: thesaurus.reference.com
  sockwrite -nt $sockname $crlf
}

on *:sockread:thesaurus:{
  var %x
  sockread %x
  if (<div class="anotherword"> isin %x) {
    did -a thesaurus 7,8 No results found
    sockclose $sockname
    unset %antonyms
  }
  if ($regex(%x,/<a class="theColor" href=".+">(.+)/i)) didtok thesaurus $iif(%antonyms,8,7) 44 $remove($htmlfree($regml(1)),$chr(32))
  if (<td valign="top"><b>Antonyms:</b></td> isin %x) {
    set %antonyms 1
    sockread %x
    sockread %x
    sockread %x
    didtok thesaurus 8 44 $remove($htmlfree(%x),$chr(32))
  }
  if (</table> isin %x) {
    sockclose $sockname
    did -z thesaurus 7,8
    unset %antonyms
  }
}

Related Files

by FordLawnmower
by Zmodem

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand