How to set dynamic variable names?
Posted: 20 Apr 2016 18:09
Hi there!
Please enlighten me as to how to set a variable name containing another variable (whose value keeps on changing)?
What I am trying to do is store all the incoming messages (received between a certain time frame) into different variables and I want to name these variables incrementally as "inc_msg_1" (for the first msg received during the time frame), "inc_msg_2" (for the second msg) and so on.
For achieving this, I want to first create a variable, "i" which shall be assigned the value zero and then I'll increment this variable as "i=i+1". Now for the variables that'll store the incomng msgs, I wish to create a single variable named "inc_msg_i". The problem is that the "i" in "inc_msg_i" does not get treated as an already declared variable and therefore, I am unable to get self-incrementing variable names i.e. inc_msg_1, inc_msg_2, .....
Kindly help.
Please enlighten me as to how to set a variable name containing another variable (whose value keeps on changing)?
What I am trying to do is store all the incoming messages (received between a certain time frame) into different variables and I want to name these variables incrementally as "inc_msg_1" (for the first msg received during the time frame), "inc_msg_2" (for the second msg) and so on.
For achieving this, I want to first create a variable, "i" which shall be assigned the value zero and then I'll increment this variable as "i=i+1". Now for the variables that'll store the incomng msgs, I wish to create a single variable named "inc_msg_i". The problem is that the "i" in "inc_msg_i" does not get treated as an already declared variable and therefore, I am unable to get self-incrementing variable names i.e. inc_msg_1, inc_msg_2, .....
Kindly help.