Hi Chris,
Sorry for the torrent of questions lately…
I know you’ve added list support for the expression parser, but is it also possible to write to a list? In other words, can I initialize a list as “tmp = [0,0,0]”, and at some state edit this variable based on another (indexing variable), like “tmp[index] = 1”.
I tried this and got an error, so my guess is this is not currently implemented. I thought a not so elegant way around this would be a bunch of variables for each list entry, e.g. “tmp0 = 0; tmp1 = 0; tmp2 = 0;” and then write into them as “tmp${index} = 1” but this kind of string manipulation seems to also not yet be supported.
Am I correct that these kinds of list/string manipulations are not yet supported, or am I simply doing something wrong? just thought I’d check in with you before going to the ultimately uglier solution.
Thanks
Rishi
Hi Chris,
Please ignore this. I just realized you’ve added some functionality to run python code inside the mworks experiment, which is a great workaround for all of these kinds of issues. Thanks a lot for that, it’s a great feature.
Rishi
Hi Rishi,
Am I correct that these kinds of list/string manipulations are not yet supported, or am I simply doing something wrong?
You’re correct: Assignment to lists (and dictionaries) is not yet implemented, but it is on my to-do list.
I just realized you’ve added some functionality to run python code inside the mworks experiment, which is a great workaround for all of these kinds of issues.
Yes, that’s probably what I would have recommended, had you not thought of it first
Cheers,
Chris
Hi Rishi,
Assignment to indices/keys of list/dictionary-valued variables is now supported in the nightly build. For more info, see this discussion.
Cheers,
Chris