Warning due no presence of attribute |
Post Reply |
Author | ||
cmorais
Contributor Joined: 23.Mar.2018 Location: Ireland Points: 12 |
Post Options
Thanks(0)
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 |
||
stevek
MetaCase Joined: 11.Mar.2008 Points: 641 |
Post Options
Thanks(1)
|
|
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.:
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:
|
||
cmorais
Contributor Joined: 23.Mar.2018 Location: Ireland Points: 12 |
Post Options
Thanks(0)
|
|
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).
|
||
Post Reply | |
Tweet |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |