MWorks: constant variables?

Hi Chris -

Question - is there a way to make a variable constant in MWorks so its value is set at e.g. parse time and can’t be changed? This isn’t a huge issue but it would allow some code to be slightly more robust.

Thanks
Mark

Hi Mark,

This isn’t supported currently, but similar functionality has been requested before. It does seem like it would be useful. We should think about it more after the 0.5 release.

Cheers,
Chris

Hi Chris,

I read the other discussion, thanks. Yes, for my purposes what is proposed is very similar to what I’d use it for.
The value doesn’t need to be saved to the persistent variables XML, and it doesn’t need to be displayed in the variables window. I’d only need to set the value at experiment load time (parse time). However I’d want to be able to query the value from the Python or Matlab bridge. (If it’s not a proper variable, it wouldn’t be hard for me to parse the text files from those languages, but perhaps an include file feature would be best in this case, or else provide a function in each language to query the parsed output at runtime.)
I’ll defer to you and Dave as to the best way implement it.

As I said it’s medium-low priority for me.

Thanks
Mark

One more question:
I’ve seen a variable attribute: editable=“never”. Does this do what I
think it does?

Hi Mark,

I’ve seen a variable attribute: editable=“never”. Does this do what I think it does?

As far as I can tell, the “editable” attribute has no effect whatsoever on when a variable can be edited. Its value is parsed and stored in the variable’s VariableProperties instance, but after that it’s ignored. It may be a relic from previous versions of the software, or perhaps it was a planned feature that was never implemented; I imagine Dave would know.

In any case, since the attribute already exists, we could potentially use it when implementing constant variables in the future. Thanks for pointing it out.

Chris