MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - accessing properties of an Object Datatype
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

accessing properties of an Object Datatype

 Post Reply Post Reply
Author
Message
grossd18 View Drop Down
Major Contributor
Major Contributor


Joined: 30.Sep.2016
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote grossd18 Quote  Post ReplyReply Direct Link To This Post Topic: accessing properties of an Object Datatype
    Posted: 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
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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:
Quote The property command can be used as a direct output command, writing the value of the property to the current output stream. It can also be used as a condition in if statements. If the property data type is a NonProperty or a Collection, it can also be used as the argument to do or dowhile loops.
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 StartedPrimer 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:
do :Animation { _DoActionAnimation() }
So to get inside an object in a property, use do :PropName {}.


Edited by stevek - 06.Oct.2016 at 23:24
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.023 seconds.