MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Warning due no presence of attribute
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Warning due no presence of attribute

 Post Reply Post Reply
Author
Message
cmorais View Drop Down
Member
Member
Avatar

Joined: 23.Mar.2018
Location: Ireland
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cmorais Quote  Post ReplyReply Direct Link To This Post Topic: Warning due no presence of attribute
    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


Edited by cmorais - 26.Jul.2018 at 10:51
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 552
Post Options Post Options   Thanks (1) Thanks(1)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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 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
Back to Top
cmorais View Drop Down
Member
Member
Avatar

Joined: 23.Mar.2018
Location: Ireland
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cmorais Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.16
Copyright ©2001-2013 Web Wiz Ltd.

This page was generated in 0.078 seconds.