Hello - I developed custom code that writes to a set of tracked variables on a queue as labels. If the TVs and labels don't exist, then an if statement generates and initializes them. I tested the if statement and confirm it works as designed for a single queue. However, my model has many queues that must be tracked, so I've chosen to nest the if statement and iterate through a list (global table) of my TV names, so all labels will be generated automatically.
My issue: the if statement is not run. I set a breakpoint and checked line by line, and the first lines within the for loop work correctly, but the first line of the if returns the compiler to the first line within the for, and once the end of the counter is reached the loop is exited and the rest of the code continues. If anyone can put me on the right path I'd appreciate it! Code:
string qName = getname(current);
Object Queue = model().find(qName); for (int i = 1; i <= totalTVs; i++){ string tableVal = gettablestr("TVs",i,1); // get TV name from global table "TVs" if (model().find("/" + qName + ">labels/" + tableVal) == NULL) // execute if labels not found { treenode tv = labels(Queue).subnodes.assert(tableVal); // generate label, assert name TrackedVariable.init(tv, STAT_TYPE_LEVEL, 0, STAT_USE_HISTORY | STAT_USE_PROFILE | STAT_IGNORE_WARMUP); // generate TV as label settrackedvariable(tv, 0); // set initial value } }