Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Romans_I_XVI
Level 7

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
squirreltown
Level 9

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
Level 8

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
Level 7

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 Smiley Very Happy .
viewtopic.php?f=34&t=85620
0 Kudos