Hello,
I have searched the forum and looked at the documentation, but I cannot find what I am looking for. I need a way to reference a list when the name of the list is held in another list of strings. Hopefully, I can show what I want more precisely with some code. With this code I am trying to save the list called list1 but the name for list1 is stored in the variable listname.
So in the writelist line I need to replace "list1" with the name inside the listname string. This is where I need help. I am not sure how to reference the list from a string variable.
This may be simple but I cannot figure i out.
Thanks Dan,
I have searched the forum and looked at the documentation, but I cannot find what I am looking for. I need a way to reference a list when the name of the list is held in another list of strings. Hopefully, I can show what I want more precisely with some code. With this code I am trying to save the list called list1 but the name for list1 is stored in the variable listname.
B4X:
sub globals
dim topiclist as list
dim list1, list2 as list
dim listname, text1, text2 as string
end sub
sub body
text1="first"
text2="second"
list1.initialize
list1.add(text1)
list2.initialize
list2.add(text2)
topiclist.initialize
topiclist.add("list1")
topiclist.add("list2")
listname=topiclist.get(0)
writelist(file.dirRootExternal,listname&".txt",list1)
end sub
This may be simple but I cannot figure i out.
Thanks Dan,