Here is some code that I have used, while out of context, it might provide some clues to help you. At the bottom are some of my registry management functions.
*********************************************************************
Write the current search term to the registry: (note, this is an excerpt and is based on previous search terms having already been loaded into histlist from the registry. It checks if the search term is already in the registry and if not then it adds it to the list and removes the oldest term from the list)
'code excerpt from a search screen
'm.tquerystring contains is the current search term.
'histlist contains list of search terms loaded from the registry
histlist=m.historylist 'this line should go at the very top of the search function
flag=0
for i=0 to histlist.count()-1
if m.tquerystring=histlist[i]
flag=1
end if
next i
if flag <> 1 then
histlist.unshift(m.tquerystring)
if histlist.count() > 9
histlist.pop()
end if
end if
searchscr.setsearchterms(histlist)
m.historylist=histlist
writereg("history","searchhist",arraytostring(histlist))
function AddHistory(id,histlist) as object
flag=0
for i=0 to histlist.count()-1
if id=histlist[i]
flag=1
end if
next i
if flag <> 1 then
histlist.unshift(id)
if histlist.count() > 10
histlist.pop()
end if
end if
m.mixhist=histlist
writereg("history","mixhist",arraytostring(histlist))
return m.mixhist
end function
function arraytostring(array as object) as string
str=""
for each element in array
if element <> invalid
str=element+","+str
end if
next
return left(str,len(str)-1)
end function
function loadsearchHistory()
if not checkreg("history","searchhist") then
?"no search history in the registry"
createregsection("history","searchhist", "")
else
?"found search history, loading"
histemp=box(readreg("history","searchhist").tokenize(","))
i=histemp.count()-1
j=0
while true
if i=-1 or j > histemp.count() -1
exit while
end if
m.historylist[j]=histemp[i]
i=i-1
j=j+1
end while
end if
end function
function createregsection(secname as string,keyname as string, keyvalue as string)
registry=createobject("roregistry")
section=createobject("roregistrysection",secname)
section.write(keyname,keyvalue)
end function
function checkreg(secname as string,keyname as string) as boolean
registry=createobject("roregistry")
section=createobject("roregistrysection",secname)
return section.exists(keyname)
end function
function readreg(secname as string, keyname as string) as string
registry=createobject("roregistry")
section=createobject("roregistrysection",secname)
return section.read(keyname)
end function
function writereg(secname as string, keyname as string, keyvalue as string) as boolean
registry=createobject("roregistry")
section=createobject("roregistrysection",secname)
section.write(keyname,keyvalue)
end function
function deletekey(secname as string,keyname as string) as boolean
registry=createobject("roregistry")
section=createobject("roregistrysection",secname)
return section.delete(keyname)
end function
function deleteSection(secname as string) as boolean
registry=createobject("roregistry")
return registry.delete(secname)
end function
function regflush()
registry=createobject("roregistry")
registry.flush()
end function