Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Fourhundred57
Channel Surfer

Help with Syntax for Basic Math as String

Jump to solution

Hello!

I've been struggling with a way for my fiance and I to actually use the Google calendar we share. And by that I mean getting her to actually see it. We fall asleep on the couch quite a bit, so I wanted to set the calendar as our Roku screensaver. This way — we actually pay attention to what's on it.

Fast-forward: It worked! —but I now have one thing I need a bit of coding help with.

I have this bit of code in my screensaver:

m.canvas.SetLayer(1,{   url: "https://api.apiflash.com/v1/urltoimage?access_key=<MYKEYGOESHERE>&format=png&ttl="+rnd(10000).tostr()+"&url=<MYURLGOESHERE>"

I am looking to replace the pseudo-random integer between 1 and 10000 with a pseudo-random integer between 5000 and 10000. I figure I can do this with simple addition by adding 5000 to rnd(5000). Buuuut I can't figure out how to do it while having it embedded in this URL.

In case anyone is curious what the **bleep** I am doing, here's the jist of it:
1. I set up a pretty-looking shared calendar via a (free) service called DAKboard
2. I use a (free) service called API Flash to screenshot my DAKboard URL into a 1080p PNG
3. I use a poorly-coded Roku screensaver to display that image URL

The hangup is that the free version of API Flash has a (totally understandable) monthly limit. I don't need this thing to update more than once every 2-4 hours or so — so I'm cool with using a long Time-to-Live value BUT as we all know if I set a static URL then the Roku cache causes it to not update, well, ever — so I'm using my TTL variable as my cachebuster since adding random flags at the end cause issues with the API Flash syntax.

Anyway - that's it. I like how it ends up looking.
RokuCal.png

Let me know if you can help me with math coding!

0 Kudos
1 Solution

Accepted Solutions
renojim
Community Streaming Expert

Re: Help with Syntax for Basic Math as String

Jump to solution

Cool little project!  It should be as easy as

...&ttl="+(rnd(5000)+5000).toStr()+"&url=...

 

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.

View solution in original post

2 REPLIES 2
renojim
Community Streaming Expert

Re: Help with Syntax for Basic Math as String

Jump to solution

Cool little project!  It should be as easy as

...&ttl="+(rnd(5000)+5000).toStr()+"&url=...

 

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
Fourhundred57
Channel Surfer

Re: Help with Syntax for Basic Math as String

Jump to solution

Aw man! I was so close! Smiley Tongue

Thanks a ton — I'll update with the results when I get a chance to apply.

EDIT: Worked beautifully! Thanks again, renojim!

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.