MWorks: constant variables?

Mark Histed's Avatar

Mark Histed

20 Jul, 2012 05:36 PM

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

  1. Support Staff 1 Posted by Christopher Sta... on 20 Jul, 2012 06:12 PM

    Christopher Stawarz's Avatar

    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

  2. 2 Posted by mhisted on 20 Jul, 2012 06:49 PM

    mhisted's Avatar

    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

  3. 3 Posted by Mark Histed on 20 Jul, 2012 07:07 PM

    Mark Histed's Avatar

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

  4. Support Staff 4 Posted by Christopher Sta... on 23 Jul, 2012 03:41 PM

    Christopher Stawarz's Avatar

    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

  5. Christopher Stawarz closed this discussion on 16 Aug, 2012 05:49 PM.

  6. Christopher Stawarz closed this discussion on 11 Sep, 2017 02:55 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac