Simplicty and flexibility!


Closing app with timer() don't work when the application is locked.


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

Closing app with timer() don't work when the application is locked.

I have a challenge, I need to auto-close the application in the night for copying the directory, like 11pm.

The KillTimer is a good base to work, it run well as long time the user have the application en front of his eyes.

BUT if the user lock his computer (desk), that is the disaster, DataEase not exit !! No way on forum or else where ..

DataEase stay opened and the timeleft run in negative after unlock.

If I modify

if mytime = current time then

as

if current time > mytime then ,

Dataease exit only if I unlock :/ . When the guy lock his desk, no possibility to make exit the soft… do you have any solution ?

define "retval" text .

define "mytime" time .

define "timeleft" number .

if getvar("KillTimer") not =blank then

myTime := GetVar("KillTimer") .

timeleft := mytime - current time .

if mytime = current time then

retval := ExitDataEase("silent") .

end

end


Written by HONVAULT PATRICK 07/03/19 at 11:49:18 Dataease [{8}]FIVE

Re:Closing app with timer() don't work when the application is locked.

Hi Patrick.


You set us off there and we where deep inside DE9 land with ServiceWindows, custom made login dialogues etc….

But no… The solution is/was quite simple ;-)

And that is a good thing as we have an early version of ServiceWIndows in DE85 but they can’t compare to the ones we have in DE9 so to work with them is like trying to operate a modern airlines using the Wright Brothers first plane…

Anyhow. It gives us an occasion for a short explanation.

DataEase has a big divide between GUI functions and PRISM functions.

GUI functions are called in the Windows GUI bit of the product and is basically WINDOWS stuff like DocumentOpen, ExitDataEase, SetValue, SetState etc.

PRISM functions are DataEase DNA and is functions that work on the data like concat,firstc, abs,random etc.

PRISM functions will always work but GUI functions is processed by the ACTIVE document!!

This is a new concept for most DataEase users that are used to sequential processing (PRISM and DFD etc).

DFW will go quite far in fooling you into believing that it is sequential too but it isn’t. It is all based around the Windows Message bus.

ALL GUI functions are sent as messages to active window and with luck you will 99.99% of the time up to 8.5 send that to the document from where they are called.

But the more advanced user would have tried something like this.

DocumentOpen(“NewDoc”)+DocumentClose()

What you want to achieve here is obviously to open a new document and close the one you are currently calling from…

Hmmm…

But you then to your big surprise find that ex. Nothing happens, or you see the new document open to quickly close again.

This is because you open a new document that then become the active document and then the message you have sent to the bus in reality only tell DataEase to close the active document, not the document you thought you wanted to close.

But this goes further. Because Active Document (or in reality Active Window) is not a DataEase thing but a Windows thing. You can only have 1 – ONE – Active document on your computer, so when you switch over to Word there is NO active document in DataEase and hence nothing can be executed in GUI!

And this lead us on to your problem.

You have only seen the problem when user minimize or lock DataEase but in reality the problem is the same if he is working in word. ExitDataEase(“Silent”) is a GUI function and need an Active Active Document in DataEase to be executed in.

Luckily for you we use our own product and features so when realising this we made a function to activate DataEase.

it is called

SetCurrent("ActivateDE") -- Activate DE environment for GUI updating.

And for those of you that want to take it one step further and control which Window/Document is active in your DE you also have
SetCurrent("ActiveDoc","DocumentName") -- Bring to front and activate Document

So the simple modification for you script to make it work 100 out of 100 times is
define "retval" text .

define "mytime" time .

define "timeleft" number .

if getvar("KillTimer") not =blank then

myTime := GetVar("KillTimer") .

timeleft := mytime - current time .

if mytime = current time then

retval := SetCurrent(“ActivateDE”)+ExitDataEase("silent") .

end

end

Good Luck!


Written by DataEase 07/03/19 at 12:07:17 Dataease [{8}]FIVE
DG3_ForumList