MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - How can I set value for the property ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How can I set value for the property ?

 Post Reply Post Reply Page  12>
Author
Message
Jiarui View Drop Down
Contributor
Contributor
Avatar

Joined: 17.May.2013
Location: China
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jiarui Quote  Post ReplyReply Direct Link To This Post Topic: How can I set value for the property ?
    Posted: 20.May.2013 at 06:14
Hello, I have studied MetaEdit+ for months, and I like it very much! I want to know that can I set  value for the property of the object or role in the generator? If can, how? Thank you very much!
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: 20.May.2013 at 11:43

Hi Jiarui,

Glad you like MetaEdit+! The generators are intended for read-only access to the models, so there aren't commands to set properties, add objects to a graph, etc. Instead you can use the API, which gives you full create, read, update and delete access to models and their representations. You can either have your API program running all the time with its own UI, from which you run the operations on MetaEdit+, or then invoke your API program with "external...execute" from a MetaEdit+ generator.

Since it sounds like you want to set a property value based on information already available elsewhere in the model, there may also be an alternative strategy. Since that property doesn't add any information that can't already be calculated from elsewhere, you may not need it: remember DRY. If it's something you want to be visible in the diagrams, then rather than storing a calculated value, you can simply calculate the value as needed when displaying. You can do this in a text element in a symbol, setting its source to a generator. Top-most on the generator stack is the object, and below that is the graph, so you can access not only the properties of this object, but also navigate in the graph - and with "do graphs", also to any other graph.
Back to Top
sinnom View Drop Down
Member
Member


Joined: 24.May.2013
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote sinnom Quote  Post ReplyReply Direct Link To This Post Posted: 24.May.2013 at 15:51
Hello,
I have a similar issue where I want to use an id generator to derive the id of a graph which is used as a property in an object from the name of this object and the graph containg the element. However, employing the "do graphs" command fails with "*Error* Generator took too long..." even in the simplest use cases ("do graphs { type ' ' }"). Are there restrictions concerning these kinds of loops in id generators?
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: 24.May.2013 at 17:01
Hi sinnom,

You've unknowingly made an infinite recursion: your graph is trying to find its name, which is calling its id generator, which is executing "do graphs", which tries to sort the graphs by type then name, which asks the name of your graph...

You could change the sorting of do graphs to something explicit that doesn't ask its id, e.g. "do graphs orderby type". You might also want to avoid searching unnecessary graphs by restricting on type, "do graphs where type='MyGraphType' orderby type". [Edit: these don't help in 5.0, since "graphs" is already sorted, and only then are its results passed to "do...where...orderby"]

However, I think you ought to consider giving the graph a name. Think of it like a function: your top-level object is a call to a function, and the definition of the function is the graph. I'd say that the definition is primary. If the top-level objects should always have a subgraph, you can make their id generator show the name of that graph. If not, you can use property sharing to make the name of the subgraph be the same as the name of the top-level object. Or you can let the top-level object have an independent name: e.g. you could have a graph "Alarm", which is the subgraph of two top-level objects "Alarm1" and "Alarm2".

Edited by stevek - 31.May.2013 at 12:57
Back to Top
cwb38 View Drop Down
Member
Member


Joined: 29.May.2013
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote cwb38 Quote  Post ReplyReply Direct Link To This Post Posted: 29.May.2013 at 16:08
Hi stevek,

your suggestion using the custom sorting on types for the "do graphs" loop does not seem to work: The same error message is displayed after a brief period of time - even when the type is limited via "where type = 'X'".

Incidentally, how would one create a shared property in MetaEdit+?

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: 29.May.2013 at 23:38

Perhaps you have something inside the loop body that's causing the infinite recursion, e.g. id? If the loop body is completely empty, do you still get the timeout message?

To create a shared property, open the pop-up menu in its field in the property dialog and choose Share Property. It will offer you a list of all instances of that property type, showing how many times each is already reused. For more detail you can go to www.metacase.com/support/50/manuals/ and search for Share Property - the first two hits should tell you everything you need to know.

Back to Top
epc View Drop Down
Member
Member


Joined: 31.May.2013
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote epc Quote  Post ReplyReply Direct Link To This Post Posted: 31.May.2013 at 13:08
Thank you for your support!

Unfortunately even a basic generator code like "do graphs where type='Composition' orderby type { 'executing generator' }" causes an infinite loop.
Furthermore, I am unable to find the "Share Property" option in MetaEdit+ - does "Open a property dialog for an object" refer to opening an object in the object tool and accessing its properties list?

A problem concerning this forum: It seems like that after doing one post, the second time the error message "You do not have permission to reply to posts in this forum" pops up, so I am the third member of our team that has to create an account to reply to your answers.
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: 31.May.2013 at 13:12
Correction: adding "where" or "orderby" to "do graphs" in a graph type's identifier generator won't help avoid infinite recursion, since "graphs" is already sorted by id, and only then are its results passed to "do...where...orderby" for possible further filtering and sorting. You should also note that in the event of two elements comparing the same on all orderby clauses, the default MetaEdit+ sorting (type, id, oid) will be used as a tiebreaker, to guarantee consistent ordering in generator output.

We'll see if we can work some magic in a future version so that "graphs" notices it's being called by a "do...orderby", and avoids doing its own default sorting. But in any case, using "do graphs" in an identifier generator is never going to be best practice - MERL may be fast, but nothing can save you from an algorithmic complexity of O((n^2)*(log n)). An identifier should be based on something the object itself knows, not having to ask every other graph in the system.

Edited by stevek - 31.May.2013 at 17:50
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: 31.May.2013 at 13:33
Originally posted by epc epc wrote:

Furthermore, I am unable to find the "Share Property" option in MetaEdit+ - does "Open a property dialog for an object" refer to opening an object in the object tool and accessing its properties list?

No, the property dialog is for instances. Please see my post above and its link to the manual for more detail.

Originally posted by epc epc wrote:

A problem concerning this forum: It seems like that after doing one post, the second time the error message "You do not have permission to reply to posts in this forum" pops up, so I am the third member of our team that has to create an account to reply to your answers.

Sorry, that was human error by our moderators. I've corrected it, emailed those affected, and reminded our moderators of the correct process.
Back to Top
Jiarui View Drop Down
Contributor
Contributor
Avatar

Joined: 17.May.2013
Location: China
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jiarui Quote  Post ReplyReply Direct Link To This Post Posted: 05.Jun.2013 at 05:18
Thank you very much for your answer. I have a question about the generator: the idea of the generator is to navigate and extract information from models, and I want to know that when navigating, wo often use foreach.() coupled with ~From~To etc, I want to navigate according to a rule, foe example, Depth-first traverse, so I need to have a flag which can control if the element is visited, if visited, the flag is true, else is false, now I cannot set vaule to the flag in the generator, and I want to know is there any other way todo so ? Yhank you very much!


Back to Top
 Post Reply Post Reply Page  12>

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.068 seconds.