Hey @mattfox ,
Sorry, I am not allowed to share code here. Will try to explain what's going on though, hopefully you'll be able to understand. Not sure if this is the best approach but this is working atm.
Right now what happens is that I get a string, this is my context variable. This string first gets split into ID and data, then that ID is looked up in an object array, with an object for each location. According to where it's found it will determine which location corresponds to that ID, enters a switch, and fires a specific function for that location.
In that function, which is the same for each location and this is why there are so many lines, what happens first is that the specific values for that location are read from the variable names for that location, then stored in an object, then that object is sent to an evaluation function (this function is perfectly reused by all 20 locations) that analyzes them and returns more values, then those values are used to set the location's values using the specific variable names for that location.
I do have a scructure for variable names, so the only things I would need is the location's id and the id from the data, and from those two IDs I could construct the strings that would represent the variable names to read and set. I mean, I could already generate those strings, but what I don't know how to do is how to pass those strings to a function that reads and sets the variables (datapoints) named as the strings that I generated with those two IDs.
I hope I am being somewhat clear with my explanation.
Many thanks in advance!