MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - typeOf(>Relation.First.()) ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

typeOf(>Relation.First.()) ?

 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: typeOf(>Relation.First.()) ?
    Posted: 13.Oct.2016 at 07:28
Hi, 

is there a way to identify in a navigation expression what the type of the target object is?

I know that there is the type keyword, but this doesn't seem applicable when using navigation expressions.

thank you,

Daniel

Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 641
Answer Answer
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 13.Oct.2016 at 09:44
You can condense mutiple navigation steps into a navigation chain, with filtering by type at each step:
do >RelationshipType~RoleType.ObjectType {...}
You can use more complex type filtering: wildcards, or multiple acceptable types in parentheses, separated by |. If you want any type, just put an empty pair of parentheses:
do >(FirstRelationshipType | OtherRelationshipType)~Rol*Type.() {...}
You can skip parts you don't need to filter on, e.g. if you're in an object, go to any connected ObjectType instance regardless of relationship or role type:
do .ObjectType {...}
If you need to filter more, you can use a where clause to add a condition:
do ~FirstRole~OtherRole; where :Kind = 'Important' 
{  do .ObjectType; where __Unique() {}
}
If you want just the first occurrence, you can use unique. Normally that is used to handle a particular case just once, e.g. 
foreach .Class; unique :Library { 'include #"' :Library '"' newline }
Since it prevents duplicates occurring in this loop for its argument, in this case :Library, you can give it a fixed string like '1' so everything after the first element will be a duplicate:
do ~Subclass~Parent.() unique '1' { 'extends' }
If you just want to test for something, you can simply use a navigation chain in an if statement:
if ~Subclass~Parent.() then ... endif
Note a few cases above where a type name is explicitly ended by a semicolon, e.g. "~OtherRole; where" - that's so MERL knows this is a type called "OtherRole", not "OtherRole where".


Edited by stevek - 13.Oct.2016 at 09:46
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.047 seconds.