Help with Currency Exchange Tile

Continuing the discussion from Navigation Screen customization:

Regarding the currency exchange tile tutorial posted by @proeftuin. I have tried, unsucessfully to implement it. Would be thankful if someone could glance over my rules/actions etc. to see if they can identify the problem.
Kept it simple and just using the exact same script as the tutorial at first (once I get that working i’ll change the rates).

Thanks


Script:

function exchangerates()
{
var nL = '<linebreak/>';
var base = 'EUR'
var symbol1 = 'RON'
var symbol2 = 'GBP'
var symbol3 = 'HUF'
var u = 'http://api.fixer.io/latest?base='+base+'&symbols='+symbol1+','+symbol2+','+symbol3+'';
var getrates = web.Download(u);
var allrates = JSON.parse(getrates);
var currentdate = allrates.date;
var rate1 = allrates.rates.RON;
var rate2 = allrates.rates.GBP;
var rate3 = allrates.rates.HUF;

return tag.Size(25,'<b><color Blue>Exchange Rates</color></b>') + nL + tag.Size(20,'<b><color Blue>Date:       </color></b>') + '<size 20>'+currentdate+'</size>'
+ nL + tag.Size(20,'<color White> '+base+' 1 = '+symbol1+' '+rate1+' </color>')
+ nL + tag.Size(20,'<color White> '+base+' 1 = '+symbol2+' '+rate2+' </color>')
+ nL + tag.Size(20,'<color White> '+base+' 1 = '+symbol3+' '+rate3+' </color>');
}

Automation command:


End result: The big red box that is blank.

The box on bottom right of your script editor screen allows you to test script without having to leave the edit screen. Use it like

function(‘XXX’)

It will show errors in script if any.

1 Like

Your call looks like this:

{CALL:euro.exchangerates()}

But your Script Handler is exchangerates, as well as your function name. The correct syntax for calling a script is:

{CALL:handler.function()}

So you need to change your Handler to euro, or change your call to:

{CALL:exchangerates.exchangerates()}

@Jesse brings up a good point for testing to see if your script function is working without errors. In the Script screen, at bottom-right, type the following in the box and click Test:

exchangerates()

2 Likes