Exchange Rate Scraping
This script also uses the web scraping capabilities of DbfScript, loading information from a website to retrieve the current Mexican exchange rate:
var #updatetime = load(&root/Currency[Name="MXN (Banco de Mexico)"]) if (SetTime(Today(), #updatetime/UpdateTime) < Now()) then var #rate = load(&root/Currency[Name="MXN (Banco de Mexico)"]) if (not (IsHoliday(#rate/HolidaySchedule, Today(), True))) then var #rateEntry = load(&root/Currency[Name="MXN (Banco de Mexico)"]/HistoricRate[EffectiveDate=Today()]) if (NotExists(#rateEntry)) then // get date call tok:LoadUrl("http://www.banxico.org.mx/tipcamb/llenarTiposCambioAction.do?idioma=en") call tok:SkipTo("FIX") call tok:SkipTo("class") call tok:SkipTo(">") var #date = tok:NextDate() if (#date == Today()) then // get rate call tok:SkipTo("style") call tok:SkipTo("id") call tok:SkipTo(">") var #rate = tok:NextNum() insert record ( EffectiveDate = Today(), Rate = 1 div #rate, Source = "Banco de Mexico" ) for &root/Currency/HistoricRate at &root/Currency[Name="MXN (Banco de Mexico)"]/HistoricRate end if end if end if end if