Print Page | Close Window

Warning due no presence of attribute

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: http://www.metacase.com/forums/forum_posts.asp?TID=893
Printed Date: 19.Apr.2024 at 13:53
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Warning due no presence of attribute
Posted By: cmorais
Subject: Warning due no presence of attribute
Date Posted: 26.Jul.2018 at 10:49
Hello there!
I tried this while doing a report:
-----------------
do .()
                {
                    id;
                    newline;
                    if (:Sensor)
                    then
                        :Sensor;
                    endif
}
---------------------
But even so, I got this message:


I know that's a warning and not a error, but it is expected to behave like this? just checking...

Thanks,

Cleber M



Replies:
Posted By: stevek
Date Posted: 26.Jul.2018 at 11:09
Sure, that's expected behaviour. The warning is only shown when running from the Generator Editor, i.e. for the generator developer, not normal users. 

Note that you don't need parentheses around the condition. In fact, you don't need the condition at all: "if :Sensor; then :Sensor; endif" is identical to just ":Sensor;". (Note the semicolon to finish the name of the property, so MERL can distinguish between a longer property name like ":Sensor id;" and two commands like ":Sensor; id".)

As you progress with your generators, you'll often find it's better to write them per object type, rather than throw all object types at the same piece of code with "do .()" and then have to write lots of "if" statements to handle each differently. A http://www.metacase.com/support/55/manuals/mwb/Mw-6_7_3.html" rel="nofollow - common pattern is to make generators for those types that need to do something special, and then call them by the type name, e.g.:
do .()
{  id newline
   subreport '_extra_' type run
}
This would then do nothing for most types, since they wouldn't have their own _extra_* generator defined, but for Interaction (which has :Sensor) you could define:
_extra_Interaction()
'   ' :Sensor; newline


Posted By: cmorais
Date Posted: 26.Jul.2018 at 11:32
Hi, Steve!

Thanks for the response. I really found out that is better split per object type, even using widecards.

It's my first code using MERL, and it's a little different to what I am used... The main idea of the if is to avoid to check for a property that was not there (and get a warning).



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net