Application Development |
Panther supports Windows Dynamic Data Exchange (DDE), which lets applications share data through client/server links. Panther supports both client and server links with other applications. As a DDE server, a Panther application exports data from a field. As a DDE client, it imports data from another application into a field.
Panther as a DDE Server |
As a DDE server, Panther can export data from a named field to a client application. The client application specifies a DDE service, topic and item. In Panther, these correspond to the application name, screen name and field name, respectively.
For example, an Excel spreadsheet can request a link between one of its cells and a Panther field. The request must include the name of the Panther server name, the screen name, and the field name. If the request succeeds, a DDE connection is created between that spreadsheet window and the Panther screen; this connection initially consists of the requested link, and can also accommodate other links that the client might request later.
Before a client application can request links to a Panther application, two conditions must be true:
To enable Panther as a server, call sm_dde_server_on or include this setting in the initialization file Clients can create links to a Panther screen either through the clipboard or by explicitly issuing a request.
You can use the Windows clipboard data to create a link to a Panther application:
prol5w32.ini
or prol5w64.ini
:
DDEServer=on
Creating Links
Paste Links
You can also create links to a Panther screen through explicit requests in the client application's DDE syntax. Refer to your client application's documentation for details on its DDE syntax.
Notes: Prefix the topic name with ampersands (& or &&) if you want the Panther screen to open as a stacked or sibling window.
The following examples show DDE syntax for two applications:
{DDEAUTO myProlApp &mainScreen totalData }
=myProlApp|mainScreen!totalData
It is the client application's responsibility to connect with a Panther screen and create links to the required fields. Most client applications automatically establish a connection when they request a link.
When DDE gets a link request that is intended for a Panther application, it processes it as follows:
Links remain in effect until they are explicitly closed by the client or the Panther application exits. Panther maintains links for a screen that is inactive or closed, and resumes data updates when the screen reopens. The client's connection to a Panther screen remains active until all links to the current screen are destroyed.
Panther destroys links only at the request of the client or when the Panther application terminates. When the client destroys its last link to a screen, its connection to that screen is broken.
A client can create three kinds of links to Panther fields:
Panther automatically updates the client with new data as soon as linked field data changes. Hot links are maintained only for fields on the active screen.
Panther notifies the client when linked field data changes. The client must then request the data. Notice is sent only for fields on the active screen. Requests for data succeed only if the linked field is on an active screen or in the LDB.
Panther updates the client with new field data only when the client requests it. Requests for data succeed only if the linked field is on an active screen or in the LDB.
If the linked field is an array, Panther supplies all occurrences in the array. Occurrences are separated by carriage returns () and newlines (). Leading blanks in right-justified fields and trailing blanks in left-justified fields are omitted.
Panther supplies text data to client applications. It is the client's responsibility to perform any necessary data conversion such as string to numeric. For example, if the client is a Microsoft Excel spreadsheet, the spreadsheet cell should wrap the formula for the DDE reference in a value function call as below; this converts the link text data into a number:
=value(JAM|screen.jam!textdata)
Other methods are specific to each client application.
You can disable Panther as a server at runtime through sm_dde_server_off. Panther continues to maintain all previous links to clients; however, it ignores all client requests that are made after this call.
Panther as a DDE Client |
When a Panther application acts as a DDE client, it imports data into fields from an external server application. Panther can request hot, warm, and cold links.
DDE can maintain multiple connections between the Panther application and server application; only one connection is allowed between a Panther screen and a given server window. Each connection can maintain multiple links.
For example, a Panther screen can request a hot link between one of its fields and a cell in an Excel spreadsheet. The request must include the name of the Excel program, the spreadsheet's filename, and the cell identifier. If the request succeeds, a DDE connection is created between the Panther screen and the specified spreadsheet; this connection initially consists of the requested link, and can also accommodate other links that the client might request later. Subsequent changes in the server cell data are reported to Panther and automatically are written to its linked field.
Before Panther can connect to a server application, it must be enabled as a DDE client. To enable Panther as a client, call sm_dde_client_on or include this setting in the initialization file prol5w32.ini
or prol5w64.ini
:
DDEClient=on
As a DDE client, Panther can request hot, warm, and cold links. For more on link types, refer to page 46-3. You can create links in three ways:
You can paste server data from the Windows clipboard into a Panther field on the active screen with one of these Panther paste link functions:
Paste Links
These functions take a single argument—the field to get server data. Panther gets the actual data and link information from the clipboard—server, topic, and item—and paste links the data into the specified field.
Panther also provides a set of library functions that explicitly specify the server data required:
Explicit Links Through Library Functions
These functions take four arguments: the server, topic, item, and target Panther field. The format for server, topic, and item arguments is specific to each server application. Refer to the server application's documentation for this information. on page 46-7 shows the syntax used by three widely used Windows applications.
For example, the following JPL statement creates a cold link between a Panther client and an Excel spreadsheet:
You can use the initialization file to create hot links. This lets you specify and edit links for an application without changing the screens themselves. Only hot links are supported from the initialization file.
The initialization file for Panther contains a Panther DDE section, where you can specify links to server applications as follows:
For example, a link to a Quattro Pro spreadsheet might look like this:
The format for server, topic, and item arguments is specific to each server application. Refer to the server application's documentation for this information. Table 46-1 shows the syntax used by three widely used Windows applications.
A link request from a Panther application consists of these steps:
retval = sm_dde_client_connect_cold \
> ("Excel","C:\XL\SALES.XLS","R1C2","total") Links Specified in Initialization File
screenname !
fieldname =
service |
topic !
item
salesScrn!totalSales=QPW|C:\MyAcct\Sales.wb1!$A:$A$10..$A$10
Processing Link Requests
If a link request fails for any reason—for example, because the server application is not running—Panther posts an error message.
Panther updates link data according to the link type:
If a field has warm or cold link data, the application must explicitly request updates from the server by calling sm_dde_client_request. This function can be called only for fields on the active screen.
When warm link data changes, DDE notifies Panther that new data is available from the server. Panther then calls a callback function—either its own or one installed by the developer—and passes it the screen name and field name of the link. For information about writing callback routines, refer to sm_dde_install_notify.
DDE does not notify the Panther client of any changes in cold link data.
Notes:
Because Panther tries to update all occurrences in the array with server data. Data flows into the array starting with the first occurrence. When Panther reaches the end of the occurrence or encounters a tab, carriage return, or newline in the server data, it skips to the next occurrence. Panther eliminates leading white space—tabs, carriage returns, and new lines—before writing the data. The process ends when there is no more data or the end of the array is reached.
When a screen closes, Panther destroys all links on that screen. You can also explicitly destroy links on the active screen with sm_dde_client_disconnect.
Panther maintains its connection to a server application as long as an open screen contains a link to that application. When the last screen containing a link to a server closes, Panther breaks the connection.
sm_dde_client_request
can be called only for widgets on the active screen, an application that uses warm links should queue notices for data on inactive screens.
Array Data
Destroying Links to a DDE Server
Disconnecting from a DDE Server
Execute Transactions |
The execute transaction lets a client execute a command on a server. As a client, Panther can initiate execute transactions on a server application; as a server, Panther can be the recipient of commands issued by a client.
As a DDE client, Panther can execute a command on a server with which it already has a connection by calling sm_dde_execute:
sm_dde_execute(server,topic,command);
The server decides whether to execute or ignore the command. You can check the function's return value to determine the outcome of the call.
As a server, Panther can receive a command issued by a client. For example, a Quattro Pro spreadsheet might contain this EXECUTE
statement:
{EXECUTE B1, "^updateData.jpl"}
Panther executes the command string like any control string.
For information about specifying execute transactions from client applications, refer to that application's documentation.
Poke Transactions |
A poke transaction lets a client send data to a server. As a client, Panther can initiate poke transactions on a server application; as a server, Panther can be the recipient of commands issued by a client.
As a DDE client, Panther can poke data into a server with which it already has a connection by calling sm_dde_poke:
sm_dde_poke(server,topic,item,data);
The server decides whether to execute or ignore the command. You can check the function's return value to determine the outcome of the call.
As a server, Panther can be the target of a poke transaction issued by a client. For information about executing poke transactions from client applications, refer to that application's documentation.