Simplicty and flexibility!


Want to exit DataEase at a scheduled time, trying Timer().


Started by SteinE
Search
You will need to Sign In to be able to add or comment on the forum!

Want to exit DataEase at a scheduled time, trying Timer().

I want to exit DataEase at a given time and is looking into Timer() but can't find any documentation.

Can anyone help?


Written by SteinE 09/11/16 at 10:19:14 Dataease [{8}]FIVE

Re:Want to exit DataEase at a scheduled time, trying Timer().

Download Sample!


Hi Stein.

Yes. this is now straight forward with the new Timer() event on Form Object.

This 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 10:57:15 Dataease [{8}]FIVE
DG3_ForumList