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: 
renojim
Community Streaming Expert

Dynamic typing bit me in the butt

My integer got turned into a float because I added x*(4000/5) to it. It wasn't a problem until I tried to convert it to a string with ToStr(). I think if floats had a ToStr() interface it wouldn't have been a problem at all. 😞

-JT
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.
0 Kudos
3 REPLIES 3
kbenson
Visitor

Re: Dynamic typing bit me in the butt

I might have something useful on this front in a few days. I'm working on a sort of super box() object, that will support common methods for anything you hand it, and if I can pull it off, string interpolation (through an in-string sigil) to boot. It will be part of librokudev if I can get it to work well enough.

Something like:

v = x*(4000/5)
print superbox(v).string()


superbox and string are examples, nothing set in stone yet... I'm considering using single character methods for brevity.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
RokuKevin
Visitor

Re: Dynamic typing bit me in the butt

If you add a '%' character to the end of your variable name, you can be assured the variable is a statically typed Integer.

Example:

myInt% = x*(4000/5) REM myInt% is an Integer. x*(4000/5) is converted to an Integer


--Kevin
0 Kudos
renojim
Community Streaming Expert

Re: Dynamic typing bit me in the butt

I admit it was a dumb mistake on my part. I have Int()'s all over the place, but I just missed that one. I really should use %'s on my integers, but I guess I'm just lazy. I just wanted to point it out to others that you have to be careful.

-JT
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.
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.