MWorks list variables and logic

Hi Chris,

So there is a bit of an issue if the user wants to have a list variable within MWorks and use that variable to control logic (For example, defining x = [1 2 3] and then asking x == 1 would return false rather than [1 0 0]). At present, the user would have to hard code a check for each item (x[1] == 1, x[2] == 1, etc.), which would easily break if the user changed the number of items in the list. That said, I’m not sure if we should ask you to fix this within MWorks… To do anything but a piecemeal fix based on what behavior an individual user might want, you’ll essentially have to provide a set of tools similar to what C++, Python or Matlab have for dealing with logic and arrays. Would it be better to rely on the embedded Python functionality to handle this sort of problem?

Thanks,
Seth

Hi Seth,

I think the right solution here is to add the equivalent of Python’s “in” operator to the MWorks expression grammar. Then, if x were an MWorks variable containing the list [1,2,3], the expression 1 in x would evaluation to true, while 4 in x would be false. I’ll add this to the to-do list.

Cheers,
Chris