getting the property from the node of a Loop - Generator

Hello,

I'm new to MPS and try to create a simple generator for Xml files: so my code looks like this inside the protocolXml in the Generator:

...

$LOOP$ [ <nested-form id=" " form-file=" "  binding=" * ">

<constraints>

<grid row=" $[rowInput]" column="0" ... ></grid>

</constraint>

</nested-form>]

...

the structure looks like this:
the protocol (concept) has n protocolPartNames (concept) children
and each protocolPartName has a string property called nameValue


now where the * (inside the code) is i want to enter a string: "Protocol" + node.nameValue + "Gui"

the node should be the one i'm iterating over (ProtocolPartName) and it should be the current one from the loop.

how can i solve this? i tried different things but wasn't able to get the property

i'm grateful for any help :)

Edit:
the property nameValue is delted now, instead the concept implements the INanedConcept of MPS, so now i have to get the name of the current node

0
8 comments

Hi Selina,

I think you just need to put the cursor on the *, press Alt+Enter, then choose "Add property macro". This will attach a property macro to the property and you will be able to enter your code in the inspector.

0

Hello,
first of all, thanks for your answer:
sadly that doesn't work since the menu doesn't provide a Property macro.
maybe because i already use a rpoperty macro inside the loop later? 
 i will update the code example

Edit: also i deleted the property and made the concept implements the INamedConcept from MPS, so now i just need to get the name of the node

0

Please post a screenshot of your code and the menu, otherwise it's difficult to tell what the problem is.

0

Good morning,
here are the screenshots from my project.
thank you for taking the time and trying to help me :)


the xml-generator-file:



here is the structure:
The concept ProtokollPartName implements INamedConcept (from MPS)

0

Ok so if I understood you properly, you want to add a property macro for the value of the binding attribute. To do that, you need to put your cursor inside the quote marks in binding: binding="|" (the vertical bar indicates where you should put the cursor). There you should be able to add a property macro to compute the attribute value.

The property macro defined for the row attribute doesn't prevent you from defining another one for a different attribute.

The node inside the macro body will be the current node from the loop.

0

thank you, so it's like thought, but as shown in the first picture if I put the cursor there and press option+enter (to open the intention menu) there are only the shown possibilities.
but i will try again, maybe i did somewhere something wrong 

0

Hmm now I see that’s exactly what you were doing. Well, the only thing I can think of is to write something into the attribute value, perhaps the option will appear then.

0

yes... that was exactly what i needed to do :D 
thank you so much :)

0

Please sign in to leave a comment.