Simplicty and flexibility!


New Sample: How to automatically open different external documents from DE 8.5 (Showcase)

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

New Sample: How to automatically open different external documents from DE 8.5 (Showcase)


Download Sample
DataEase 8.5 is packed with new functionality but that is not much help if nobody use them.

Our focus has been on developing the functionality, but now our focus will gradually move to usage.

Things that used to be seriously hard in DFW 5.x, 6.x and 7.x is breezily simple in DE8.5

Programming is combination of different functions into a program which is what DE85 is all about. We have given you an amazing tool chest and now we will start showing you how to use it.

One request we get quite often is how to generate and open documents directly from DataEase.


Generating is ExecDQL but opening is ExecuteFile.

Yes. It is old and trusted but it is also radically changed.

In the old days you used to be able to execute a program but now you can execute Documents too.

We have created a little example to show how you can do it (attached).

ExecuteFile("MyPdf.PDF") will open the PDF in the assigned Application ex. Acrobat Reader.

Depending on your security settings etc, it will just open or it will ask you if it is OK to open it.

However there is a small But..

When opening with a full path in WIndows the format used is different dependent on the path having spaces in it or not.

When it has Spaces the format is:

"d:\Documents\Bulgaria\Elena Hold House Unrestored\DSC00461.JPG"

When it doesn't have spaces the format is:

d:\Documents\Bulgaria\ElenaHoldHouseUnrestored\DSC00461.JPG

The stupid bit is that you can't use " " around the path if it DOESN'T have spaces in it (who defined this beauty?)

This is why our derivation looks like this:

ExecuteFile(if (StringFind(DocumentToOpen," ")>0,concat("/'",DocumentToOpen,"/'"),DocumentToOpen))


Here we use StringFind to check if there are spaces and if it is we concatenate the path with " " on each side. Lucky for us in 8.5 we have escape characters for forbidden characters like " which is /'.

To be "helpful" we have also shown how you can use DEOS to pick a file with the file explorer.

SetValue("DocumentToOpen",DEOS("@BrowseForFile"))+RefreshForm()


What we do here is to put the result from calling DEOS("@BrowseForFile") in the Field with objectname "DocumentToOpen" and then we call RefreshForm() to make sure the visual controls are updated to reflect this. 

Could it be simpler ;-)


Written by DataEase 21/03/17 at 20:14:46 Dataease [{8}]FIVE
DG3_BlogList