Top

Currency Converter Dialog


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  5.4 (of 8 scores)
Date Added  May 25, 2008
Last Updated  Jun 21, 2008
Tags  converter  currency  dialog  finance  money  regex  sockets 

Introduction

My Currency Converter dialog for mIRC.
I have recently re-done the script to take out favorites, killed the problem with the timers to make the whole script much more efficient and less annoying!

Converts X number from one currency to another one.

Thanks to Lindrian for help with the on *:SOCKREAD: event and $regex !

If script says converting for long time, close it and start again (should only happen first time you run)





Grab the Code

menu status,channel,nicklist {
  [Currency Converter]: $iif(!$dialog(CurrencyConverter),dialog -mied CurrencyConverter CurrencyConverter,halt)
}
alias currencyconverter $iif(!$dialog(CurrencyConverter),dialog -mied CurrencyConverter CurrencyConverter,halt)
dialog CurrencyConverter {
  title "Currency Converter"
  size -1 -1 240 280
  text "Currency Converter ~Vaseline28", 1, 35 4 200 20
  text "Information thanks to: finance.yahoo.com", 2, 20 20 230 20 
  tab "Custom", 3, 10 50 220 220
  button "New Conversion", 5, 20 80 200 40, left, tab 3
  box "Results", 6, 20 125 200 130, tab 3
  text "From:", 7, 30 150 80 20, tab 3
  text "To:", 8, 30 170 80 20, tab 3
  text "Amount:", 9, 30 190 80 20, tab 3
  text "Converts to:", 10, 30 210 80 20, tab 3
  text "Exchange Rate:", 11, 30 230 80 20, tab 3
  text "**", 12, 80 150 80 20, tab 3
  text "**", 13, 70 170 80 20, tab 3
  text "**", 14, 90 190 80 20, tab 3
  text "**", 15, 105 210 80 20, tab 3
  text "**", 16, 120 230 80 20, tab 3
  box "Conversion Information", 17, 10 280 220 160
  box "From", 18, 20 300 90 90
  box "To", 19, 130 300 90 90
  box "Amount", 20, 20 390 200 45
  edit "Replace with Number. No symbols", 21, 30 408 180 20
  button "Go!", 22, 200 445 30 20
  button "Cancel", 23, 155 445 40 20
  combo 24, 30 318 70 70
  combo 25, 140 318 70 70
  text "", 26, 15 445 140 20, hide
}
on *:dialog:CurrencyConverter:init:*: {
  var %i GBP USD EUR ARS BBD BZB BOB BRL CAD CLP COP CRC CUP ECS MXN PAB PYG BZD BWP DJF DOP EGP ERN ETP FJD GMD GHC GYD HKD INR IDR IRR IQD ILS JPY KES KRW NAD NPR NZDNIO NGN PKR PHR RUB SOS ZAR SGD LKR
  var %x 0
  while (%x < $numtok(%i,32)) {
    inc %x
    did -i $dname 24 %x $gettok(%i,%x,32)
    did -i $dname 25 %x $gettok(%i,%x,32)
  }
  if (%CurrencyFavoriteOn != $null) { did -h $dname 27-43 | did -v $dname 44 }
}
on *:dialog:CurrencyConverter:sclick:5: {
  dialog -s $dname -1 -1 240 470
}
on *:dialog:CurrencyConverter:sclick:23: {
  dialog -s $dname -1 -1 240 280
}
on *:dialog:CurrencyConverter:sclick:22: {
  timercurrency off
  $iif(!$did($dname,24).seltext, customconvertwrong, did -h $dname 26)
  $iif(!$did($dname,25).seltext, customconvertwrong, did -h $dname 26)
  $iif($did($dname,21).edited == $false, customconvertwrong, did -h $dname 26)
  dialog -s $dname  -1 -1 240 280
  did -av $dname 12 $did($dname,24).seltext | did -av $dname 13 $did($dname,25).seltext | did -av $dname 14 $didtok($dname,21,32) | did -av $dname 15 ...Converting... | did -av $dname 16 ...Converting...
  currency $didtok($dname,21,32) $did($dname,24).seltext $did($dname,25).seltext
 
  did -u $dname 24 | did -u $dname 25 | did -o $dname 21 1 Replace with Number. No symbols
}
alias customconvertwrong {
  did -av $dname 26 Invalid Parameters selected.
  halt
}
on *:dialog:CurrencyConverter:close:*: {
  /timercurrency off
}
alias currency {
  if ($sock(currency)) .sockclose $v1
  sockopen currency finance.yahoo.com 80
  set %Currency amt= $+ $1 $+ &from= $+ $2 $+ &to= $+ $3 $+ &submit=Convert
}
on *:SOCKOPEN:currency: {
  sockwrite -n $sockname GET /currency/convert? $+ %Currency HTTP/1.1   
  sockwrite -n $sockname Host: finance.yahoo.com
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
  sockwrite -n $sockname $crlf
}
on *:SOCKREAD:currency: {
  var %x
  sockread %x
  if ($regex(%x,/<td class="w+"><b>(d+)</b></td><td class="w+">(.*?)</td><td class="w+">(d+(?:.d+)?)</td>/i)) {
    did -av CurrencyConverter 14 $ $+ $regml(1)
    var %Amount $regml(1)
  }
  if ($regex(%x,/<td class="w+">(d+(?:.d+)?)</td>/ig)) {
    did -av CurrencyConverter 15 $calc($regml(3) * %Amount)
    did -av CurrencyConverter 16 $regml(3) 
  }
  unset %Currency
} 
 
 

Comments

  (6)  RSS
vaseline28
Comments: 162
 
mIRC Snippet:  Currency Converter Dialog
Posted on Jun 21, 2008 6:34 am
Deleted all comments for the revised version of the script, things which have changed:

No Favorites - seemed to be annoying than useful
Timers are off - There are no timers anymore
Compact - Script is much more compact


greenlanter420
Comments: 77
 
mIRC Snippet:  Currency Converter Dialog
Posted on Jun 21, 2008 10:02 am
looks really good well done
vaseline28
Comments: 162
 
mIRC Snippet:  Currency Converter Dialog
Posted on Jun 21, 2008 10:25 am
Thank you, if anyone knows of any currencies not included, please let me know!
Vlada_bgd
Comments: 15
 
mIRC Snippet:  Currency Converter Dialog
Posted on Jun 23, 2008 3:31 am
RSD a.k.a. Serbian Dinar :)
Atm 1€=78.2RSD
Toby3
Comments: 1
 
mIRC Snippet:  Currency Converter Dialog
Posted on Jul 19, 2009 1:28 am
I dont seem to be able to get this working, as mentioned, it converts for a lonnnnnng time. Shut it down, try again, same again.
vaseline28
Comments: 162
 
mIRC Snippet:  Currency Converter Dialog
Posted on Jul 25, 2009 5:55 am
Yeah, that's because yahoo have changed their currency converter online to a new AJAX system and i haven't yet worked out which page I need to grab the data from.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom