Public feed #890593

hey sexy

public text v1 · immutable
Raw Edit
·published 2008-02-03 21:35 UTC
rendered paste body
alias rstool {
  $_d(-m,300,150,471,382,rstool,1)
}
dialog rstool {
  title "RuneScape Kit"
  size -1 -1 471 382
  option pixels
  tab "Stats", 25, -1 -1 584 399
  tab "Clan/Calculator", 26
  tab "Price Lookup", 27
  tab "Combat Calculator", 58
  tab "Compare", 99
  edit "name.", 1, 63 52 100 20, tab 25 autohs autovs
  button "Lookup", 2, 122 315 205 25, tab 25 flat
  edit "n/a", 15, 241 50 45 20, tab 25
  edit "n/a", 24, 120 239 30 20, tab 25
  text "Attack", 28, 36 90 38 17, tab 25
  text "Strength", 29, 36 115 54 17, tab 25
  text "Defense", 30, 36 140 47 17, tab 25
  text "Range", 31, 36 165 38 17, tab 25
  text "Prayer", 32, 36 190 39 17, tab 25
  text "Magic", 33, 36 215 34 17, tab 25
  text "Runecrafting", 34, 36 240 68 17, tab 25
  text "Construction", 35, 36 265 71 17, tab 25
  text "Hitpoints", 36, 186 90 52 17, tab 25
  text "Agility", 37, 185 115 38 17, tab 25
  text "herblore", 38, 186 140 46 17, tab 25
  text "Thieving", 39, 186 165 52 17, tab 25
  text "Crafting", 40, 186 190 51 17, tab 25
  text "Fletching", 41, 186 216 49 17, tab 25
  text "Slayer", 42, 186 240 36 17, tab 25
  text "Hunter", 43, 186 265 41 17, tab 25
  text "Mining", 44, 311 90 42 17, tab 25
  text "Smithing", 45, 311 115 50 17, tab 25
  text "Fishing", 46, 311 140 44 17, tab 25
  text "cooking", 47, 311 165 44 17, tab 25
  text "Firemaking", 48, 311 190 59 17, tab 25
  text "Woodcutting", 49, 311 215 69 17, tab 25
  text "Farming", 50, 311 240 52 17, tab 25
  text "Summoning", 51, 311 265 64 17, tab 25
  edit "n/a", 52, 121 89 30 20, tab 25
  edit "n/a", 53, 121 114 30 20, tab 25
  edit "n/a", 54, 121 164 30 20, tab 25
  edit "n/a", 55, 121 139 30 20, tab 25
  edit "n/a", 56, 121 214 30 20, tab 25
  edit "n/a", 57, 121 189 30 20, tab 25
  edit "n/a", 5, 120 263 30 20, tab 25
  text "Overall", 3, 187 52 46 17, tab 25
  edit "n/a", 4, 254 237 30 20, tab 25
  edit "n/a", 6, 255 87 30 20, tab 25
  edit "n/a", 7, 255 112 30 20, tab 25
  edit "n/a", 8, 255 162 30 20, tab 25
  edit "n/a", 9, 255 137 30 20, tab 25
  edit "n/a", 10, 255 212 30 20, tab 25
  edit "n/a", 11, 255 187 30 20, tab 25
  edit "n/a", 12, 254 261 30 20, tab 25
  edit "n/a", 13, 395 237 30 20, tab 25
  edit "n/a", 14, 396 87 30 20, tab 25
  edit "n/a", 16, 396 112 30 20, tab 25
  edit "n/a", 17, 396 162 30 20, tab 25
  edit "n/a", 18, 396 137 30 20, tab 25
  edit "n/a", 19, 396 212 30 20, tab 25
  edit "n/a", 20, 396 187 30 20, tab 25
  edit "n/a", 21, 395 261 30 20, tab 25
  box "", 22, 24 75 418 218, tab 25
  box "", 23, 57 38 235 38, tab 25
  edit "User Name", 61, 20 38 100 20, tab 26 autohs autovs
  list 60, 61 76 338 104, tab 26 hsbar vsbar
  text "User Lookup", 62, 177 34 100 17, tab 26
  text "Calculator", 63, 175 232 100 17, tab 26
  edit "Calculations", 64, 117 258 184 20, tab 26 autohs autovs
  button "=", 65, 175 285 65 20, tab 26
  edit "Answer", 66, 56 315 340 20, tab 26 autohs autovs
  box "", 67, 10 221 445 142, tab 26
  box "", 68, 10 20 445 199, tab 26
  list 69, 61 184 335 136, tab 27 hsbar vsbar
  text "Price Lookup", 70, 190 44 62 17, tab 27
  edit "Item", 71, 120 79 110 20, tab 27 autohs autovs
  edit "Qty", 72, 253 79 68 20, tab 27 autohs autovs
  button "Lookup", 59, 108 184 203 20, tab 26
  button "Lookup", 73, 109 137 221 25, tab 27
  box "", 74, 22 30 424 310, tab 27
  text "Information", 75, 195 50 68 17, tab 58
  text "Attack:", 76, 60 90 38 17, tab 58
  edit "1", 77, 122 89 26 20, tab 58
  text "Strength:", 78, 50 107 51 17, tab 58
  edit "1", 79, 122 107 26 20, tab 58
  edit "1", 80, 122 125 26 20, tab 58
  edit "1", 81, 122 143 26 20, tab 58
  text "Defense:", 82, 52 127 47 17, tab 58
  text "Hit Points:", 83, 48 144 55 17, tab 58
  text "Ranged:", 84, 175 91 47 17, tab 58
  text "Prayer:", 85, 177 109 41 17, tab 58
  text "Magic:", 86, 182 125 39 17, tab 58
  text "Summoning:", 87, 158 144 61 17, tab 58
  edit "1", 88, 250 89 26 20, tab 58
  edit "1", 89, 250 107 26 20, tab 58
  edit "1", 90, 250 125 26 20, tab 58
  edit "1", 91, 250 143 26 20, tab 58
  text "Results", 92, 340 46 42 17, tab 58
  text "Combat:", 93, 305 90 47 17, tab 58
  text "Based:", 94, 306 117 43 17, tab 58
  edit "1", 95, 368 90 68 20, tab 58
  edit "", 96, 368 117 68 20, tab 58
  box "", 97, 19 30 438 205, tab 58
  button "Calculate", 98, 174 184 111 25, tab 58
  text "Compare", 100, 195 38 100 17, tab 99
  edit "User 1.", 101, 47 80 100 20, tab 99
  edit "User 2.", 102, 177 80 100 20, tab 99
  combo 103, 312 81 100 62, tab 99 drop
  button "Compare", 104, 193 124 65 25, tab 99
  list 105, 39 200 390 109, tab 99 hsbar vsbar
  button "Clear", 106, 187 321 65 25, tab 99
  box "", 107, 15 25 445 345, tab 99
}
on *:DIALOG:rstool:sclick:104:{
  sockclose compare
  Set %name1 $replace($did(101),$chr(32),+)
  Set %name2 $replace($did(102),$chr(32),+)
  Set %c.skill $replace($did(103),$chr(32),+)
  sockopen compare parsers.stirk.org 80
}
on *:DIALOG:rstool:sclick:106:{
  did -r rstool 105
}

ON *:SOCKOPEN:compare: {
  sockwrite -nt $sockname GET /compare.php?user1= $+ %name1 $+ &user2= $+ %name2 $+ &skill= $+ %c.skill HTTP/1.1
  sockwrite -nt $sockname Host: parsers.stirk.org
  sockwrite -nt $sockname $crlf
}

ON *:SOCKREAD:compare: {
  if (!$sockerr) {
    var %sockreader
    sockread %sockreader
    if (<br> isin %sockreader) {
      tokenize 58 %sockreader
      did -a rstool 105 User Name = $1 %c.skill $+ : $2 Rank: $3 Exp: $remove($4,<br>)
    }
  }
}

on *:DIALOG:rstool:sclick:65:{
  var %x $replacex($did(64),k,000,m,000000,g,000,b,000000000,t,000000000000)
  did -ra rstool 66 = $bytes($calc(%x),bd)
}

on *:DIALOG:rstool:sclick:2:{
  if ($did($dname,1)) {
    var %a 52
    while %a < 58 {
      did -ra rstool %a n/a
      inc %a
    }
    var %a 5
    while %a < 22 {
      did -ra rstool %a n/a
      inc %a
    }
    did -ra rstool 24 n/a
    sockclose stats
    Set %name $replace($did(1),$chr(32),+)
    sockopen stats www.cameron.gvjordan.com  80
  }
}
ON *:SOCKOPEN:stats: {
  sockwrite -nt $sockname GET /ht1d.php?rsn= $+ %name HTTP/1.1
  sockwrite -nt $sockname Host: cameron.gvjordan.com
  sockwrite -nt $sockname $crlf
}
ON *:SOCKREAD:stats: {
  if (!$sockerr) {
    var %sockreader
    sockread %sockreader
    tokenize 32 %sockreader
    if ($1 isnum) did -ar rstool $1 $2
    unset %name
  }
}

on *:DIALOG:rstool:sclick:73:{
  sockclose price
  Set %item $replace($did(71),$chr(32),+)
  set %amount $replace($did(72),$chr(32),+)
  sockopen price www.nou.stirk.org 80
}

ON *:SOCKOPEN:price: {
  sockwrite -nt $sockname GET /parsers/price.php?item= $+ %item $+ &results=100&amount= $+ %amount HTTP/1.1
  sockwrite -nt $sockname Host: nou.stirk.org
  sockwrite -nt $sockname $crlf
}

ON *:SOCKREAD:price: {
  if (!$sockerr) {
    var %sockreader
    sockread %sockreader
    if (<br> isin %sockreader) {
      tokenize 58 %sockreader
      did -a rstool 69 $remove($1-,<br>)
      unset %item
      unset %amount
    }
  }
}


on *:DIALOG:rstool:sclick:98:{
  Var %Def $calc($did(80) * 100)
  Var %Hits $calc($did(81) * 100)
  Var %Pray $calc($did(89) * 50)
  var %summon $calc($did(91) * 50)
  Var %hit.def.pray.summon $calc((%Def + %hits + %Pray + %summon) / 400)
  Var %Att $calc($did(77) * 130)
  Var %str $calc($did(79) * 130)
  if (!$and($did(88),1)) { Var %range $calc((($did(88) - 1) + ($did(88) * 2)) * 65) }
  Else var %Range $calc($did(88) * 195)
  if (!$and($did(90),1)) { Var %mage $calc((($did(90) - 1) + ($did(90) * 2)) * 65) }
  Else var %Mage $calc($did(90) * 195)
  Var %Melee $calc((%att + %str) /400), %Ranger $calc(%range / 400), %mager $calc(%mage / 400)
  If (%ranger > %melee) && (%ranger > %Mager) { did -ar rstool 95 $calc(%hit.def.pray.summon + %ranger) | did -ar rstool 96 Range }
  elseIf (%mager > %melee) && (%mager > %ranger) { did -ar rstool 95 $calc(%hit.def.pray.summon + %mager) | did -ar rstool 96 mage }
  elseIf (%Melee > %mager) && (%melee > %ranger) { did -ar rstool 95 $calc(%Hit.def.pray.summon + %melee) | did -ar rstool 96 Melee }
}




on *:DIALOG:rstool:sclick:59:{
  sockclose clan
  Set %name $replace($did(61),$chr(32),+)
  sockopen clan www.nou.stirk.org 80
}

ON *:SOCKOPEN:clan: {
  sockwrite -nt $sockname GET /parsers/clan.php?user= $+ %name HTTP/1.1
  sockwrite -nt $sockname Host: nou.stirk.org
  sockwrite -nt $sockname $crlf
}

ON *:SOCKREAD:clan: {
  if (!$sockerr) {
    var %sockreader
    sockread %sockreader
    if (<br> isin %sockreader) {
      tokenize 124 %sockreader
      did -a rstool 60 $remove($1-,<br>)
      unset %item
      unset %amount
    }
  }
}


on *:DIALOG:rstool:INIT:0:{
  did -a rstool 103 Overall
  did -a rstool 103 Attack
  did -a rstool 103 Strength
  did -a rstool 103 Defense
  did -a rstool 103 Hitpoints
  did -a rstool 103 Prayer
  did -a rstool 103 Ranged
  did -a rstool 103 Magic
  did -a rstool 103 Summoning
  did -a rstool 103 Runecrafting
  did -a rstool 103 Construction
  did -a rstool 103 Farming
  did -a rstool 103 Herblore
  did -a rstool 103 Hunter
  did -a rstool 103 Thieving
  did -a rstool 103 Agility
  did -a rstool 103 Fishing
  did -a rstool 103 Cooking
  did -a rstool 103 Woodcutting
  did -a rstool 103 Firemaking
  did -a rstool 103 Slayer
  did -a rstool 103 Crafting
  did -a rstool 103 Fletching
  did -a rstool 103 Smithing
  did -a rstool 103 Mining
}

alias _d {
  if ($7 = 1) {
    dialog $1 $6 $6
    var %x = 1 , %y = 350
    while (%x <= %y) { dialog -s $6 $2 $3 $round($calc( $4 / %y * %x )) $round($calc( $5 / %y * %x )) | inc %x }
  }
  if ($7 = 2) {
    dialog $1 $6 $6
    var %x = 1 , %y = 500
    while (%x <= %y) { dialog -s $6 $2 $3 $round($calc( $4 / %y * %x )) $5 | inc %x }
  }
  if ($7 = 3) {
    dialog $1 $6 $6
    var %x = 1 , %y = 500
    while (%x <= %y) { dialog -s $6 $2 $3 $4 $round($calc( $5 / %y * %x )) | inc %x }
  } 
}
To: menu * {
  Price Lookup:/dialog -md price price
}
dialog price {
  title "Price Lookup"
  size -1 -1 181 109
  option dbu
  edit "", 1, 3 3 106 10
  button "Lookup", 2, 8 15 26 12
  button "Clear", 3, 35 15 26 12
  list 4, 0 39 181 70, size hsbar vsbar multsel
  text "Price Lookup by Xxhaloxx4", 5, 3 30 177 8
  button "C Lines", 6, 62 15 26 12
  button "Save", 7, 92 15 26 12
  button "View", 8, 119 15 26 12
  button "^", 9, 150 15 9 12
  button "v", 10, 160 15 9 12
  menu "File", 32
  item "On Top", 33, 32
  item break, 34, 32
  item "Exit", 35, 32
  menu "Clear", 11
  item "Clear All", 12, 11
  item "Clear Selected", 13, 11
  menu "Save", 14
  item "Save All", 15, 14
  item "Save Selected", 16, 14
  item break, 17, 14
  item "View Saves", 18, 14
  menu "Options", 19
  menu "Result Display", 20, 19
  item "Edit", 21, 20
  item "Use Default", 22, 20
  item "Compare Prices", 28, 19
  menu "Other", 23
  item "Lookup", 24, 23
  item break, 25, 23
  item "Move Up", 26, 23
  item "Move Down", 27, 23
  item break, 40, 23
  menu "Add Separator", 37, 23
  item "Line Above", 38, 37
  item "Line Below", 39, 37
  menu "About", 31
  item "View About", 36, 31
}
on *:DIALOG:price:init:*:{
  did -t price 2
  if ($readini(price.ini,-n,S,D)) { did -c price 22 }
}
on *:DIALOG:price:sclick,menu:2,24:{
  if ($sock(price.*)) {
    if ($input(The price socket is already connected $+ $crlf $+ Number of connections: $sock(price.*,0) $+ $crlf $+ $crlf $+ Close the socket and continue search?,yw,Error)) {
      sockclose price.*
      goto end
    }
    halt
  }
  :end
  if ($did(1)) {
    var %x = 1
    while ($gettok($did(1),%x,44)) {
      sockopen $+(price.,%x) www.zybez.net 80
      inc %x
    }
    did -ra price 5 Looking up $qt($did(1)) $+([,$gettok($did(1),0,44) item $+ $iif($gettok($did(1),0,44) > 1,s),])
  }
  else { did -ra price 5 No item supplied }
}
on *:DIALOG:price:sclick:3:{
  if ($did(4).lines) {
    did -r price 4
    did -z price 4
    did -ra price 5 Cleared all results
  }
  else { did -ra price 5 No results to clear }
}
on *:DIALOG:price:sclick:6:{
  if ($did(4).sel) {
    did -ra price 5 Cleared $did(4,0).sel line $+ $iif($did(4,0).sel > 1,s)
    while ($did(4).sel) { did -d price 4 $ifmatch }
  }
  else { did -ra price 5 No line(s) are selected }
}
on *:DIALOG:price:sclick,menu:7,15,16:{
  if ($did(4).seltext) && ($did == 7 || $did == 16) {
    var %x = 1
    while (%x <= $did(4,0).sel) {
      write Price.txt $did(4,$did(4,%x).sel)
      inc %x
    }
    did -ra price 5 Saved $did(4,0).sel line $+ $iif($did(4,0).sel > 1,s)
  }
  elseif ($did(4).lines) && ($did == 7 || $did == 15) {
    var %x = 1
    while (%x <= $did(4).lines) {
      write Price.txt $did(4,%x)
      inc %x
    }
    did -ra price 5 Saved all lines $+([,$did(4).lines,])
  }
  else { did -ra price 5 Nothing to save }
}
on *:DIALOG:price:sclick,menu:8,18:{
  if ($exists(price.txt)) { dialog -md ps ps }
  elseif ($input(You currently do not have any saved prices $+ $crlf $+ $crlf $+ To save an item: $+ $crlf $+ $crlf • Press the 'Save' button on the main dialog $+ $crlf • If you have line(s) selected $+ $chr(44) it will only save those line(s) that are selected $+ $crlf • If you do not have any lines selected $+ $chr(44) all lines will be added into the save file $+ $crlf $+ $crlf $+ Open the save dialog?,yw,No saves found)) { dialog -md ps ps }
}
on *:DIALOG:price:sclick,menu:9,26:{
  if ($did(4).sel) {
    if ($did(4).sel == 1) { did -ra price 5 Cannot move line up }
    else {
      var %t = $did(4).seltext, %n = $did(4).sel
      did -d price 4 %n
      did -i price 4 $calc(%n -1) %t
      did -c price 4 $calc(%n -1)
      did -ra price 5 Moved line %n up
    }
  }
  else { did -ra price 5 No line selected to move up }
}
on *:DIALOG:price:sclick,menu:10,27:{
  if ($did(4).sel) {
    if ($did(4).sel == $did(4).lines) { did -ra price 5 Cannot move line down }
    else {
      var %t = $did(4).seltext, %n = $did(4).sel
      did -d price 4 %n
      did -i price 4 $calc(%n +1) %t
      did -c price 4 $calc(%n +1)
      did -ra price 5 Moved line %n down
    }
  }
  else { did -ra price 5 No line selected to move down }
}
on *:DIALOG:price:menu:12:{
  if ($did(4).lines) {
    did -r price 4
    did -ra price 5 Cleared all results
  }
  else { did -ra price 5 No results to clear }
}
on *:DIALOG:price:menu:13:{
  if ($did(4).sel) {
    did -ra price 5 Cleared $did(4,0).sel line $+ $iif($did(4,0).sel > 1,s)
    while ($did(4).sel) { did -d price 4 $ifmatch }
  }
  else { did -ra price 5 No line(s) are selected }
}
on *:DIALOG:price:menu:21:{ dialog -md pr pr }
on *:DIALOG:price:menu:22:{
  if ($did(22).state) {
    did -u price 22
    writeini -n price.ini S D 0
  }
  else {
    did -c price 22
    writeini -n price.ini S D 1
  }
}
on *:DIALOG:price:menu:28:{ dialog -md pc pc }
on *:DIALOG:price:menu:33:{
  if ($did(33).state) {
    did -u price 33
    dialog -n price
  }
  else {
    did -c price 33
    dialog -o price
  }
}
on *:DIALOG:price:menu:35:{ dialog -x price }
on *:DIALOG:price:menu:36:{ noop $input(Price Lookup dialog made by Xxhaloxx4 for public release. $+ $crlf $+ $crlf $+ All prices taken from Zybez.net $+ $crlf $+ $crlf $+ Future updates include: but not limited to: $+ $crlf • Ability to select your own socket connections $+ $crlf • Fix any bugs that come to my attention,ow,About) }
on *:DIALOG:price:menu:38:{
  if ($did(4).sel) {
    did -ra price 5 Added separator above line $did(4).sel
    did -i price 4 $did(4).sel $chr(32)
  }
  else { did -ra price 5 No line selected }
}
on *:DIALOG:price:menu:39:{
  if ($did(4).sel) {
    var %n = $calc($did(4).sel +1)
    did -ra price 5 Added separator below line $did(4).sel
    did -i price 4 $iif(%n == $calc($did(4).lines +1),$did(4).lines,%n) $chr(32)
  }
  else { did -ra price 5 No line selected }
}
on *:SOCKOPEN:price.*:{
  sockwrite -n $sockname GET /priceguide.php?search_terms= $+ $replace($gettok($did(price,1),$gettok($sockname,2,46),44),$chr(32),+) $+ &search_area=1&price_low=0&price_high=0&member=1&all_prices=1&sortby=name&sort=ASC&ppage=200 HTTP/1.1
  sockwrite -n $sockname Host: www.zybez.net
  sockwrite -n $sockname $+($crlf,$crlf)
}
on *:SOCKREAD:price.*:{
  if ($sockerr) { did -a price 5 Socket Error $qt($sockerr) }
  else {
    var %read, %id = $gettok($sockname,2,46)
    sockread %read
    if (*<td style="text-align: left; width: 180px;">Viewing * of * Results</td>* iswm %read) { set $+(%,pr.,%id) $gettok($nohtml(%read),2,32) }
    if (*<!--name-->* iswm %read) { set $+(%,p.n.,%id) $nohtml(%read) }
    if ($regex(%read,/<td class="tablebottom" title="Former average price: (.*)gp (.*)"><img src="(.*)" alt="This price has/Si)) { set $+(%,p.c.,%id) $remove($regml(2),[,]) }
    if (*<td class="tablebottom"><a href="/priceguide.php?category=145">*</a></td>* iswm %read) { set $+(%,p.ct.,%id) $nohtml(%read) }
    if (*<!--price-->* iswm %read) {
      if ($readini(price.ini,-n,S,D) || !$readini(price.ini,-n,S,M)) { did -a price 4 $($+(%,p.n.,%id),2) $+ : $nohtml(%read) $iif($($+(%,p.c.,%id),2),$+([,$ifmatch,])) }
      else { did -a price 4 $replace($readini(price.ini,-n,S,M),*item*,$($+(%,p.n.,%id),2),*price*,$nohtml(%read),*cat*,$iif($($+(%,p.ct.,%id),2),$ifmatch,None),*change*,$iif($($+(%,p.c.,%id),2),$ifmatch,None)) }
      unset %p.*
      did -z price 4
    }
    if (*<!-- Search Results: End -->* iswm %read) {
      did -ra price 5 $($+(%,pr.,%id),2) result $+ $iif($($+(%,pr.,%id),2) > 1,s) found $+([,$did(price,4).lines total,])
      unset %p.* %pr.*
    }
  }
}
alias -l nohtml { return $remove($regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null),&nbsp;,$chr(09)) }
dialog ps {
  title "Saved Prices"
  size -1 -1 215 109
  option dbu
  list 1, 0 0 215 93, size hsbar vsbar
  button "Empty", 2, 17 95 26 12
  button "C Line", 3, 44 95 26 12
  button "Refesh", 4, 74 95 26 12
  button "^", 5, 140 95 9 12
  button "v", 6, 150 95 9 12
  button "Add Sep", 7, 104 95 26 12
}
on *:DIALOG:ps:init:*:{
  if ($exists(price.txt)) {
    var %x = 1
    while (%x <= $lines(price.txt)) {
      if (!$read(price.txt,%x)) {  did -a ps 1 $chr(32) }
      else { did -a ps 1 $read(price.txt,%x) }
      inc %x
    }
    did -z ps 1
  }
}
on *:DIALOG:ps:sclick:2:{
  if ($input(Are you sure you wish to empty the save file?,yi,Confirm Erase)) {
    .remove price.txt
    did -r ps 1
    did -z ps 1
    noop $input(Saved file was cleared of all data,oi,Erased)
  }
}
on *:DIALOG:ps:sclick:3:{
  if ($did(1).sel) {
    while ($did(1).sel) {
      write -dl $+ $did(1).sel Price.txt
      did -d ps 1 $did(1).sel
    }
  }
  else { noop $input(Select line(s) to clear from the file,ow,Error) }
}
on *:DIALOG:ps:sclick:4:{
  if ($exists(price.txt)) {
    did -r ps 1
    var %x = 1
    while (%x <= $lines(price.txt)) {
      if (!$read(price.txt,%x)) {  did -a ps 1 $chr(32) }
      else { did -a ps 1 $read(price.txt,%x) }
      inc %x
    }
    did -z ps 1
  }
  else {
    did -r ps 1
    noop $input(The save file was not found,ow,Error)
  }
}
on *:DIALOG:ps:sclick:5:{
  if ($did(1).sel) {
    if ($did(1).sel == 1) { noop $input(Cannot move line up $+ $chr(44) it is already the top line,ow,Error) }
    else {
      var %n = $did(1).sel, %t = $did(1).seltext
      write -dl $+ %n Price.txt
      write -il $+ $calc(%n -1) Price.txt %t
      did -d ps 1 %n
      did -i ps 1 $calc(%n -1) %t
      did -c ps 1 $calc(%n -1)
    }
  }
  else { noop $input(Select a line to move up in the list,ow,Error) }
}
on *:DIALOG:ps:sclick:6:{
  if ($did(1).sel) {
    if ($did(1).sel == $did(1).lines) { noop $input(Cannot move line down $+ $chr(44) it is already the bottom line,ow,Error) }
    else {
      var %n = $did(1).sel, %t = $did(1).seltext
      write -dl $+ %n Price.txt
      write -il $+ $calc(%n +1) Price.txt %t
      did -d ps 1 %n
      did -i ps 1 $calc(%n +1) %t
      did -c ps 1 $calc(%n +1)
    }
  }
  else { noop $input(Select a line to move down in the list,ow,Error) }
}
on *:DIALOG:ps:sclick:7:{
  if ($did(1).sel) {
    did -i ps 1 $did(1).sel $chr(32)
    write -il $+ $calc($did(1).sel -1) price.txt $chr(32)
  }
  else { noop $input(Select a line to add a seperator above it,ow,Error) }
}
dialog pc {
  title "Compare Prices"
  size -1 -1 208 142
  option dbu
  edit "", 1, 3 3 50 10, autohs
  button "Lookup", 2, 55 2 26 12
  edit "", 3, 107 3 50 10
  button "Lookup", 4, 159 2 26 12
  list 5, 0 16 100 54, size hsbar vsbar
  list 6, 104 16 100 54, size hsbar vsbar
  text "Item:", 17, 2 72 13 8
  text "", 18, 17 72 82 8
  text "Price:", 19, 2 82 13 8
  text "", 20, 17 82 85 8
  text "Category:", 21, 2 92 24 8
  text "", 22, 28 92 74 8
  text "Change:", 23, 2 102 21 8
  text "", 24, 25 102 76 8
  text "", 25, 121 82 85 8
  text "Price:", 26, 106 82 13 8
  text "Item:", 27, 106 72 13 8
  text "", 28, 121 72 82 8
  text "", 29, 132 92 74 8
  text "Category:", 30, 106 92 24 8
  text "Change:", 31, 106 102 21 8
  text "", 32, 129 102 76 8
  text "Difference in price:", 33, 41 121 46 8
  text "", 34, 89 121 85 8
  text "Difference in change:", 35, 35 131 52 8
  text "", 36, 89 131 85 8
  text "--------------------------------------------------------------------------------------------------------", 37, 0 112 209 8
  button "C", 41, 84 2 9 12
  button "C", 42, 188 2 9 12
  menu "File", 7
  item "On Top", 8, 7
  item break, 9, 7
  item "Exit", 10, 7
  menu "Search", 11
  item "Lookup 1", 12, 11
  item "Lookup 2", 15, 11
  item "Clear", 13, 11
}
on *:DIALOG:pc:close:*:{ .remove Temp }
on *:DIALOG:pc:sclick:5:{
  if ($did(5).sel) {
    if ($read(temp,s,$did(5).seltext)) {
      tokenize 124 $ifmatch
      did -a pc 18 $did(5).seltext
      did -a pc 20 $1
      did -a pc 22 $2
      did -a pc 24 $3
      if ($did(18) && $did(28)) {
        var %p11 = $remove($gettok($did(20),1,45),$chr(44),gp), %p12 = $remove($gettok($did(20),2,45),$chr(44),gp)
        var %p21 = $remove($gettok($did(25),1,45),$chr(44),gp), %p22 = $remove($gettok($did(25),2,45),$chr(44),gp)
        if (%p12 && %p22) {
          if (%p12 > %p22) { did -ra pc 34 < $bytes($remove($calc(%p11 - %p21),-),db) - $bytes($remove($calc(%p12 - %p22),-),db) $+ gp }
          else { did -ra pc 34 > $bytes($remove($calc(%p21 - %p11),-),db) - $bytes($remove($calc(%p22 - %p12),-),db) $+ gp }
        }
        else {
          if (%p11 > %p12) { did -ra pc 34 < $bytes($remove($calc(%p11 - %p21),-),db) $+ gp }
          else { did -ra pc 34 > $bytes($remove($calc(%p11 - %p21),-),db) $+ gp }
        }
        var %c1 = $remove($replace($did(24),decreased by,-,none,0),increased by,$chr(32),$chr(44),gp), %c2 = $remove($replace($did(32),decreased by,-,none,0),increased by,$chr(32),$chr(44),gp)
        if (%c1 > %c2) { did -ra pc 36 $bytes($calc(%c1 - %c2),db) $+ gp }
        else { did -ra pc 36 $bytes($calc(%c2 - %c1),db) $+ gp }
      }
    }
  }
}
on *:DIALOG:pc:sclick:6:{
  if ($did(6).sel) {
    if ($read(temp,s,$did(6).seltext)) {
      tokenize 124 $ifmatch
      did -a pc 28 $did(6).seltext
      did -a pc 25 $1
      did -a pc 29 $2
      did -a pc 32 $3
      if ($did(18) && $did(28)) {
        var %p11 = $remove($gettok($did(20),1,45),$chr(44),gp), %p12 = $remove($gettok($did(20),2,45),$chr(44),gp)
        var %p21 = $remove($gettok($did(25),1,45),$chr(44),gp), %p22 = $remove($gettok($did(25),2,45),$chr(44),gp)
        if (%p12 && %p22) {
          if (%p12 > %p22) { did -ra pc 34 < $bytes($calc(%p11 - %p21),db) - $bytes($calc(%p12 - %p22),db) $+ gp }
          else { did -ra pc 34 > $bytes($calc(%p21 - %p11),db) - $bytes($calc(%p22 - %p12),db) $+ gp }
        }
        else {
          if (%p11 > %p12) { did -ra pc 34 < $bytes($calc(%p11 - %p21),db) $+ gp }
          else { did -ra pc 34 > $bytes($calc(%p11 - %p21),db) $+ gp }
        }
        var %c1 = $remove($replace($did(24),decreased by,-,none,0),increased by,$chr(32),$chr(44),gp), %c2 = $remove($replace($did(32),decreased by,-,none,0),increased by,$chr(32),$chr(44),gp)
        if (%c1 > %c2) { did -ra pc 36 $bytes($calc(%c1 - %c2),db) $+ gp }
        else { did -ra pc 36 $bytes($calc(%c2 - %c1),db) $+ gp }
      }
    }
  }
}
on *:DIALOG:pc:menu:8:{
  if ($did(8).state) {
    did -u pc 8
    dialog -n pc
  }
  else {
    did -c pc 8
    dialog -o pc
  }
}
on *:DIALOG:pc:menu:10:{
  .remove Temp
  dialog -x pc
}
on *:DIALOG:pc:sclick,menu:2,12:{
  if ($did(1)) {
    if ($sock(price2)) {
      if ($input(The Compare Price socket is already connected $+ $crlf $+ $crlf $+ Close socket and continue search?,yw,Connection already open)) {
        sockclose price2
        goto end
      }
      halt
    }
    :end
    set %pc.num 5
    sockopen price2 www.zybez.net 80
  }
  else { noop $input(Supply an item to lookup,ow,Error) }
}
on *:DIALOG:pc:sclick,menu:4,15:{
  if ($did(3)) {
    if ($sock(price2)) {
      if ($input(The Compare Price socket is already connected $+ $crlf $+ $crlf $+ Close socket and continue search?,yw,Connection already open)) {
        sockclose price2
        goto end
      }
      halt
    }
    :end
    set %pc.num 6
    sockopen price2 www.zybez.net 80
  }
  else { noop $input(Supply an item to lookup,ow,Error) }
}
on *:DIALOG:pc:sclick,menu:13,41,42:{
  did -r pc 5,6,18,20,22,24,25,28,29,32,34,36
  .remove temp
}
on *:SOCKOPEN:price2:{
  sockwrite -n $sockname GET /priceguide.php?search_terms= $+ $replace($did(pc,$iif(%pc.num == 5,1,3)),$chr(32),+) $+ &search_area=1&price_low=0&price_high=0&member=1&all_prices=1&sortby=name&sort=ASC&ppage=200 HTTP/1.1
  sockwrite -n $sockname Host: www.zybez.net
  sockwrite -n $sockname $+($crlf,$crlf)
}
on *:SOCKREAD:price2:{
  if ($sockerr) { return }
  else {
    var %read
    sockread %read
    if (*<!--name-->* iswm %read) { set %p.n $nohtml(%read) }
    if ($regex(%read,/<td class="tablebottom" title="Former average price: (.*)gp (.*)"><img src="(.*)" alt="This price has/Si)) { set %p.f $remove($regml(2),[,]) }
    if (*<td class="tablebottom"><a href="/priceguide.php?category=*">*</a></td>* iswm %read) { set %p.c $nohtml(%read) }
    if (*<!--price-->* iswm %read) {
      write Temp %p.n $chr(124) $nohtml(%read) $chr(124) $iif(%p.c,$ifmatch,None) $chr(124) $iif(%p.f,$ifmatch,None))
      did -a pc %pc.num %p.n
      unset %p.*
      did -z pc %pc.num
    }
    if (*<!-- Search Results: End -->* iswm %read) { unset %p.* %pc.* }
  }
}
dialog pr {
  title "Results Display"
  size -1 -1 112 50
  option dbu
  check "Enable", 1, 3 3 25 10
  button "Help", 2, 68 36 17 12
  text "Display:", 3, 5 15 19 8
  edit "", 4, 2 23 108 10, autohs
  button "Ok", 5, 8 36 24 12, ok
  button "Cancel", 6, 36 36 24 12, cancel
}
on *:DIALOG:pr:init:*:{
  if (!$readini(price.ini,-n,S,D)) { did -c pr 1 }
  if ($readini(price.ini,-n,S,M)) { did -ra pr 4 $ifmatch }
}
on *:DIALOG:pr:sclick:2:{ dialog -ma prh prh }
on *:DIALOG:pr:sclick:5:{
  writeini -n price.ini S D $iif($did(1).state,0,1)
  if ($did(1).state) { did -u price 22 }
  if ($did(4)) { writeini -n price.ini S M $strip($did(4)) }
  else { noop $input(No text was entered for the custom display $+ $crlf $+ $crlf $+ Saving of result display cancelled,ow,Error) }
}
dialog prh {
  title "RD Help"
  size -1 -1 153 65
  option dbu
  text "Result Replacers:", 1, 2 2 42 8
  text "*item* = item name", 2, 2 14 48 8
  text "*price* = price of item", 3, 2 24 54 8
  text "*cat* = category", 4, 2 34 42 8
  text "*change* = change of price", 5, 2 44 68 8
  text "| | | | | | | | | |", 6, 72 1 2 62
  text "Color is not allowed and will be stripped when it is saved", 7, 77 3 73 13
  text "Result Replacers can be touching items other than itself", 8, 77 19 73 20
  text "When a category/change does not exist, the returning text will be 'None'", 9, 77 42 73 20
}