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: 
EngoTom
Visitor

roRegistry

From page 85 of the component reference doc.

Why is the variable reg created? I only see sec being used in the following 2 functions.

Also... When calling this function, what does "return invalid" return? I need to if block the return value...

Finally... When calling SetAuthData() will this example take into account a null registry section or one already populated with data. If null I want to create and save data, if not null I want to overwrite value.

THX...

Function GetAuthData() As Dynamic
reg = CreateObject("roRegistry")
sec = CreateObject("roRegistrySection", "Authentication")
if sec.Exists("UserRegistrationToken")
return sec.Read("UserRegistrationToken")
endif
return invalid
End Function

Function SetAuthData(userToken As String) As Void
reg = CreateObject("roRegistry")
sec = CreateObject("roRegistrySection", "Authentication")
sec.Write("UserRegistrationToken ", userToken)
sec.Flush()
End Function
0 Kudos
6 REPLIES 6
TheEndless
Channel Surfer

Re: roRegistry

"EngoTom" wrote:
From page 85 of the component reference doc.

Why is the variable reg created? I only see sec being used in the following 2 functions.

Funny. I was wondering the same thing last night. I thought creating the roRegistry object might initialize something somewhere, but I found that removing that line from my code didn't change any behavior, so I'm curious what it's for as well.

"EngoTom" wrote:
Also... When calling this function, what does "return invalid" return? I need to if block the return value...

"invalid" is the null or Nothing of BrightScript, so "return invalid" gives you a return value that you can test for validity (ex. If token = invalid Then prompt user for credentials).

"EngoTom" wrote:
Finally... When calling SetAuthData() will this example take into account a null registry section or one already populated with data. If null I want to create and save data, if not null I want to overwrite value.

This code will create the registry section if it doesn't already exist, or it will overwrite what's already there if it does exist.

TheEndless
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
EngoTom
Visitor

Re: roRegistry

OK Thanks for your reply.

Kevin, Patrick will you enlighten us on the use of reg in your documentation example?

THX
0 Kudos
RokuKevin
Visitor

Re: roRegistry

EngoTom,

You are correct that the roRegistry object is not necessary to read/write from the registry sections. It's methods are only useful to iterate and manage the different sections of the registry.

Its inclusion in the examples is historical as it used to be the only way to Flush() the registry... but now Flush() can be called on roRegistrySection directly.

--Kevin
0 Kudos
EnTerr
Roku Guru

Re: roRegistry

"RokuKevin" wrote:
[roRegistry] inclusion in the examples is historical as it used to be the only way to Flush() the registry... but now Flush() can be called on roRegistrySection directly.

Is there a difference between using ifRegistrySection.flush() and ifRegistry.flush()?
E.g. is flushing a section (potentially) faster than the whole registry - or does flushing a section not flush all sections as well?
0 Kudos
RokuMarkn
Visitor

Re: roRegistry

As it's currently implemented, RegistrySection.Flush just calls Registry.Flush, which flushes the whole registry. I wouldn't preclude the possibility that someday RegistrySection.Flush might be changed to only flush that one section, but I don't know of any plans to change it.

--Mark
0 Kudos
EnTerr
Roku Guru

Re: roRegistry

Thank you RokuMarkn, your answer - concise as always - is appreciated!
Yeah, i can imagine how registry could be partitioned - yet the 16kb limit will render performance benefits negligible.
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.