All pastes #905265 Raw Edit

Stuff

public text v1 · immutable
·published 2008-02-15 17:48 UTC
rendered paste body
dialog Price {
  title "Price"
  size -1 -1 178 110
  option dbu
  text "Item:", 3, 8 11 34 8, center
  list 2, 3 44 171 62, size vsbar
  box "", 4, 1 38 176 71
  box "Price", 1, 1 1 176 41
  edit "", 5, 41 10 125 10
  button "Look up", 7, 29 31 107 9, flat
  check "F2P only?", 6, 48 20 35 10
  text "(Default is P2P)", 8, 87 21 42 8, center
}
on *:DIALOG:Price:sclick:7:{
  if (!$did(5)) {
    dialog -m NoItem NoItem
  }
  else {
    did -r Price 2
    var %s $ticks
    sockopen Price. $+ %s www.zybez.net 80
    sockmark Price. $+ %s $+(item,~,$did(Price,5))
  }
}
on *:SOCKOPEN:Price.*:{
  var %item $gettok($sock($sockname).mark,2,126)
  sockwrite -n $sockname GET $+(/priceguide.php?search_terms=,%item,&search_area=1&price_low=&price_high=&member=,$iif(!$did(Price,6).state,1,0)) HTTP/1.1
  sockwrite -n $sockname Host: www.zybez.net
  sockwrite -n $sockname $crlf
}
on *:SOCKREAD:Price.*:{
  if ($sockerr) { dialog -m SockErr SockErr | halt }
  else {
    var %hi
    sockread %hi
    if (*Your search did not return any results* iswm %hi) {
      did -ra Price 2 No results found for $+(",$gettok($sock($sockname).mark,2,126),") $+ . $+ $ctrlf
      did -a Price 2 You might have mispelled the item name or it might be P2P.
      sockclose $sockname
      halt
    }
    else {
      if (*<td><a href="/items.php?search_area=name&amp;search_term=* iswm %hi) {
        sockread %hi
        var %name = $remove(%hi,<td>,</td>,$chr(9))
        sockread %hi
        var %price = $bytes($remove(%hi,</td>,<td>,$chr(9),<td title="Previously:,[&uarr; by 1,000gp]"><img src="/img/market/p_u.gif" alt="Price has &uarr;" />,$chr(44)),db)
        did -a Price 2 $+($calc($did(Price,2).lines + 1),.) $+(%name,$chr(32),%price,gp)
      }
    }
  }
}
on *:SOCKCLOSE:Price.*:{
  sockclose $sockname 
}
dialog NoItem {
  title "Price"
  size -1 -1 67 47
  option dbu
  text "- Error -", 1, 21 6 19 8, center
  box "", 2, 1 -1 65 46
  text "No Item Specified.", 3, 5 20 54 8, center
  button "Cancel", 4, 13 32 37 8, cancel
}
dialog SockErr {
  title "Socket Error"
  size -1 -1 67 47
  option dbu
  text "- Error -", 1, 19 8 27 8, center
  text "Socket error, try again", 2, 3 19 60 8, center
  button "Cancel", 3, 15 33 37 10, cancel
}