This is a follow on from this question
My program is taking in a string that is comprised of two parts: a distance value and an id number respectively. I've split these up and stored them in local variables inside my program. All of the id numbers are stored in a dictionary and are used check the incoming distance value. Though I should note that each string that gets sent into my program from the device is passed along on a single string. The next time my program receives that a signal from a device, it overrides the previous data that was there before.
Should the id key coming into my program match one inside my dictionary, then a variable held next to my dictionaries key, should be updated. However, when I run my program, I don't get 6 different values, I only get the same value and they all update at the same time.
This is all the code I have written trying to do this:
Dictionary<string, string> myDictonary = new Dictionary<string, string>();
string Value1 = "";
string Value2 = "";
string Value3 = "";
string Value4 = "";
string Value5 = "";
string Value6 = "";
void Start()
{
myDictonary.Add("11111111", Value1);
myDictonary.Add("22222222", Value2);
myDictonary.Add("33333333", Value3);
myDictonary.Add("44444444", Value4);
myDictonary.Add("55555555", Value5);
myDictonary.Add("66666666", Value6);
}
private void AppendString(string message)
{
testMessage = message;
string[] messages = message.Split(',');
foreach(string w in messages)
{
if(!message.StartsWith(" "))
outputContent.text += w + "\n";
}
messageCount = "RSSI number " + messages[0];
uuidString = "UUID number " + messages[1];
if(myDictonary.ContainsKey(messages[1]))
{
Value1 = messageCount;
Value2 = messageCount;
Value3 = messageCount;
Value4 = messageCount;
Value5 = messageCount;
Value6 = messageCount;
}
}
How can I get it so that when programs recives the first key, for example 1111111, it only updates Value1?
The information that comes through can be dynamic, so I'd like to avoid harding as much information as I possibly can.