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

problems with roRegistrySection

I am having no lucking getting local storage to work for "roRegistrySection". It looks correct, and I've tried several variations, but the "read" never finds what was written. I don't get any errors, but I also don't get any stored codes. What am I missing?

Here's the current code:


Function GetStoredRegCode() As Dynamic
REM registry = CreateObject("roRegistry")
sec = CreateObject("roRegistrySection", "Authentication")
if sec.Exists("UserRegistrationToken")
print "Exists: UserRegistrationToken"
code = sec.Read("UserRegistrationToken")
print "Found Stored RegCode: " + code
return code
else
print "DOES NOT Exist: UserRegistrationToken"
endif
return invalid
End Function

Function SetStoredRegCode(regCode As String) As Void
print "Storing: UserRegistrationToken " + regCode
REM registry = CreateObject("roRegistry")
sec = CreateObject("roRegistrySection", "Authentication")
sec.Write("UserRegistrationToken ", regCode)
sec.Flush()
End Function
0 Kudos
3 REPLIES 3
RokuMarkn
Visitor

Re: problems with roRegistrySection

Your Write statement has an extra space at the end of the registry entry name. So you're writing to one name and reading from a different name.

--Mark
0 Kudos
greid
Visitor

Re: problems with roRegistrySection

Thank you, Mark! I copy/pasted the code directly from the Roku "Component Reference.pdf", page 99, which I now see has the SAME BUG (extra space). I'd recommend fixing the documentation 🙂 I've found a number of inconsistencies in the docs but I didn't see this one.

Thanks again!!
0 Kudos
RokuMarkn
Visitor

Re: problems with roRegistrySection

Thanks, I've fixed the doc.
If you do see any other errors or inconsistencies in the docs, please post them and we'll get them fixed.

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