MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - disposing of generated rt variables
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

disposing of generated rt variables

 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: disposing of generated rt variables
    Posted: 12.Oct.2016 at 21:21
Hi,

Following the example in (https://www.metacase.com/support/51/manuals/mwb/Mw-5_2_8.html), i generated associative runtime variables -- to indicate which elements i have already visited

variable 'eoid_' oid write 'visited' close

I defined the variable as global since this information is generated in a subreport and is needed upon return to a main report. 

Once the main report, which itself is a subreport, completed its job, i want to dispose of all variables, so, if the main report is called again, a new sleight of eoid_'s are generated. Is there a way to do that

thank you,

Daniel
Back to Top
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 Posted: 12.Oct.2016 at 21:27
in the meantime i solved the problem by making every generated variable a conceptual entity that is generated (e.g. if i generate a subclass relation then the variable name is the child and parent and an indicator for subclass) -- like this i am building up a variable based representation of the model that can then be associatively queried. 

i dont know how expensive this is, and i would prefer keeping variable generation small sized, so better if i can only temporarily generate small chunks of the model and then dispose of it, when not needed anymore.
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: 12.Oct.2016 at 22:43
There's no operation to dispose of a global variable - but also virtually no cost associated with them. Premature optimization is the root of all kinds of evil :). It's best to aim for a generator that is understandable by someone else without too much work. For code generation, there's virtually never a problem of speed. 

To collect a 'visited' list, the easiest way is the __Unique() generator. Using it is as simple as:
if __Unique() then /* handle the object */ endif
By default, it checks for uniqueness of id per type, i.e. the first time you meet an object Foo of type Bar, it will be handled, but if you meet that same object (or another of type Bar also called Foo) again, it will be ignored. Internally it simply concatenates the id's to a newline-separated stream in a variable named after the type. It takes two optional parameters, which default to __Unique(type, id). If you want names to be unique across all types, you can make the first parameter a fixed string, e.g.  __Unique('MyList'). If you want to check for uniqueness based on oid rather than string comparison of names, supply that as a second parameter: __Unique(type, oid). The first parameter thus determines the name of the variable where this object is collected, and the second its string representation to add to that variable, and that you want to be unique there.

There's not generally a need to duplicate the model in variables. You already have the model there, so you can simply use that. Of course I don't know exactly what you're doing, but in most cases where this is seen, people are trying to turn the model into string variables, and then use MERL as a 3GL to navigate in it. MERL is much better at querying models than string variables: not only do you save a whole phase of converting the model into string variables, you also get to write "do ~Parent.() {:Name}" rather than: "variable 'name' variable 'class' variable 'parent' oid read read read".
Back to Top
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 Posted: 12.Oct.2016 at 23:09
thank you. 

Since there is more than one way in a model to describe a relation across objects, i need to check which were already visited/generated. These are usually a combination of at least two objects and their relationship between them, so checking for individual object uniqueness is not sufficient. 

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: 12.Oct.2016 at 23:24
OK, I understand. I remember the frustration of having to check for attribute, aggregation or association all the time in the Web App Example :). Sounds like you might also be facing the downside of a UML-like approach, where information is spread over several graphs, with no way to say that "this is where this Class is defined" as opposed to "here I'm just referencing this Class". There are a variety of ways of improving that, but they're pretty standard conceptual modeling.

You can use __Unique fine with 'compound keys' by building them up like this:
__Unique('subclass', $parentClassOid '_' $subClassOid)
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.037 seconds.