![]() |
accessing properties of an Object Datatype |
Post Reply
|
| Author | ||
grossd18
Major Contributor
Joined: 30.Sep.2016 Points: 22 |
Post Options
Thanks(0)
Quote Reply
Topic: accessing properties of an Object DatatypePosted: 06.Oct.2016 at 20:47 |
|
|
Hi
I have a model object defined, say, Person, which has one property defined with an object data type. E.g. an address property that refers to an Address object. In MERL i can access the Address object by indicating the name of the property in Person :address -- however, i want to access the properties of the Address object itself referred to, and cant figure out how to do this. For example, :address:Street or :address.():Street or the like -- but it doesnt work. Any suggestions would be much appreciated, Daniel
|
||
![]() |
||
stevek
MetaCase
Joined: 11.Mar.2008 Points: 643 |
Post Options
Thanks(0)
Quote Reply
Posted: 06.Oct.2016 at 23:15 |
|
|
Hi Daniel,
You probably want to try the MERL Primer, if you haven't already: that has an example of this on the second page. For a property containing an object or objects, you navigate into the object with do :PropName {}. Within the loop you are in the context of the object in the property, and so can access properties of it. In your case, do :Address { :Street }. You can find more about accessing properties in the first command in the MERL Reference, 6.1.1 Property:
More about the do loop can be found in 6.3.3 - 6.3.11: it's the workhorse of MetaEdit+ navigation. As well as the MERL Getting Started, Primer and Reference, a great way to get familiar with MERL is to work through some of the generators in the demo repository. Either pick a particular project that you know has generators, e.g. the Digital Watch or Mobile UI examples, or simply open them all. You can open a MERL Generator Editor from the main MetaEdit+ toolbar and press Ctrl+Shift+F to do an Advanced Find over all modeling languages, allowing you to find examples of how to use the various MERL commands. You can then run the generator, stepping through it with the MERL Generator Debugger, or by setting a Breakpoint at the part you're interested in and simply generating. If you're looking for an example of how to deal with a particular kind of model structure, and what MERL might offer for that, you can approach the problem from the other end: find a similar structure in the demo repository. E.g. if you wanted to find a property holding an object, you could open a Property Tool from the Metamodel menu, set its Filter to just Object, and press Open. The first two types found are in BPMN, which doesn't have a generator, but it's third time lucky with Animation, from the Turtle Graphics language. Use Advanced Find in a MERL Generator Editor to see where Animation is used, and you'll see _DoActionAnimation(), which accesses properties of the Animation object as if we are in it. But how did we get in it? Switch to the Hierarchical view of the generator list, and you can see that _DoActionAnimation() is called from _Python(). But where? From the pop-up menu, choose Show Call Context, and it will take you to the call site:
Edited by stevek - 06.Oct.2016 at 23:24 |
||
![]() |
||
Post Reply
|
|
| Tweet |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |