Referring to inputs which are constructed of several fields (including answer by Vaclav Pech)

How can we reference and use inputs which are constructed of several fields?
e.g. in the Calculator tutorial the inputs have one field (name).
What if we need to have inputs which have several fields, of various types (string, integer and even complex types e.g. an address type which in itself contains strings and integers)?
How can we reference each such field of the different inputs?

I've created an Address concept (with properties such as "city", "street" and "zip code") and I've also created other concepts which specify that Address concept in their "children" section.
My question is how to access those fields from other concepts.
Suppose I want to enable the user to write some input data (which includes Address data) and then I want the user to be able to add some "logic" and that "logic" result depends on the values of the "zip code"
e.g.

input      person_name_1      city_1         street_1       zip_code_123
input      person_name_2      city_2         street_2       zip_code_456
input      person_name_3      city_3         street_3       zip_code_123
input      person_name_4      city_4         street_4       zip_code_123

check_presence  zip_code_123  > 2

This "check_ presence" should get 2 values (the value to check: "zip_code_123" and a limit value: "2"). The "zip code" property value of each of the inputs should be checked (and a counter raised if there is a match), and if the counter value is more than the limit value ("2" in our case) then some Boolean property should be set to "true" (or a dialog box should appear with a message to the user).

Answer (by Vaclav Pech):
For this you’ll have to define your own reference to an input field or a zip code, which would extend the Expression from BaseLanguage. Although we do not have yet an example that would cover this case, you can still follow the Calculator sample (the InputFieldReference concept) to get some ideas.
I’ve elaborated a bit on your question regarding referring to addresses from within validation expressions. I’ve attempted to create generic guide-lines on how extend the DotExpression with references to your own concepts. You may check it out at https://confluence.jetbrains.com/display/MPSD32/Common+language+patterns#Commonlanguagepatterns-ExtendingtheDotExpressionforyourownreferences

Please sign in to leave a comment.