Simplicty and flexibility!

CDF Re-invented! Calling all programmers!

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

CDF Re-invented! Calling all programmers!

Dear All.

A lot of things going on that soon will be revealed, but one "early warning".

We have had a look at the good old CDF interface that has fallen "fallow". 

Not everything is suitable to include in the standard function library, so to make a "loadable" function via the CDF interface is a perfect option.

Sadly nobody have known how to do it since DFD/DFW 5.x so we have spent a little time on it and updated the advice.

CDF's will be supported in all DFD 8, 9 etc and also in DG3 (as long as they don't have gui input/output).

We are currently working on three CDF's inhouse:

2. US Postal Address Generator with OCR.
3. Barcode Controller

We will open a "shelf"/corner of our webshop for third party sales/licensing of CDF's and we will also give you an API to include them in the licensing certificate for DataEase.

So if you have a bright idea for a CDF and know your way around C/C++ take a look on the CDF interface and start making your own.

How to create CDFs

This is how you create your own CDFs using Visual Studio 2013. I selected to use this version because any one can get a full version for free as long as you register with MicroSoft. You should be able to recreate this in any version of Visual Studio in almost the same way as described here. Not much has changed in creating Windows DLLs in the last 20 years. You probably can do the same using other compilers as MinWin GCC and Embarcadero, but that is outside the scope of this document.

How to create a CDF using Visual Studio 2013

Start Visual Studio 2013

Create a new project

Select: Templates->Visual C++->Win32->Win32 Project

Give the project a proper name and a directory where you store the project

Then you run the Win32 Application wizard, just skip the first screen by pressing next and then pay attention to the next screen.

Change from Windows application to DLL, check Export symbols and leave the rest

Now you have got a new project where you can write your code. The are some code already, if you did not select an empty project. We will not keep much of this, but it saves some typing to leave it in. It also illustrate what is needed to create a dll and export functions, classes and variables. We are only interested in the functions for CDFs, so we remove the rest and do an important changes to make the CDF work from DfW and DG3.

The new examplecdf.h file

// The following ifdef block is the standard way of creating macros which make exporting  // from a DLL simpler. All files within this DLL are compiled with the EXAMPLECDF_EXPORTS // symbol defined on the command line. This symbol should not be defined on any project // that uses this DLL. This way any other project whose source files include this file see  // EXAMPLECDF_API functions as being imported from a DLL, whereas this DLL sees symbols // defined with this macro as being exported. #ifdef EXAMPLECDF_EXPORTS #define EXAMPLECDF_API extern "C" __declspec(dllexport) #else #define EXAMPLECDF_API __declspec(dllimport) #endif EXAMPLECDF_API int fnexamplecdf(void);<br> 

The new examplecdf.cpp file

// examplecdf.cpp : Defines the exported functions for the DLL application. // #include "stdafx.h" #include "examplecdf.h" // This is an example of an exported function. EXAMPLECDF_API int fnexamplecdf(void) { 	return 42; }<br> 

The changes worth noting is #define EXAMPLECDF_API __declspec(dllexport) is now #define EXAMPLECDF_API extern "C" __declspec(dllexport). The added extern "C" is the code that makes DfW and DG3 able to recognize the function names. If not the names will be full name with parameters and calling convention. This is not recodnozed by the current version of DfW and DG3.

Install the new CDF in DfW

To use your newly created CDF in DfW, you need to copy the dll file (in this example the examplecdf.dll) from you release area (Ex. E:\Projects\experiments\examplecdf\examplecdf\Release) to your application folder or DfW installation folder pluss CDFLIBS folder contained inside the DfW folder. This DfW installation folder are usually called "C:\Program Files (x86)\DataEase\DataEase x.y\CDFLIBS\" where x is the major version and y is the minor version of the software at the point of first installation. So if you have a fairly new installation it should be "C:\Program Files (x86)\DataEase\DataEase 8.5\CDFLIBS\". Then you need to add en entry in your Custom Function table.

And then to test that it works, just add a button on your page, use Execute Function/Derivation and add this formula:

Message(concat("The meaning of life is: ",fnexamplecdf()),"Important",0,0,0)<br> 

Then have made your first CDF that you can use in your applications.

Install the new CDF in DG3

To use your newly created CDF in DG3, you need to copy the dll file (in this example the examplecdf.dll) from you release area (Ex. E:\Projects\experiments\examplecdf\examplecdf\Release) to your application folder or DG3 installation folder pluss DE4Web\Prism\cdflibs\ . This DG3 installation folder are usually called "C:\Program Files (x86)\DG3". So the full path to CFGLIBS should be "C:\Program Files (x86)\DG3\DE4Web\Prism\cdflibs\". Then you need to add en entry in your Custom Function table.

Make a test DQL to test funtion

That's it you have a result

Reference documentation and tools

Visual Studio download for downloading Community 2013 with Update 4

Exporting C++ Functions for Use in C-Language Executables

DLL Export viewer that is easy to use and understand

Written by DataEase 29/05/15 at 12:57:50 Dataease [{8}]FIVE

Re:CDF Re-invented! Calling all programmers!

This is very good! That you opened up a DLL programming.

Actually, I am not very good with C/C++. So, what I did was created an EXE file for a client to be used like a CDF.
What it does in their application is, we will send a full postal address to this EXE file.
This EXE file will log into Google Maps, and it gets the GPS coordinates for that address.
Then coordinates will be passed back to DataEase application.
DataEase application gets the coordinates and it will store it into a table.

My question to you, based on this scenario. DLL vs EXE, which is better?

Written by Jeyarajah Arulrajah 30/05/15 at 02:16:18 Dataease [{8}]FIVE

Re:Re:CDF Re-invented! Calling all programmers!

Another question I had is.

Are we able to create DLL using C# and use it in DataEase?

Written by Jeyarajah Arulrajah 30/05/15 at 02:27:27 Dataease [{8}]FIVE