CREATE_LEVEL vs. LEVEL_EVENT
Pep_SD
Posts: 106
I've red a few posts around CREATE_LEVEL and LEVEL_EVENT...
There are still a few things unclear to me.
- If you use a LEVEL_EVENT, do you absolutely need to declare a CREATE_LEVEL?
- If you declare a CREATE_LEVEL, apparently you don't need the LEVEL_EVENT (unless I've done some magic without knowing it...) - can somebody confirm?
Any additional info on the subject is greatly appreciated.
Paul-Eric
There are still a few things unclear to me.
- If you use a LEVEL_EVENT, do you absolutely need to declare a CREATE_LEVEL?
- If you declare a CREATE_LEVEL, apparently you don't need the LEVEL_EVENT (unless I've done some magic without knowing it...) - can somebody confirm?
Any additional info on the subject is greatly appreciated.
Paul-Eric
0
Comments
LEVEL_EVENTS occur when levels change. Trapping this event allows you to perform an action every time a level is updated with a new value. When a level event is fired, the value of the level can be found in the event data item LEVEL.VALUE. Outside of level events, LEVEL.VALUE has no meaning/is out of scope.
CREATE_LEVEL is a way of associating a variable with a device level. As the value of the device level changes, the variable will be updated to match. CREATE_LEVEL therefore makes it possible to check the value of a device level at any time, not just inside a level event.
Hope that helps
The two are completely independent. You can have either in your code without a need to include the other.
Back in the days we had to use CREATE_LEVEL, because there was no LEVEL_EVENT.
At the moment I'm only using LEVEL_EVENT, but come to think of it, CREATE_LEVEL has more advantages...
It's still very convenient for modules. If you are using a level inside a module, it's LEVEL_EVENT is not accessible to the main program without some kludgy code duplication. Slap a CREATE_LEVEL in it, and pass a variable to the module that is linked to it, and you have full access to the current value without any queries, and without any new event needing to happen. And besides, if all you are doing in a level event is updating a variable, why should you bother, when an internal function can do it for you? I don't see it as obsolete at all.
Then I capture the LEVEL_EVENT and check if that variable is high.
When I use CREATE_LEVEL I would also have to use a BUTTON_EVENT to check when that level has changed, so code-wise it would mean almost no change for me...
Passing it to a module (device module and Touchpanel module) is a very nice method indeed!
Auser, Yuri, Dave, TurnipTruck thank you for your explanations.
Definitely teaching a lot and clarifying once and for all.