Reputation: 818
I tried to create a roRegistration section and write a two function GetAuthData and SetAuthData I tried to pass multiple Argument in SetAuthData and Read using GetAuthData.
Function GetAuthData() As Dynamic
sec = CreateObject("roRegistrySection", "Authentication")
' print "section : " + Authentication
if sec.Exists("Authentication")
print "Read URL : " + m.top.GlobleURL
print " ****************** DATA :" + m.top.GlobleURL
return sec.Read("Authentication")
'return sec.Delete("Authentication") ' Here not override concept so compalsary delete first and after again second URL Store pannel.brs and hud.brs both file
print "***********************GetAuthData************************"
endif
return invalid
End Function
'Here the SetAuthData to wrire URL
Function SetAuthData(Serverurl As String,zxorausername As String, zxorapassword As String) As Void
sec = CreateObject("roRegistrySection", "Authentication")
m.top.GlobleURL = Serverurl
m.top.globalusername = zxorausername
m.top.globalpass = zxorapassword
sec.Write("Authentication", m.top.GlobleURL)
sec.Write("Authentication", m.top.globalusername)
sec.write("Authentication", m.top.globalpass)
?"key for the URL" sec.GetKeyList()
Print "Write URL :" + m.top.GlobleURL
Print " Write username :" + m.top.globalusername + " Write pass :" + m.top.globalpass
print "***********************SetAuthData************************"
End Function
And I call GetAuth data like below
m.top.GlobleURL = GetAuthData()
m.top.globalusername = GetAuthData()
m.top.globalpass = GetAuthData()
And I print it all three item but every time print m.top.GlobleURL value. I tried to Store all three value. But store only one value. Does anyone know this issue?
EDITED POST
Function GetAuthData(key as string) As Dynamic
' reg = CreateObject("roRegistry")
sec = CreateObject("roRegistrySection", "Authentication")
' print "section : " + Authentication
if sec.Exists(key)
return sec.Read(key)
end if
return invalid
'return sec.Delete("Authentication") ' Here not override concept so compalsary delete first and after again second URL Store pannel.brs and hud.brs both file
print "***********************GetAuthData************************"
End Function
'Here the SetAuthData to wrire URL
Function SetAuthData(Serverurl As String,zxorausername As String, zxorapassword As String) As Void
' reg = CreateObject("roRegistry")
sec = CreateObject("roRegistrySection", "Authentication")
m.top.GlobleURL = Serverurl
m.top.globalusername = zxorausername
m.top.globalpass = zxorapassword
' if not m.top.GlobleURL = Serverurl
sec.Write("url", m.top.GlobleURL)
sec.Write("username", m.top.globalusername)
sec.write("password", m.top.globalpass)
sec.Flush()
?"key for the URL" sec.GetKeyList()
Print "Write URL :" + m.top.GlobleURL
Print " Write username :" + m.top.globalusername + " Write pass :" + m.top.globalpass
' end if
print "***********************SetAuthData************************"
' Flush(true)
End Function
and print using the
m.keyUrl = GetAuthData("url")
m.keyUserName = GetAuthData("username")
m.keyPassword = GetAuthData("password")
?"URL Print : " m.keyUrl
?"Username print : " m.keyUserName
?"password print : " m.keyPassword
Upvotes: 0
Views: 254
Reputation: 574
In your code, you are writing the 'Authentication' key inside the 'Authentication' section. And you are writing to the same key i.e. it is getting overwritten. Thats why you are gettig only one key. Please use write function () as --
Function SetAuthData(Serverurl As String,zxorausername As String, zxorapassword As String) As Void
sec = CreateObject("roRegistrySection", "Authentication")
m.top.GlobleURL = Serverurl
m.top.globalusername = zxorausername
m.top.globalpass = zxorapassword
sec.Write("url", m.top.GlobleURL)
sec.Write("username", m.top.globalusername)
sec.write("password", m.top.globalpass)
sec.Flush() // add this to code
print"key for the URL" sec.GetKeyList()
End Function
Make the get function generic to access multiple keys as--
Function GetAuthData( key as String) As Dynamic
sec = CreateObject("roRegistrySection", "Authentication")
if sec.Exists(key)
return sec.Read(key)
endif
return invalid
End Function
Now you can access the keys as--
keyUrl = GetAuthData("url")
keyUserName = GetAuthData("username")
keyPassword = GetAuthData("password")
hope this will help.
(Note:- You can use "ReadMulti" method to read multiple keys at a time. But personaly, I will suggest to not using it as it will involve creating and reading AssociativeArrays, and will create unnecessary complications.)
Upvotes: 0