Skip to main content
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

Uniface 9: define trigger on entity level

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

20 replies

Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Hi Ingo, Gerton and Knut, so all we have to do is to put our relevant local modifications in front of the modeled one for the compile. So each relevant modeled trigger starts with: #include locals_<$entname>_<$triggerabbr> And in this include proc, we can add our local modifications as #if <$componentname> = MYCPT1 #define DOSOMETHING #endif Perhaps you can give it a try in a real-world context, Uli


Author: ulrich-merkel (ulrichmerkel@web.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Ingo, I might have misunderstood the issue, but; I've had #include inside of another #include - with compile time constants wrapped in and around the content of the #include - thus I only ended up with it being included once.. It gets kinda messy, but it solved the issue you described (I believe). Knut


Author: Knut (knut.dybendahl@gmail.com)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Hi Gerton ThanX for the long answer All what you did say is what I thought too about the logic behind the curtain :-) The "problem" here is, that I want to define some precompiler constants in DEFE-trigger on component level AND want to react to this by the an include in this trigger. E.g depending on the kind of an entity (declared by #define CLL_TYP=xyz in DEFE) , some other constants should be definend in the include of DEFE and in ECOP-trigger proccode should be manipulated. So it is essential, that DEFE be will resolved in a "proper way" before ECOP. And as lessens learnded in C/C++, an include should be guarded against include twice But with DEFE in UnifAce, the guard will turn to a devil, as the #defines in DEFE will not proper checked :-) So the questions are a) Will the sequence for one entity always  DEFE(model)->DEFE(component)->ECOP ? b) Is there any way to check, if I am on model or component level? c) Is there a way to check, if or if not a DEFE(component) will follow? Explanation Currently I did guard the include by two guard-statements. A third time, this include will "fail" But I have to do consider both time the included, as I don't know wether the second -component DEFE- will be resolved or not. The precompiler code in question is now stable againts this double resolve, but the listing looks awful :) TIA Ingo


Author: istiller (i2stiller@gmx.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Hi Ingo, this a bit tricky to explain, but I will give it a try. In Uniface 9, in context of inheritance, we need to make a distinction between two types of triggers: 1. triggers that perform container-base inheritance: meaning the complete content of the modeled-level trigger is overwritten by the local/component-level trigger if there is any data in that local/component-level trigger. Triggers of this type are all Standard Triggers (read, write, etc.) and Local Proc Modules (basically all OLD triggers - pre Uniface 7) 2. triggers that perform inheritance per Proc Module (trigger/entry/operation): both the content of the modeled-level and the local-level trigger are concatenated and in case of duplicate definitions, the last one wins. Triggers of this type are the Defines, Extended Triggers, and Operations triggers (all new triggers, introduced in Uniface 7). The problem is in the UDE. The UDE shows a kind of code pre-view and does this as if the trigger is of type 1, which is fine for all triggers that are of type 1, but very misleading for triggers of type 2 where it sim ply gives the wrong impression. An example: You have some code in the Defines trigger at modeled-level. In the Component Editor, you see that inherited code because there is no local code in the trigger (yet). This is fine as and very useful as long as you don't add any local code. But what happens if you start changing the code that you see (but not is)? A copy of that code is made to local-level and your changes are applied. Now, for the type-1 triggers this is fine, because the modeled code is no longer inherited, but for the type 2 triggers this is not fine, because (as stated above) you now have a some modeled code AND some local code. It does not have to be a problem, but could be, depending on what you do. (This is an old bug (as of Uniface 7), and before you ask, we tried to solve it once and simply received too much complains about the fix that we decided to roll the fix backCry) So back to your problem. What you see is correct: your #include is process twice because it is actually defined twice: at modeled-level AND at component/local level. To avoid this situation is not to change the inherited code that you see in the Defines trigger at component level, but to first complete clear that trigger and ONLY put your local code in there. The inherited code WILL get inherited at compile time, even if you do not see it in the UDE. So for type-2 triggers, why do we compile the modeled code also? That has to do with the inheritance type, we want to inherit per Proc module declaration, but to get the declarations, we need to compile first. Module declaration might get included (#include), get generated (#for), or conditionally declared (#if), or even undeclared (#undeclare). So we MUST compile first, and then resolve inheritance. I hope this explains it and allows you to figure out what to do. If not, reply some more. Regards, Gerton (Software Architect Uniface Lab)


Author: Gerton Leijdekker (gerton.leijdekker@uniface.com)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

gianni said Ingo I hope you talk to someone in between your 3 posts... while reading them from far away, it seems you are talking to yourself! :-) :-) :-) Just smile...you're on candid camera! Gianni  

Hi Gianni All my colleagues are on vacation Cool But maybe out there, some will read my posts. Increase: UnifAce will read it And -fingers crossed - UnifAce will answer or fix the problem Wink Ingo


Author: istiller (i2stiller@gmx.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Ingo I hope you talk to someone in between your 3 posts... while reading them from far away, it seems you are talking to yourself! :-) :-) :-) Just smile...you're on candid camera! Gianni


Author: gianni (gianni.sandigliano@unifacesolutions.com)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

"Nice" inheritance Confused In each define-trigger for groups on model level (TPLACTUAL.UCGROUP) write an #include into the trigger  #include STD_DEFE Create a componente and put some #defines before the include into the define trigger (TPLACTUAL.UXGROUP)   #define DOSOMETHING   #include STD_DEFE How often will STD_DEFE excuted on compilation? Not not once but twice If the include start with an guard like:  #ifundefined STD_DEFE_GUARD   #define STD_DEFE_GUARD   #ifdefined DOSOMETHING     #info somethingtodo   #endif #endif what is the result? Yes, you guess it. #info will never reached Why? On first round, UnifACe includes the modell define-trigger: Guard is therefore armed Second step, the component define-trigger is "executed". But as the guard is armed .... So one need a two step guard to get this one to run. And as in documentation there is no hint about inheritance and the sequence of resolving the triggers, I do not trust UnifAce that model is always for component. As an consequence, the include will be executed two times. @UnifAce: a) Is there any way to stop UnifAce from resolving two times? b) is there and precompiler constant to check, if I am on model or component level? Ingo


Author: istiller (i2stiller@gmx.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

So, I got a "solution" I do a define in DEFE: #define ENTITY_TYPE=XYZ In ECOP I did already have a operation returning some useful information about the entity/collection. In this operation do some "magic" with precompiler statements to set the return parameter. After this I do a #undefine ENTITY_TYPE to be sure, that no other ECOP catch this definition. Now I can call the ECOP-operation from every globale proc to check, on which entity type I'm working. To avoid a call to this operation, I could store the information at first call in $entityproperties, but this will sometimes crash ... Let's hope, that the sequence of compiling will not change @UnifAce A little more Reflection would be nice :-)   Ingo


Author: istiller (i2stiller@gmx.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Okay, it is getting quirky. I did a small test that shows how the pre-compiler runs through the code and handles #defines: I created a modeled entity and a component that uses that modeled entity, with the following code:

  Modeled Entity Component Entity
Defines (DEFE)
#define myColor = WHITE #warning ModeledEntity/DEFE: ‹myColor›
#warning ComponentEntity/DEFE: ‹myColor›
Collection Operations (ECOP)
#warning ModeledEntity/ECOP(1): ‹myColor› #define myColor = YELLOW #warning ModeledEntity/ECOP(2): ‹myColor›
#warning ComponentEntity/ECOP: ‹myColor›

When compiling I get the following result: (2\\DEFE) warning: 1000 - ModeledEntity/DEFE: WHITE (2\\DEFE) warning: 1000 - ComponentEntity/DEFE: WHITE (2\\ECOP) warning: 1000 - ModeledEntity/ECOP(1): WHITE (2\\ECOP) warning: 1000 - ModeledEntity/ECOP(2): YELLOW (2\\ECOP) warning: 1000 - ComponentEntity/ECOP: WHITE What we see here is that: - all 4 triggers get pre-compiled, as expected for a type 2 trigger (see my explanation above), because we get all 5 warnings (try doing the same with a type-1 trigger like read) - e.g. the order of compilation is: ModeledEntity/DEFE --> ComponentEntity/DEFE -> ModeledEntity/ECOP --> ComponentEntity/ECOP. So, compilation is handled per trigger includes trigger inheritance, before doing the next trigger. - because of the scope of #defines in DEFE, all #defines defined in DEFE are available in other triggers as well - because of the scope of #defines in triggers other then DEFE, any #defines are ONLY available in that trigger. So the redefinition of #define in the ModeledEntity/ECOP to YELLOW is only available in the modeled ECOP and does NOT get inherited! So, what you're trying to do, being a #define in a modeled level trigger other then DEFE will NOT get inherited. If used to check a condition, that same condition will result in something else at component level.


Author: Gerton Leijdekker (gerton.leijdekker@uniface.com)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:39 AM UTC

define trigger on entity level

Author: i2stiller@gmx.de (istiller)

Hi freaks Did anyone of you use the define trigger on entity level? I just did so and got a strange listing (9.7.04)

Trigger <DEFE> from Entity: TABLE.MODEL [ 1] #define ENTITY_TYPE=XYZ ... Trigger <DEFE> from Entity: FIELD.MODEL [ 1] #define ENTITY_TYPE=XYZ Trigger <DTLF> from Field: FIELD.TABLE.MODEL ...

What the ... is this defintion for entity FIELD.MODEL? BTW: And, this defines are not local to the entity :-(   Background: We do have different 'types' of entities in a component, like visible entities or auxiliary entities. I looking for a simple way to tell the globale procs (for read or write or ...) which kind of entity it is. For the whole component, this could be done by the DEFINE-trigger and some coding in a general INIT-Operation. But how to do this for entities?  a) the DEFE trigger should do what it have to do. And this local to the entity  b) I need some kind of INIT for the entity (collection) Any ideas? BTW: This should not interference the rest of the code, as my colleagues don't like to change there code or see changed code :-) Ingo

Hi Gerton, as I understand, the whole process you explained runs with the motto "the last definition overwrites the previous one". So you compile the modeled ones before the local ones, but precompiler guards do not follow this rule. And if one wants a variation to win you have to code it AFTER the modeled one, he has to touch the entities code, what means these variations are scattered in a lot of different places.   Let's assume we change the motto to "the first definition blocks the following ones": Local variation is compiled BEFORE the modeled one so precompiler guards are working as expected. AND to make coders and readers life easier: one can even code all variations of entity modeled procs in the Local Proc Module of the component without any protection. Wouldn't this be an option which respects type 1 and type 2 and the #define logics as well?


Author: ulrich-merkel (ulrichmerkel@web.de)