Easy to Create, Easy to Change - Easy to use!


New Sample - How to use Timer(Event) to schedule exiting DataEase

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

New Sample - How to use Timer(Event) to schedule exiting DataEase

Download Sample!



Here we will show how you can use the new Timer(Event) to take down DataEase automatically at a given time. 

Timer(Event) is an OML event so you need to use the OML editor to activate it.

There is one Timer() event for each document, but it is global and will be called 10 times a second as long as the document is open.

The Timer document is hence not dedicated to the document for which it is called. The only dependency is that the document is open, after that it will act as a global resources.

All DataEase functions talk directly to the active document, so a SetValue() or SetState() called in a document does not change the object on the document it is called from but on the Active document. In reality this is the document they are called for if the action is immediate like when it is called from a button or a derivation etc.

But for instance.

DocumentOpen("TestActiveDocument") + wait(1)+SetLabelText("RemoteText","This is set from KillTimer Document!")

will be "too late" to set it in the document from where it is called, so it will do the job in the new document. This is of course a feature that one both need to be aware of and can use to ones advantage.

The reason we mention this is that when you do these kind of actions from Timer() it will be delayed (it can be called weeks or months after the timer was started) so the likelihood that the document form where it is called is the active document is minuscule.

So if you want the functions to be executed in the document that owns the timer you need to activate this document prior to calling the functions.

For instance:

OML or DQL.
If GetCurrent("ActiveDoc") not="MyDocument") then 
retval := SetCurrent("ActiveDoc","MyDocument") .
end

This will activate an already open document (which it will have to be if the timer should work).

If you want to activate an already open document or open it if it is not already open then you use the following:

OML or DQL.

If GetCurrent("ActiveDoc") not="MyDocument") then
if GetCurrent("IsDocOpen","MyDocument") not="Yes" then
retval := DocumentOpen("MyDocument") .
else
retval := SetCurrent("ActiveDoc","MyDocument") .
end
end

We have made a small sample to illustrate how Timer() works in this instance and included some goodies using

SetCurrent()/GetCurrent()
"IsDocOpen"
"ActiveDoc"

SetStyle()
MoveObject()

etc


Written by DataEase 09/11/16 at 12:11:48 Dataease [{8}]FIVE