Nested dereferencing of dicts and declaring trigger variables from dicts

Hi Louis,

Just to be clear, neither of your issues has anything to do with MWEL vs. XML.

// This works:
queue_temp = fixation_points[stim_fix_id]['stim_fix_id']
queue_stimulus(stim_fix[queue_temp])
// This does not:
//queue_stimulus(stim_fix[fixation_points[stim_fix_id]['stim_fix_id']])

This issue here is that stimulus groups (e.g. stim_fix) are not related in any way to dictionaries (e.g. fixation_points[stim_fix_id]). They are parsed (after conversion from MWEL to XML) using completely different code. Unfortunately, the code for parsing stimulus group expressions is a little dumb, and it’s getting confused by all the additional square brackets in the indexing expression. I’ve opened an issue to correct this. In the meantime, your current workaround looks good.

trigger_flag = trigger_correct // <-this works, but this does not work (or at least the variable stays unchanged on expected trigger): fixation_points[STIM_CORRECT][‘trigger’]

The problem here is that trigger_flag must be the name of a variable. This is true for any component parameter that has values assigned to it. While you can technically use an arbitrary expression, anything other than a plain variable name won’t be writable, which is why the trigger isn’t being set.

I see the logic in what you were trying to do, but, sadly, it just doesn’t work. I also don’t see a way to change this, short of a drastic reworking of MWorks’ basic handling of variables and expressions.

As far as I understand how most parameters work, they are not assigned by value but by reference. Hence, you can change the value in the variable somewhere else, and it also gets updated across all components.

It really depends on the component. In general (but not always), input-only parameters are stored as unevaluated expressions, and the component can evaluate and re-evaluate them as needed. Output parameters, on the other hand, can’t be anything other than a variable name, as I noted above. It’s all rather frustrating and inconsistent, but there’s not a lot to be done about it at this point, short of some very major revisions to a lot of basic functionality.

Cheers,
Chris