
Romans_I_XVI
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2015
12:57 PM
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.
So what are my options? How would I store a hex value (being used for a color such as &hffffffff) in the registry?
Thanks.
3 REPLIES 3

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2015
01:28 PM
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
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2015
01:30 PM
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:
As illustration to what happens to big ints when they go through floats:
(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

Romans_I_XVI
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
06:40 PM
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
viewtopic.php?f=34&t=85620