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: 
Romans_I_XVI
Roku Guru

How do I save a hex value to the registry?

I'd like to store some hex values in the registry, however the registry only accepts strings. I can't use .tostr() and then back to .toint() because the value is too large as explained by RokuKC here -> viewtopic.php?f=34&t=84652 .

So what are my options? How would I store a hex value (being used for a color such as &hffffffff) in the registry?

Thanks.
0 Kudos
3 REPLIES 3
squirreltown
Roku Guru

Re: How do I save a hex value to the registry?

I'm doing this:

sec.Write("bakclr", "&h404040FF")
background = HexToInteger( sec.Read("bakclr"))
Kinetics Screensavers
0 Kudos
EnTerr
Roku Guru

Re: How do I save a hex value to the registry?

Try Stri(int) in one direction and then val(str, 10) in the other.
(Yes, the val with second argument.)

Hex colors with R>127 are negative int-s - that's ok as long as conversion to and fro is faithful.

PS. a quick&dirty check (besides discovering a bug in loops) seems to confirm the combo working:
BrightScript Debugger> for v = -2^31 to 2^31-258 step 257: check = v=val(stri(v), 10) or 0/0: next
BrightScript Debugger> REM: no "divide by zero" error

As illustration to what happens to big ints when they go through floats:
BrightScript Debugger> b = &h7ffffeff
BrightScript Debugger> ? b = int(b)
false
BrightScript Debugger> ? type(b), b, int(b), cint(b)
Integer 2147483391 2147483392 2147483392
0 Kudos
Romans_I_XVI
Roku Guru

Re: How do I save a hex value to the registry?

Thanks for your responses, after I posted this I decided even if I got those numbers into the registry it wouldn't give me the ability to easily adjust the color like I needed. So I got this put together, now I will just save the hue to the registry, which is only a max of 360 anyway 😄 .
viewtopic.php?f=34&t=85620
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.