I have received a few bug reports of this happening, but I'm unable to reproduce it on any of my roku's.
Sub Main()
'... create facade, sets theme, etc etc
TheValue=RegRead("KeyName","MyChannel") 'read saved registry value
If Type(TheValue)="Invalid" Then
port=CreateObject("roMessagePort")
dialog=CreateObject("roMessageDialog")
dialog.SetMessagePort(port)
dialog.SetTitle("Invalid Registry Data")
dialog.SetText("No registry data exists - select OK to save new value")
dialog.AddButton(0,"OK")
dialog.Show()
While TRUE
dlgMsg=Wait(0,port)
If Type(dlgMsg)="roMessageDialogEvent"
If dlgMsg.isButtonPressed()
Print"Button pressed: ";dlgMsg.GetIndex();" ";dlgMsg.GetData()
Exit While
End If
End If
End While
TheValue=CreateObject("roDeviceInfo").GetDisplayType()
RegWrite("KeyName",TheValue,"MyChannel")
End If
'... displays regular screen, loads xml, etc etc etc
End Sub
Function RegRead(key,section=invalid)
If section=invalid section="Default"
sec=CreateObject("roRegistrySection",section)
If sec.Exists(key) Return sec.Read(key)
Return invalid
End Function
Function RegWrite(key,val,section=invalid)
If section=invalid section="Default"
sec=CreateObject("roRegistrySection",section)
sec.Write(key,val)
sec.Flush() 'commit it
End Function
It saves and loads the value just fine on all my roku's (Roku1 and Roku2 types), however, our clients are saying occasionally it pops the error message 'sometimes' when the code section is executed, meaning either it fails when writing the registry value 'sometimes' or the value is getting deleted sometimes. The channel isn't being removed from their roku, it's simply losing the value of the section/key? Have you seen this issue before?
There is no RegDelete command in the script files, just the RegDelete function itself (in case we need it for testing), and with the code above it should never be possible for .GetDisplayType() to return an invalid value to write.