All pastes #519091 Raw Edit

Mine

public text v1 · immutable
#519091 ·published 2007-05-29 15:14 UTC
rendered paste body
Menu * {
  book:/dialog -lm book book
}
Dialog book {
  Title "Book searcher and saver"
  size -1 -2 200 200
  option dbu
  tab "Search saved", 6, 1 1 200 200
  tab "Search for book", 7, 1 1 200 200
  button "Search", 1, 140 170 60 10, tab 7
  button "Save", 2, 1 170 60 10, tab 7
  button "Clear", 10, 70 190 60 10, tab 7
  button "Clear", 22, 70 190 60 10, tab 6
  button "Close", 11, 70 170 60 10, ok
  edit "Search in here", 3, 5 20 190 70, tab 7
  edit "", 4, 5 100 190 70, tab 7 multi autohs autovs hsbar vsbar 
  text "Book finder and saver by Fwoggy", 5, 100 1 100 7
  edit "", 8, 5 100 190 70,  tab 6 multi autohs autovs hsbar vsbar 
  button "List books stored", 9, 140 170 60 10, tab 6
  edit "Search for book stored", 12, 1 50 100 10, tab 6 
  button "Search", 13, 105 50 60 10, tab 6
  button "Clear saved", 21, 1 170 60 10, tab 6

}
on *:Dialog:book:sclick:1: {
  set %book $replace($did($dname,3),$chr(32),+,_,+)
  sockopen books www.waterstones.com 80
}
on *:sockopen:books:{
  sockwrite -nt $sockname GET /waterstonesweb/simpleSearch.do?simpleSearchString= $+ %book $+ &searchType=0&Image1.x=13&Image1.y=9 Http/1.1
  sockwrite -nt $sockname Host: www.waterstones.com
  sockwrite -nt $sockname $crlf 
}
on *:sockread:books:{
  var %booklu
  sockread %booklu
  if (*<h2><a href="http://www.waterstones.com/waterstonesweb/displayProductDetails.do?sku=*">*</a> by <a href="javascript:doAuthorSearch* iswm %booklu) {
    inc %l
    set %book $htmlfree($remove(%booklu,$chr(9),et al,$chr(44)))
    /did -i book 4 %l %book
  }
  unset %l
  unset %book
}
on *:Dialog:book:sclick:2: {
  var %l 1 
  while (%l <= $did(4).lines) { 
    write books.txt $did(4,%l).text 
    inc %l 
  }
  did -r book 4 
  did -a book 4 Book infomation saved into books.txt.
}
on *:Dialog:book:sclick:10: {
  did -r book 4 
}
on *:Dialog:book:sclick:13: {
  if ($read(books.txt,w,$+(*,$did($dname,12),*)*)) {  
    /did -a book 8 $read(books.txt,w,$+(*,$did($dname,12),*)*)
  }
}
on *:dialog:book:sclick:9: {
  var %c 1 
  while ($read(books.txt,%c)) { 
    did -i book 8 %c $v1 
    inc %c 
  }
}
on *:dialog:book:sclick:9: {
  did -r book 8 
}
on *:dialog:book:sclick:21: {
  write -c books.txt
  did -r books.txt 8
  did -i books.txt 8 Files saved deleted.
}
on *:Dialog:book:sclick:22: {
  did -r book 8 
}