R Rajesh kannan MJ Member Licensed User Longtime User Nov 12, 2015 #1 Hi, I want to store 2 strings in a variable. and they should be array of values, For example, I want to store the following "Apple", "http://www.apple.com" "Google", "http://www.google.com/" Please suggest best way, Thank you,
Hi, I want to store 2 strings in a variable. and they should be array of values, For example, I want to store the following "Apple", "http://www.apple.com" "Google", "http://www.google.com/" Please suggest best way, Thank you,
derez Expert Licensed User Longtime User Nov 12, 2015 #2 There are several options, here are some: 1. Store a string with a comma separating the two values: dim var as string = "Apple,http://www.apple.com" , then use: dim str() as string = regex.split(",", var) the first string will be in str(0) and the second in str(1) 2. Define a type (in globals) - Type dblstring(name As String,link As String) dim var as dblstring and use var.name = "Apple" var.link = "http://www.apple.com" 3. Use my Keyvalues class which is a modification of KeyValueStore. https://www.b4x.com/android/forum/threads/keyvalues-extended-keyvaluestore.32553/ Upvote 0
There are several options, here are some: 1. Store a string with a comma separating the two values: dim var as string = "Apple,http://www.apple.com" , then use: dim str() as string = regex.split(",", var) the first string will be in str(0) and the second in str(1) 2. Define a type (in globals) - Type dblstring(name As String,link As String) dim var as dblstring and use var.name = "Apple" var.link = "http://www.apple.com" 3. Use my Keyvalues class which is a modification of KeyValueStore. https://www.b4x.com/android/forum/threads/keyvalues-extended-keyvaluestore.32553/
R Rajesh kannan MJ Member Licensed User Longtime User Nov 12, 2015 #3 @derez Thanks. I will try your ideas Upvote 0
R Rajesh kannan MJ Member Licensed User Longtime User Nov 12, 2015 #4 Is this kind of 2 dimensional array possible in b4a please Code: Copy $cars = array ( array("Volvo",22,18), array("BMW",15,13), array("Saab",5,2), array("Land Rover",17,15) ); Upvote 0
Is this kind of 2 dimensional array possible in b4a please Code: Copy $cars = array ( array("Volvo",22,18), array("BMW",15,13), array("Saab",5,2), array("Land Rover",17,15) );
J James Chamblin Active Member Licensed User Longtime User Nov 12, 2015 #5 Use maps Code: Copy Dim m As Map m.Initialize m.Put("Apple","http://www.apple.com") m.Put("Google","http://www.google.com") Log(m.Get("Apple")) Log(m.Get("Google")) Upvote 0
Use maps Code: Copy Dim m As Map m.Initialize m.Put("Apple","http://www.apple.com") m.Put("Google","http://www.google.com") Log(m.Get("Apple")) Log(m.Get("Google"))
R Rajesh kannan MJ Member Licensed User Longtime User Nov 12, 2015 #6 Wow, map seems great. Thanks @James Chamblin Upvote 0