I have various active objects named with a running index (i.e., 'item1', item2', ...) and create them randomly using 'create object by name'. Each has a alterable value with the same name (say, 'price')
If possible, I want to add the values of existing objects together in one expression.
What works is: NCount("item1")*price("item1")+NCount("item2")*pri ce("item2")+...
However, this requires me to maintain a long expression for each addition item type. Alternatively, I can create an event fore each type and add it to a global counter - but this also requires maintaining one event per new object type.
I was wondering whether there is a simpler way to do it.
I was hoping to do it using a fast loop, each iteration adding the following to a global counter: NCount("item"+Str$(LoopIndex("counter")))*price(it em"+Str$(LoopIndex("counter")))
However, this doesn't validate in the expression editor (it expects only actual strings pointing to actual objects).
Is it possible to do something like this?
Is there a better way to create 'similar but different' objects and do identical operations on them?