BTC-IDR
Last: Rp. 107,082,000
High: Rp. 112,503,000
Low: Rp. 95,880,000
TEN-IDR
Last: Rp. 316
High: Rp. 346
Low: Rp. 292
bla bla bla also another coin
.
im so blind in this

Moderator: Martin
can you help me to make it more less script to adding new map?Micky Micky wrote: ↑20 Mar 2020 20:36Hello
This should get you going. You can see the structure and amend as required.
http://automagic4android.com/flow.php?i ... cf57e0c20f
Hope this helps
Micky
Code: Select all
js = fromJSON(response);
t = js["tickers"];
tickers = newMap();
for(i in getMapKeys(t))
tickers[i] = newList(t[i]["last"], t[i]["high"], t[i]["low"]);
//tickers contains map | coin name : Last, High, Low
show = "";
for(i in getMapKeys(tickers))
show = show +
"{toUpperCase(i)}\n" +
"Last : Rp. {tickers[i][0],numberformat,#,##0.##}\n" +
"High : Rp. {tickers[i][1],numberformat,#,##0.#}\n" +
"Low : Rp. {tickers[i][2],numberformat,#,##0.##}\n\n";
//this part use the favourite, save the keyword in the fav list
fav = newList("btc_idr", "ten_idr");
showfav = "";
for(i in fav)
showfav = showfav +
"{toUpperCase(i)}\n" +
"Last : Rp. {tickers[i][0],numberformat,#,##0.##}\n" +
"High : Rp. {tickers[i][1],numberformat,#,##0.#}\n" +
"Low : Rp. {tickers[i][2],numberformat,#,##0.##}\n\n";
wow.. awesomeDesmanto wrote: ↑21 Mar 2020 16:30@gilanxcheetz : Use loop. If you dig on the js variable in the debug dialog, change value, you can tap the "tickers" and see all the coins map. Loop upon this and store in other list or you can directly create the text to show. I prefer to create a temporary list or map to store the converstion first, because you can do another preprocessing before showing it, or doing some filter.
Using temporary map, we can filter out for only some coins. As shown in the favourite part.
You can also use the remove, to show every coin except the ones you don't need. You can also do some calculation and don't include the coin which have value lower than 0. But I will leave that to you first.