Your full service technology partner! 
-Collapse +Expand
Search Paradox Group:

-Collapse +Expand Paradox To/From
-Collapse +Expand Paradox Store

Prestwood eMagazine

May Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Paradox & Ob...P7 Book: Pro...   Print This     
  From the August 2014 Issue of Prestwood eMag
Paradox P7 Book: Programming Unleashed:
PUN: Chapter 27, Using DDE, OLE, and OLEAuto
Posted 16 years ago on 3/17/2003 and updated 6/5/2008
Take Away: Chapter 27, "Using DDE, OLE, and OLEAuto" from Paradox 7 Programming Unleashed by Mike Prestwood.
 Tags: Paradox , ObjectPAL , DDE , OLE , OLEAuto , COM , DCOM


Updated 6/5/2008, fixed code formatting and linked message board threads at bottom of page

Dynamic data exchange (DDE) and object linking and embedding (OLE) are two protocols, or standards, that Microsoft asks makers of Windows applications to support. Both provide easy ways to exchange data with another Windows application. Although DDE and OLE are primarily interactive user features, you can carry out some interesting tasks with them in ObjectPAL.

The primary difference between DDE and OLE has to do with what each one sends. DDE sends data and commands between two applications. OLE either embeds data directly into another application, or stores information about a link to a specific piece of data. You can store OLE data in an OLE field type of a table. You cannot store DDE links in a table.

What Is DDE?

DDE is a powerful tool for Windows programmers. DDE in ObjectPAL enables you to do three things: send values to another application, get values from another application, and send commands to another application.

Just as you have a client and a server in a network environment, you have a DDE client and a DDE server when you establish a DDE link between two applications. The application that is the source -- that is, the provider -- of the data is the server. The application that receives the data is the client. Paradox is only a DDE client with ObjectPAL. Therefore, you can send and receive values, but Paradox must be the application that does the sending and receiving. In other words, another application can't tell Paradox to send or receive data.

DDE Basics

The term DDE stands for Dynamic Data Exchange, which is a way for two or more applications to share data. A DDE link is distinctly different from an OLE link. Use DDE to exchange bits of data and execute DDE commands. Use OLE to embed objects from one application into another. The application that receives data from the server application is the DDE client. The DDE server is the application that responds to the calling application (that is, the client) in a DDE or OLE conversation, usually by sending data. The client application is responsible for starting the DDE or OLE conversation. A DDE topic is the subject of a DDE conversation. Usually, it is the name of a data file of the application. A DDE item is the piece of data sent between applications.

What DDE Can Do for You

DDE sends and receives one piece of data or a command at a time. This means that you can use DDE to send the value of a single field or a complete table. You can send several single values one after another. With DDE, you can send text, field information, or even a bitmap. For example, you can put a button on a form that tells your word processor to open a document. Then you can send it values and tell it to print. Not every application can exchange data with Paradox. For example, DOS applications don't support DDE. Most -- but not all -- Windows applications support DDE. Applications that support DDE include Quattro Pro for Windows, Excel, Word for Windows, WordPerfect for Windows, ObjectVision, and Quicken for Windows. Small utilities often don't support DDE.

Most programmers stay away from DDE because they think that it's difficult. The funny thing, however, is that DDE isn't difficult. In fact, only four commands in ObjectPAL deal with DDE. Table 27.1 lists the DDE methods and procedures.

Table 27.1. DDE methods and procedures.

Method                        Description

close                            Closes a DDE link.

execute                         Sends a command by means of a DDE link.

open                             Opens a DDE link to another application.

setItem                         Specifies an item in a DDE conversation.

The Windows Registration Database

The Windows registration database is a system-wide source of information, listing the server applications that support the DDE/OLE protocol, the names of the executable files for these applications, the verbs for classes of objects, and whether an object-handler library exists for a given class of object (see Figure 27.1).


Figure 27.1. The registration database.

When a DDE or an OLE server is installed, the correct information about the server is stored in the registration database. The registration database is a big part of Windows 95 and Windows NT and stores information about your software and hardware. You can access the registration database by running the REGEDIT.EXE application. If a program that supports DDE or OLE is merely copied to a workstation, problems with DDE and OLE can occur. For example, a DDE server must be in the DOS PATH.

How to Use DDE from ObjectPAL

You must establish all DDE and OLE links for a form from Paradox. You can do this interactively or through ObjectPAL. You can't use another application's macro or a programming language to establish a link with a form.

To establish a DDE link with another application through ObjectPAL, you need to know the following three things:

·        The name of the other application

·        What the other application uses as a DDE topic

·        What the other application uses as a DDE item

The name of the application almost always is the name of the executable. For example, Word for Windows uses WINWORD, and ObjectVision uses VISION.

The DDE topic almost always is the name of the document with which you want to establish the link. For example, Word for Windows uses the document name, such as README.DOC, and ObjectVision uses the application name, such as ORDER.OVD. When using the document name, remember to include the path to the document.

The DDE item is trickier. In most cases, you must consult the manual of the other application to find out what it uses for the DDE item. Usually, the DDE item is an element of the document -- in other words, an element of the DDE topic. For example, Word for Windows uses the document's bookmarks, and ObjectVision uses the application's field names.

Using the DDE open() Method

You can think of DDE links as conversations between two applications. One application must ask the other application if it wants to talk about a particular subject or topic. You do this with the open() method. You can use three syntax models:

open (const server String)

open (const server String, const topic String)

open (const server String, const topic String, const item String)

As always, first you must declare a variable, as in the following example: 

 1:  var
 2:     ddeWinWord   DDE 
 3:  endVar

As soon as you have a variable to work with, you can use one of the three syntax models to establish a link. With syntax 1, you ask the other application whether it wants to talk. You can use the following techniques to establish links with most DDE-compatible applications.

The following line of code asks Word for Windows whether it can talk:


If Word for Windows isn't open already but it's in your DOS path, this command launches it. After a conversation, or link, is established, you can use the execute() method to execute a command in the other application.

In most cases, however, you won't use syntax 1 because it doesn't establish a topic. The following command uses syntax 2. It opens a link and establishes a topic with Word for Windows. 


Syntax 3 of the DDE :: Open method allows to specify the application, topic, and item. For example,


Executing DDE Commands

To enable you to control other applications with DDE, ObjectPAL offers the execute() command. You can use ObjectPAL to send commands to other applications. You use the same macro command structure that the controlled application understands. For Word for Windows, this is WordBasic. You can search the Word for Windows help screen to find the WordBasic commands. If you only want to print the document, you don't need to establish an item. The following line of code uses the execute() command to tell Word for Windows to print the document:

Do not confuse the DDE type execute() with the system type execute(). The DDE execute() sends the string command to an application via a DDE link. The system execute() executes or runs a Windows or DOS application. The nature of the DDE execute() command varies from one application to another. Commands sent to Excel probably won't work in Quattro or in a word processor.

Using setItem()

If you want to exchange data, you must send (or in DDE terminology, poke) the data into another application or get information from it. To do this, open a DDE channel, use the setItem() method, and assign the data as a value to the DDE variable. If the README.DOC document has a LastName bookmark, you can set the item of conversation to it with the following statement:

1:  ddeVar.setItem("LastName")

Otherwise, you can use syntax 3. For example, the following opens a conversation and sets both the topic and the item in one line of code:


After you establish the link, or gateway, you can use regular dot notation to manipulate the data in the open document. For example, to get a value from the established DDE item and to put it in a variable, you can use the following code:

 1:  var  
 2:     Last_Name String 
 3:  endVar 
 4:  Last_Name = ddeVar 

Setting the value in the other application is just as easy. For example, the following statement sets the item in the other application to the value in the variable named Last_Name

 1:  ddeVar = Last_Name

Now, put all these statements together. The code looks like the following: 

 1:    ;button :: pushButton 
 2:    method pushButton(var eventInfo Event) 
 3:       var 
 4:          ddeVar     DDE 
 5:          Last_Name  String 
 6:       endVar 
 9:       Last_Name = ddeVar 
10:       Last_Name.view("Value in Word") 
11:       ddeVar = "Ault" 
12:       Last_Name = ddeVar 
13:       Last_Name.view("New value in Word") 
14:    endMethod 

Exchanging Multiple Values

So far, this chapter has discussed about sending and receiving only single values. You might be wondering how you send multiple values. To do so, first use the setItem() method to set the item. Next, send or receive the value. Then, use setItem() again to establish a new item of discussion. In DDE terminology, that is a new item within the current topic.

The following code builds on the README.DOC example. It sends three different values to three different bookmarks. It assumes that you already have established the three bookmarks in Word for Windows:

1:  ddeVar.setItem("LastName") 
2:  ddeVar = Last_Name 
4:  ddeVar.setItem("FirstName") 
5:  ddeVar = First_Name 
7:  ddeVar.setItem("PhoneNumber") 
8:  ddeVar = Phone_Number 

Paradox makes asynchronous transmissions. This means that Paradox waits for the other program to respond. This waiting doesn't always occur correctly. This means you might need to put a sleep() command in your code to wait for the server to respond to certain requests. As a rule of thumb, if a DDE command fails when it sends or gets values or when it sends commands, put a sleep(100) command between the two lines of code. This tells Paradox to sleep for one-tenth of a second. In computer time, this is usually plenty of time for the other application to return a message.

Starting the Other Application Ahead of Time

If you want, you can launch an application before you establish the DDE link. For example, you can launch Word for Windows ahead of time with code such as the following:

1:    ;Button :: pushButton 2:    method pushButton(var eventInfo Event) 
3:       execute("WINWORD.EXE C:\\WINWORD\\README.DOC") 
4:    endmethod 

This approach offers no real advantage. Sometimes, however, you want to enable the user to open the application ahead of time without doing any DDE exchanges.

The form in Figure 27.2 demonstrates how to link to Word for Windows, send and get values, and print. You must have Word for Windows in your path for this form to work. When you tell Word for Windows to print, the system doesn't switch to Word for Windows. Instead, the Printing dialog box from Word for Windows appears over Paradox.


Figure 27.2. APPS\INFO\INFO.FSL uses Word for Windows to spell check text.

You can use DDE to spell check a field with Word for Windows. Take a look at The Information Database (\APPS\INFO\INFO.FSL) for an example of this technique. Also note that you can use this technique to grammar check.  

Sometimes, you might want to send a large text field to Word for Windows for spell checking. When the spell checking is done, you retrieve the text file. The form in Figure 27.2 demonstrates how you can do this. Table 27.2 lists sample DDE applications, names, topics, and items. For the applications, case doesn't matter.

Table 27.2. Sample DDE applications, names, topics, and items.

Program                      Application                  DDE Topic                  DDE Item ObjectVision                Vision   OVD filename  Field name Paradox                       PDoxWin                     Table filename              Field name Word for Windows      WinWord                     Document   Bookmark WordPerfect for           WPWin                        Document   not supported Win. v5 WordPerfect for           WPWin60_Macros      Document   not supported Win. v6 Quicken for                  Quicken                       System       SysItems, Windows ReturnMessage, Key

Limitations of DDE

DDE in Paradox is limited. You can't send values from another application to a Paradox form. You must use ObjectPAL to get the values from the other application. This is simply a matter of what has control. Paradox must have control, except when you use a TableView object. Another limitation is that Paradox doesn't support the system topic, which is a general-purpose topic that some applications support. Paradox can't exchange data through the system topic.

OLE Basics

The term OLE stands for object linking and embedding. You use OLE to insert files from OLE servers into a Paradox table using the OLE field type or to an OLE object on a form or report. An OLE client is an application that uses the documents provided by an OLE server. Paradox is both an OLE server and client. An OLE server is an application that can provide access to its documents by means of OLE. An OLE object is the object the server shares. This object is similar to the document that an OLE server can save. An OLE object is stored in the OLE client much as a document is stored on a disk. An OLE variable is a handle to an OLE object. You use an OLE variable in ObjectPAL to manipulate an OLE object.

Using OLE

OLE is another tool that enables you to take advantage of another application. OLE enables you to insert objects created by OLE servers into forms and reports, or you can use them in fields of a table. You can use OLE to manage large numbers of files on disk. For example, you might browse through a database of AutoCAD drawings, which is actually a Windows metafile snapshot of a data file. Then, double-click on the drawing you want. The OLE link automatically brings up AutoCAD and feeds it the correct file. OLE fields enable you to store objects from other Windows applications in your database. You can create a database of your word processing documents or spreadsheets and manage them with Paradox.

OLE Version 1

Currently, two types of OLE are on the market: object linking and object embedding. Can Paradox OLE embed, link, or both? You can link to files using the command-line option in Windows Object Packager or through DDE Paste Link into a table's alphanumeric field.

OLE Version Two

Paradox now supports version two of OLE. With OLE 2, you can use the other application right in your database application; including its menus.

OLE Controls

OLE Controls (or OCX controls) are new to Windows 95/NT. The OLE control is a 32-bit version of the old 16-bit VBX controls. OLE controls are portable to DEC Alpha, MIPS, Apple Macintosh, and PowerPC environments.

Because OLE controls are a separate application running as a subprocess of Paradox, you will find the behavior is different from normal Paradox objects. Each OCX has its own child window on the form and its own message queue. This gives the OCX its own event model.

ObjectPAL and OLE

Through ObjectPAL, you can use Paradox as a client or server. You can use ObjectPAL to send data from Paradox to another application or to get values from another application. In ObjectPAL, you can retrieve data in two ways: from a table or from the clipboard.

OLE Methods and Procedures

You can use the OLE methods and procedures and most of the methods and procedures from the AnyType type. Table 27.3 lists the OLE class of procedures and methods.

Table 27.3. OLE methods and procedures.

blank* canLinkFromClipboard canReadFromClipboard dataType* edit enumServerClassNames enumVerbs getServerName insertObject isAssigned* isBlank* isFixedType* isLinked linkFromClipboard readFromClipboard writeToClipboard unAssign* updateLinkNow *Inherited by the Anytype type

Table 27.4 describes some of the more important OLE methods.

Table 27.4. OLE methods and procedures descriptions.

Method                        Description canReadFromClipboard                       Reports whether an OLE object can be pasted from the Clipboard into an OLE variable. edit                               Launches the OLE server and enables the user to edit the object or take another action. enumVerbs                   Creates a DynArray that lists the actions supported by the OLE server. getServerName            Returns the name of the OLE server for an OLE object. readFromClipboard      Pastes an OLE object from the Clipboard into an OLE variable. writeToClipboard         Copies an OLE variable to the Clipboard.

OLEAuto Methods

OLE Automation is a way to manipulate an application's objects from outside that application. OLE Automation uses OLE's component object model, but can be implemented independently from the rest of OLE. With OLE Automation, you can do the following:

  • Create objects for programming tools and macro languages.
  • Create and manipulate objects from one application exposed in another.
  • Create tools that access and manipulate objects.
Using enumAutomationServers

The procedure enumAutomationServers() reads the registry on the current machine and gathers all the available OLE servers, with a programmable interface. Following is the syntax:

enumAutomationServers ( var servers Array[ ] String ) Logical :

You can type in the following code into the pushButon method of button to list all the available OLE servers on your machine:

;Button :: pushButton 
method pushButton(var eventInfo Event)    
dynServers   DynArray[] String    
dynServers.view("Available OLE Automation Servers") 
Using open, enumMethods, and version

The open, enumMethods, and version methods enable you to open an OLE server and extract information. Following is the syntax for each:

open ( const serverName String ) Logical enumMethods ( var methods DynArray[ ] String ) Logical version ( ) String

The following example opens the Paradox OLE server and enumerates its methods to a dynamic array. Finally, it displays the version number.

;Button :: pushButton 
method pushButton(var eventInfo Event)    
	oa  OLEAuto       
	dynMethods   DynArray[] String    
;Open server."Paradox.Application")    ;Display methods    
dynMethods.view("Paradox Methods")    
;Display version.    

The OLEAuto methods enumObjects() and enumProperties() enable you to extract other types of information from OLE servers.

Some of these methods of an OLE control might not be accessible by ObjectPAL because their types are not supported, in which case the prototype will show an asterisk *.

Native Windows Controls

Paradox provides support for native window controls (NWC) to be used in forms. To ObjectPAL, native windows controls and OLE controls are virtually identical. Paradox has an OCX type wrapper inside of the Paradox form system so that native controls behave like OLE controls. All the OLEAuto programming concepts are applicable to native windows controls. The only difference (and benefit) is that there is no .OCX file (the code is stored in a the Paradox DLLs). Table 27.5 lists all the OLEAuto methods and procedures.

Table 27.5. OLEAuto methods and procedures.

attach close enumAutomationServers enumConstants enumConstantValues enumControls enumEvents enumMethods enumObjects enumProperties enumServerInfo first invoke next open openObjectTypeInfo openTypeInfo registerControl unregisterControl version

The New ^ Operator

Among the OLE automation methods included with Paradox 7 (such as FormOpen(), ScriptOpen(), and so on), is delete(), which deletes a named file. The following is an example of using delete() with an OLEAuto variable. var 

oa OLEAuto 

In the above code, there is a conflict with the existing delete() method. You must use the new ^ operator (as in oa^delete()) which unambiguously identifies the method as an OLE method. An ObjectPAL method always overrides an automation method when using dot notation. Use the ^ to refer to automation methods in which there may be a conflict with an existing ObjectPAL method.

Using enumServerClassNames()

Use enumServerClassNames() to find the OLE servers on your system -- specifically, the OLE verbs. For example, a Microsoft Word for Windows Server name is either Microsoft Word 6.0 Document or Microsoft Word 6.0 Picture. The corresponding OLE verb you use in ObjectPAL to refer to the OLE server is either Word.Document.6 or Word.Picture.6. You find this information with the following code: 

 1:  ;btnServers :: pushButton 
 2:  method pushButton(var eventInfo Event) 
 3:    var 
 4:       dyn  DynArray[] AnyType 
 5:       o    OLE  
 6:    endVar 
 8:    o.enumServerClassNames(dyn) 
 9:    dyn.view("OLE Servers on system") 
10: endmethod 

Type the preceding code into the pushButton method of a button on a form. Run the form and click the button.

Using insertObject()

You can use insertObject() to insert a linked or embedded OLE object into an OLE variable. Following is the syntax for insertObject().

insertObject ( ) Logical insertObject ( const fileName String , const link Logical ) Logical insertObject ( const className String ) Logical

The first syntax is just like choosing Edit | Insert Object. In the second syntax, you insert the name of a file. Finally, in the third syntax, you specify the class of the object to insert. For example, place a button and an OLE object on a form and type the following into the pushButton method of a button: 

 1:  ;btnInsertOLE :: pushButton 
 2:  var 
 3:    o  OLE 
 4:  endVar 
 5:  method pushButton(var eventInfo Event) 
 6:    if not o.insertObject() then 
 7:       errorShow() 
 8:       fldOLE.value = o 
 9:    endIf 
10: endMethod 
Using OLE Type edit()

The edit() method launches the OLE server application and gives control to the user when used with an OLE object. The argument oleText is a string that Paradox passes to the server application. Many server applications can display oleText in the title bar. For example, the following is the syntax template for OLE :: edit.

edit ( const oleText String, const verb SmallInt ) Logical

edit passes verb to the application server to specify an action to take. verb is an integer that corresponds to one of the OLE server's action constants. The meaning of verb varies from application to application, so a verb that is appropriate for one application may not be for another. Usually, you can pass an OLE server the number 1 to play or display the OLE object.

Using CanReadFromClipboard()

With ObjectPAL, you can read OLE data directly from the Windows Clipboard. You can use canReadFromClipboard() to test whether anything is on the Clipboard. The syntax is as follows:

canReadFromClipboard ( ) Logical

This method is useful in a routine that informs the user whether an operation is possible. canReadFromClipboard() returns True if an OLE object can be read from the Clipboard into an OLE variable; otherwise, it returns False. For example, type the following into the pushButton method of a button:  

1:  ;Button :: pushButton  
2:  method pushButton(var eventInfo Event)  
3:    var  
4:       o OLE  
5:    endVar  
7:    view(o.canReadFromClipboard)  
8:  endMethod 

Another technique is to use the timer event method and check the result of enumWindowNames(). As an alternative to enumWindowNames(), you could use the Windows API FindWindow function for the OLE server's window title. When it is gone, kill the timer and assign the OLE variable


In this chapter, you learned about DDE, OLE, OCX and the new OLEAuto type. All provide easy ways to exchange data with another Windows application. Although DDE and OLE are primarily interactive user features, you can carry out some interesting tasks with them in ObjectPAL. The primary difference between DDE and OLE has to do with what each one sends. DDE sends data and commands between two applications. OLE either embeds data directly into another application, or stores information about a link to a specific piece of data. OCX is an extension of OLE you can use to extend the objects in Paradox.

Paradox 7.0 enables you to embed 32-Bit OLE Custom Controls (OCXs) into Paradox forms. OCXs can be a complex miniature application such as an editor, spreadsheet, or even a graph engine. Each OCX surfaces methods, properties, and/or events, which the user can set and call during runtime or design-time.

1:  ddeVar.execute("[FilePrintDefault]") 

Linked Message Board Threads

 OLE Excel Subtotal/Sort ? in Paradox to/from Other Data Sources MB Topic (1 replies)
 OLE in Paradox 5 in Paradox Forms MB Topic (2 replies)
 Controlling ObjectPAL via external app DDE? in ObjectPAL MB Topic (4 replies)
 Connecting to winzip with DDE in ObjectPAL MB Topic (5 replies)
 Beginner OLE Question in Paradox Forms MB Topic (1 replies)
 OLE DB/ADO in ObjectPal in ObjectPAL MB Topic (0 replies)
 OLE in ObjectPAL MB Topic (2 replies)
 OLE Automation in ObjectPAL MB Topic (2 replies)
 Paradox reports, ole container in Paradox Forms MB Topic (2 replies)
 clear out OLE fields in ObjectPAL MB Topic (2 replies)
 DDE and IEXPLORE, Open Link works but having troub in ObjectPAL MB Topic (0 replies)
 Documents.Add with OleAuto in ObjectPAL MB Topic (3 replies)
 DDE and Word 2000 problems :( in ObjectPAL MB Topic (1 replies)


Share a thought or comment...
Comment 1 of 2

salut à toute l'equipe prestwood & ses amants.

 je suis débutant en langage Paradox, seulement et selement si quelqu'un pourra m'aider à créer l'executable de mon petit projet.

      merci infiniment .

Posted 12 years ago

Comment 2 of 2
My french is a bit rusty but I think you're asking for help with a small project. Correct? If you need help and have someone that speaks english at your company, let us know; otherwise, hopefully a french speaking Paradox developer will contact you.
Posted 11 years ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1257A1
Enter key:
Article Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100145 Counter
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

©1995-2019 Prestwood IT Solutions.   [Security & Privacy]