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


Exit from dataease automatically


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

Exit from dataease automatically

I have some automatic procedures that runs during the night but those procedures doesn’t close dataease application.

Since version 6.52 I use :

a := ExitDataEase() .

a := Keystrokes("_enter") .

DataEase 8 doesn’t close the application and reply to me : OK to close "database name"   Yes/no (twice!!)

Have you any suggestion for this? It's very important for us because after this procedures we have to run backup copies.

Written by Marco Marchesi 31/10/14 at 07:32:10 Dataease [{8}]FIVE

Re:Exit from dataease automatically

I have used the same coding that you have shown and it works - Are you running your procedure from another procedure, is it being called from an unterminated block etc.

I would check again that the procedure that is closing your database is being used in a clear and straightforward manner - There is probably something in the way that it is being run that is interfering with the clean shutdown.

Written by Peter Birney, PB Associates 31/10/14 at 20:57:28 Dataease [{8}]FIVE

Re:Exit from dataease automatically

One of the big news in DataEase 7.0 was the conversion of Borland C++ to Microsoft Visual C++. This was higly necessary since Borland C++ was de-supported etc.

Borland C++ had its own DLLs and functions for most windows functions so the behavior of DataEase for Windows changed quite a lot from 6.x to 7.x simply because of this.

The biggest problem was fro people using "hacks" in their programming i.e. CDF's and linked functions etc, as the way functions are executed is different in Borland and Microsoft. 

Many things that worked (but maybe shouldn't) in DE6 didn't work in DE7 etc. Microsoft C also imposes a much stricter regime for illegal memory pointers so bugs that was "neglected" in 6.x caused GPF in 7.x.

Due to lack of functionality in DFW 5.x and 6.x there was a big cottage industry around hacks/workarounds and CDFs etc.

KeyStrokes is one of these hacks and it works by sending codes to the Keyboard buffer. 

We understand that it was both desirable and necessary to work around the limitations of DE5.x adn DE6.x but it is still an "abominable" way to do programming.

It is like throwing a basketball and expect it to hit the basket every time with 1000 10 meter tall defenders on the pitch.

The problem with your code is not that ExitDataEase() is called many times or show the Dialog more than once, but simply that it doesn' thave the "focus" when you send your keystroke.

The fact that the exact same code worked without a hitch doesn't really count for much as how functions are prioritized etc is no longer the same.

Due the to fact that functions are posted on the queue rather than executed in order means that the ExitDataEase() dialogue is not the one that receive the keystroke but some other function so it is lost in "space".



define "telle" number .

define "retval" text .

while telle <20000 do

telle := telle + 1 .

if telle=10000 then

retval := ExitDataEase() +Keystrokes("_enter") .

end

message concat("This is record: ",telle) .

end

This code will fail the same way. as the Keystroke is lost.

but this code will work.

define "telle" number .

define "retval" text .

while telle <20000 do

telle := telle + 1 .

message concat("This is record: ",telle) .

if telle=10000 then

retval := ExitDataEase() +Keystrokes("_enter") .

end

end

Because we moved the message line so there is just enough time for the code to execute before it looses focus, but observe one thing when you run the latter code the message will go way past 10000 before it actually exits the Application and that the code is executed in parallel so the DQL is not pre-empted until DataEase is actually closed.

We coudn't find a better example to showcase the short-comings and problems with using keystrokes to control an application in Windows. 

The only reason it works is also the reason it fails. It works because computers are so fast that it is hard to get in between so human interaction will no longer be a real risk, but for the same reason the computer /OS will be able to get in between.

But at the end of the day it is DataEase' fault that these things was necessary in the first place and we are removing the need for them one step at a time.

We did a major change in DE8.2 and that is that we can now have variable numbers of arguments on Functions. This means that we can have from 0 to 32 arguments.

ExitDataEase() is a DFWAction function implemented as a CDF in 6.x and then merged into the code in 7.x. But due to the fact that it was created with 0 arguments we could never add options to it, with the latest change we can simply add an argument to it that tell DataEase to exit wihtou any dialogue or human interaction.

ExitDataEase("Silent")

This was added to our ToDo list today.

In the meantime make sure that you only call retval := ExitDataEase() +Keystrokes("_enter") . at the end of a chain of DQLs etc, and don't run processes in parallel to avoid this problem.

If it doesn't work, just move things around a little and test till it works.

Written by DataEase 01/11/14 at 09:58:16 Dataease [{8}]FIVE

Re:Re:Exit from dataease automatically

I tried your code marked in blue :
1) If I run the procedure simply open the procedure via catalog it works.
2) If I run the procedure via scheduled task it doesn't work and reply to me "Ok to close "Application name" ? and if I click "yes" appear an error like this "Error 211 Error closing Application Operation failed"
Obviuosly I need run the procedure during the night..
Anyway let me know when I can use "Silent" parameter on ExitDataEase.

Here my procedure:
--
-- Procedure automatiche serali
--
define "a" number .
define "telle" number .
------------------------------------------------------------------------------------
--- Inserire qui le procedure da far girare durante la notte ---
-----------------------------------------------------------------------------------
-- run procedure PRinuAggiornaDataProssimaEvidenza .

-----------------------------------------------------------------------------------------------------------------------------------
-- routine di uscita in attesa di aggiunta del parametro "Silent" alla funzione "ExitDataEase" ---
-----------------------------------------------------------------------------------------------------------------------------------

telle := 0 .
while telle < 20000
do
telle := telle + 1 .
message concat ("waiting for exitdataease : " , telle) .
if telle = 10000 then a := ExitDataEase()+Keystrokes("_enter") . end .
end .

Written by Marco Marchesi 03/11/14 at 09:16:25 Dataease [{8}]FIVE

Re:Re:Re:Exit from dataease automatically

I had a similar request from a client. 

All I did was created a 3rd party utility to open DataEase, run the procedure, wait for the DataEase to finish running the procedure, when procedure completes, there will be message like "OK to close....". 

At that point 3rd party utility will close that message and close DataEase.

All of this is controlled by using the Windows title and keystrokes.

There are few options, I can write a utility for your custom needs. Or you can write one yourself.

There are many software available for this purpose. But, software I used www.winbatch.com
Best software I would highly recommend for any MS Windows automation.

Regards, Arul
arulj@fish4support.com

Written by Jeyarajah Arulrajah 05/11/14 at 02:15:31 Dataease [{8}]FIVE

Re:Re:Re:Re:Exit from dataease automatically

Thank you for this. Unfortunately I cannot install 3rd part software without a license and a specific approval by my company.  If it works with your script could you please send it to me by e-mail or upload the file in your website? (marco.marchesi@atradius.com) Note - for internal policy I cannot receive file with .zip or .exe or .ini extension. If you have the possibility please upload the script on web so everyone can download it.  I can try to use it until dataease support correct the function exitDataEase with the parameter "Silent".

Written by Marco Marchesi 05/11/14 at 11:31:46 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Exit from dataease automatically

Hi Marco,

May be I did not explain myself properly. This utility is created according to customer application/specification. i.e. it is chargeable consultancy.

That is why I even pointed out which software I use. And you can use the same software on your home computer and build the utility.
But, the idea is free :-) . All you have to do is to find out DataEase title under Windows and wait for it to complete. Then send keystrokes from outside of DataEase application. That way you are always in control of the app. There are other macro type software out there for free. You may have to search online for it.

I hope this helps.

Regards, Arul

Written by Jeyarajah Arulrajah 05/11/14 at 14:25:11 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Exit from dataease automatically

We have now added ExitDataEase("Silent")

One thing you have to make sure of is that you call Exit in the right place. In my example I did it in a wrong place i.e. in the middle of a loop and this can cause problems.

Only call exit when DataEase is properly finished with what it is doing or otherwise it can cause a GPF.


http://www.dataease.com/static/files/DataEaseFull-...

Written by DataEase 11/11/14 at 11:39:31 Dataease [{8}]FIVE