DDE Programming in Crosstalk(R) for Windows[TM]

Julianne Sharer

Julianne Sharer is the Director of Application Development for WexTech Systems, Inc., a consulting and training firm specializing in applications for the MicrosoftÒ WindowsTM and AppleÒ MacintoshÒ environments.

Microsoft Corporation does not make any representation or warranty, express or implied, with respect to any information herein. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of products manufactured by vendors independent of Microsoft.

Created: March 20, 1992

ABSTRACT

CrosstalkÒ for WindowsÔ is a communications program designed for the MicrosoftÒ Windows graphical environment that supports dynamic data exchange (DDE) protocols. Crosstalk can interact with other applications as a client or as a server through the use of scripts. This article describes the Crosstalk programming language and provides sample scripts that illustrate Crosstalk’s implementation of DDE.

INTRODUCTION TO PROGRAMMING IN CROSSTALK FOR WINDOWS

The CrosstalkÒ for WindowsÔ programming language is designed to provide control over Crosstalk’s communications features. A Crosstalk for Windows program, known as a script, can automate tasks as simple as sending a user ID and password to a host system or as complex as completely automating a communications session.

Script Files

A Crosstalk for Windows script consists of two files: the source file containing your instructions and the compiled executable script file. The source file is created using an ASCII text editor such as Windows Notepad and must have the extension XWS. You must run the source file through the Crosstalk for Windows compiler before you can execute it. The compiler converts source code text into a binary, machine-readable format. The compiled script file is smaller than the source file, loads and executes faster, and cannot be viewed or edited by users. Compiled scripts have the file extension XWC.

Configuring Crosstalk for Using Scripts

Before you can begin to work with script files in Crosstalk for Windows, you must set the script directory and select the script editor. To do this:

1.From the Setup menu on the Crosstalk for Windows menu bar, choose System to display the System Settings dialog box.

2.Click the More button to extend the dialog box.

3.In the Phone Book Entries box, specify the directory that contains the sample files (in this example, D:\WINDOWS\DDE).

4.Type the same directory name in the Scripts box.

5.In the Editor To Use box, type NOTEPAD.EXE.

Your screen will look like the screen in Figure 1.

Figure 1.

6.Click OK.

The Crosstalk for Windows programming environment is now ready to use.

Although Crosstalk for Windows has a complete and powerful programming language that lets you create stand-alone applications that never touch a COM port, it is still first and foremost a communications program. With that in mind, our first example illustrates programming techniques for asynchronous communications with remote systems.

Crosstalk stores communications port settings, phone numbers, terminal emulation settings, upload/download protocols, and so on, in phone book entry files (*.XWP). You can access all settings directly from scripts.

The screen in Figure 2 demonstrates the degree to which you can customize modem settings.

Figure 2.

Using Session Variables

We will deal with two types of variables in the first script example: session variables used by Crosstalk for Windows and script variables defined in your code. Session variables contain phone book entry information stored in phone book entry files. Before continuing with the script, we will place information into a phone book entry for our script to access.

To open a phone book entry:

1.From the File menu on the Crosstalk for Windows menu bar, choose Open A Phone Book Entry.

2.Select COMPSERV.XWP from the list box and click OK.

3.When asked whether you want to connect, click Cancel.

4.Choose Session from the Setup menu.

5.Complete the text boxes as shown in Figure 3.

Figure 3.

6.Click OK.

Your entries are stored in session variables that share the names of the boxes, omitting the spaces. We are now ready to open the script.

Interactive Script Handling

There are three ways to execute a script file:

1.From the Setup menu, choose the Session command. The Session Settings dialog box shown in Figure 3 appears. Type the script file name in the Script box. This causes the script to execute when you open that particular phone book entry file.

2.From the Setup menu, choose the System command. The System Settings dialog box shown in Figure 1 appears. Type the script file name in the Startup Script box. This will cause the script to execute immediately when you start Crosstalk.

3.From the Actions menu, choose the Script command. Select the script file name from the dialog box. This method lets you run, edit, compile, or delete the script directly from the dialog box.

For this exercise we will use option 3.

To open the script:

1.From the Actions menu on the Crosstalk for Windows menu bar, choose Script. (The shortcut key is F8.)

2.Select the LOGIN file from the list box.

3.Click the Edit button.

The source file will appear in a Windows Notepad window.

Examining the Script

LOGIN.XWS is a simple host system logon script for CompuServeÒ that demonstrates Crosstalk’s script variable assignments, statements, programming constructs, and branching capabilities. The source code listing follows.

/*

LOGIN.XWS -- CompuServe Login Script

Block Comments are anything between the matching

"asterisk-slash" pairs.

*/

-- Line comments do not require end-of-comment symbols.

-- Anything on a single line following two consecutive hyphens

-- is treated as a comment.

STRING PhoneBook -- declare variables explicitly

INTEGER QuietTime

WaitTime = 2 -- declare variables implicitly

PhoneBook = "compserv" -- initialize the variables

QuietTime = 30

LABEL mainprogram

CALL PhoneBook -- load the phone book entry, and dial number

IF ONLINE THEN GOSUB OnlineToHost

END

LABEL OnlineToHost

REPLY -- send carriage return

WHILE ONLINE

WATCH FOR

CASE 'Host Name:' : WAIT WaitTime TICKS : REPLY NetID

CASE 'User ID:' : WAIT WaitTime TICKS : REPLY UserID

CASE 'Password' : WAIT WaitTime TICKS : REPLY Password

CASE 'Connect time = ' : BYE

QUIET QuietTime SECONDS : REPLY "bye"

ENDWATCH

WEND

RETURN

Comments

/*

LOGIN.XWS -- CompuServe Login Script

Block Comments are anything between the matching

"asterisk-slash" pairs.

*/

-- Line comments do not require end-of-comment symbols.

-- Anything on a single line following two consecutive hyphens

-- is treated as a comment.

The first lines of the script demonstrate two methods for commenting your scripts: blocks and lines. Comments make your executable scripts neither larger nor slower because the compiler ignores them. Therefore, we recommend that you comment your code liberally.

Variable declaration and initialization

STRING PhoneBook -- declare variables explicitly

INTEGER QuietTime

WaitTime = 2 -- declare variables implicitly

PhoneBook = "compserv" -- initialize the variables

QuietTime = 30

The next lines of code deal with script variables. The two types of script variables are integers (Crosstalk does not support real numbers and floating-point calculations) and strings (strings of text). You must declare these before using them. You can declare a variable explicitly by using the STRING or the INTEGER statement followed by the variable name. You can also declare a variable implicitly by assigning it a value of the appropriate type. Variable names can have a maximum of 32 characters and may include letters, digits, and the special characters %, $, and _. Variable names are not case sensitive, but variable types are.

Program flow and labels

Crosstalk scripts support GOSUB/RETURN and the nefarious GOTO for directing program flow. The IF/THEN/ELSE, REPEAT/UNTIL, and WHILE/WEND programming constructs are also available.

The LABEL statement defines a particular reference point in the script. Labels are required arguments for the GOSUB and GOTO statements and follow the same naming conventions as variables.

LABEL mainprogram

CALL PhoneBook -- load the phone book entry, and dial number

IF ONLINE THEN GOSUB OnlineToHost

END

In this example, the LABEL mainprogram statement defines the beginning of the primary routine. The CALL statement loads a phone book entry and dials the phone number defined in the Session Settings dialog box (see Figure 3). Because we initialized the PhoneBook variable name earlier with the value “compserv”, Crosstalk loads the COMPSERVE.XWP phone book file. The next line of code uses the ONLINE function to test for a successful connection to the host. If the function returns TRUE, the script branches to the OnlineToHost label. When the OnlineToHost subroutine has run its course and returns, or if the connection was not successful, the next END statement terminates the script.1

Monitoring the communications session

LABEL OnlineToHost

REPLY -- send carriage return

WHILE ONLINE

WATCH FOR

CASE 'Host Name:' : WAIT WaitTime TICKS : REPLY NetID

CASE 'User ID:' : WAIT WaitTime TICKS : REPLY UserID

CASE 'Password' : WAIT WaitTime TICKS : REPLY Password

CASE 'Connect time = ' : BYE

QUIET QuietTime SECONDS : REPLY "bye"

ENDWATCH

WEND

RETURN

If the script reaches the OnlineToHost subroutine, the connection to the host system has been successful. The first statement, REPLY, sends a string of text to the communications device. By default, REPLY appends a carriage return to the end of the string. (To suppress this action, end the statement with a semicolon.) We use the first REPLY statement without an argument to send a single carriage return to “wake up” the host. Later in this subroutine, we use REPLY to send information contained in session variables to the host.

The statements within the WHILE/WEND loop execute as long as the ONLINE condition remains TRUE. The WATCH FOR/ENDWATCH construct monitors the information received from the host system. The CASE statements determine the actions to take if certain text constants are received, and form the heart of our login routine.

CASE 'Host Name:' : WAIT WaitTime TICKS : REPLY NetID

This WATCH command waits for the “Host Name:” string from the host system. (You can use either matching single quotation marks or matching double quotation marks to delimit strings.) If the string is received, WATCH executes the commands following the string. The colon lets you group multiple statements on a single line. The WAIT statement takes an argument in the form x HOURS, x MINUTES, x SECONDS, or x TICKS (1/10 second). It can also wait for a keystroke. In this example, we specified ticks to delay the response to the host slightly, so it is not lost in the transmission. After the delay, we send our first NetID session variable to the host.

The next two CASE statements complete the logon. The last CASE statement watches for the “Connect time = ” string, which is sent from the host after we log off from our CompuServe session. The following BYE statement immediately hangs up the phone line, thus rendering ONLINE FALSE. This breaks the WHILE/WEND loop. The RETURN statement brings us back to the Mainprogram routine, to the END statement that terminates the script.

The last section of code to examine in this script is the following line:

QUIET QuietTime SECONDS : REPLY "bye"

The QUIET statement is part of the WATCH construct. It monitors the communications line for inactivity. If no information comes our way for 30 seconds (the value of QuietTime), we send the “bye” string, which is the CompuServe logoff command, to the host. This timeout feature helps limit idle online connect time charges.

Compiling and Running the Script

After viewing, and perhaps editing, the script in Windows Notepad, save the source code file using Notepad’s File Save command. We can now run our script through the compiler and execute it.

To compile and run the script:

1.Activate Crosstalk and press F8, the shortcut key for the Script command.

2.Assuming that we entered valid information into the system variables earlier, select LOGIN from the list box.

3.Click the Run button.2

If you made changes to the source code or if a previously compiled version does not exist, Crosstalk compiles the script before executing it.

If you are satisfied with the way the script executed, you can archive the source file. The compiled version of the script no longer requires it.

A CROSSTALK FOR WINDOWS DDE MACRO

We will now explore how Crosstalk communicates with other applications in the Windows environment. As stated in the Crosstalk for Windows Programmer’s Reference, Crosstalk follows the July 17, 1988 dynamic data exchange (DDE) specification defined by Microsoft Corporation.

DDE Plus One More

Crosstalk for Windows includes the following standard DDE commands:

DDEINITIATE initiates a DDE link to another application.

DDEEXECUTE executes a command in another application.

DDEPOKE transfers a value to another application.3

DDEREQUEST requests a value from another application.4

DDETERMINATE terminates a DDE link to another application.

Crosstalk has an additional DDE statement, DDESTATUS, that is not part of the DDE specification. This statement tests the DDE channel to another application and comes in handy for error trapping, as we will see later.

The DDE Demo Script

The next example script file, INTRODDE.XWS, contains working examples of the Crosstalk DDE commands. INTRODDE is a self-running demonstration script that uses Crosstalk as a front-end to Microsoft Excel for two-way data exchange between the programs.

To edit INTRODDE.XWS:

1.Activate Crosstalk and press F8.

2.Select INTRODDE from the list box.

3.Click the Edit button.

The source file will appear in a Windows Notepad window.

/*

DDEINTRO.XWS - Xtalk/Excel DDE demo.

XTALK Script that passes the contents of variables back and forth

between Crosstalk and Microsoft Excel via DDE.

*/

INTEGER ChannelToExcel, ChannelToXLS

STRING ExcelSysInfo, ExcelData, GreetingToExcel

GreetingToExcel = "Hello from XTALK"

LABEL Mainprogram

TRAP ON

GOSUB ArrangeXTALK -- arrange the XTALK window for the Demo

GOSUB InitiateDDE -- start up DDE line with Microsoft Excel

-- with error trapping

GOSUB ExecDDE -- have XTALK execute some Microsoft Excel

-- functions

GOSUB PokeDDE -- place some data in a Microsoft Excel

-- variable

GOSUB RequestDDE -- retrieve the data from Microsoft Excel

GOSUB TerminateDDE -- terminate DDE communication session

END

/*

Subroutines

*/

LABEL ArrangeXTALK

SHOWHSCROLL = OFF

SHOWVSCROLL = OFF

SHOWKEYBAR = OFF

SHOWSTATUSBAR = OFF

SHOWINFOBAR = OFF

CLS

SIZE 645,150 : MOVE 1,1

RETURN

LABEL InitiateDDE

DDEINITIATE ChannelToExcel,"Excel","System"

IF NOT DDESTATUS(ChannelToExcel) THEN GOSUB OpenExcel

DDEINITIATE ChannelToXLS,"Excel","ddeintro.xls"

IF NOT DDESTATUS(ChannelToXLS) THEN GOSUB OpenExcelDataFile

/*

This is another method of checking whether the correct

data file is open, and if not, opening it.

Some applications, including earlier versions

of Microsoft Excel (before release 2.1c),

will not respond correctly to a DDEREQUEST for "Topics."

DDEREQUEST ChannelToExcel,"Topics",ExcelSysInfo

PRINT "Contents of Excel Topics -> " + ExcelSysInfo

IF INSTR(ExcelSysInfo,"DDEINTRO.XLS") = 0 THEN GOSUB

OpenExcelDataFile

*/

RETURN

LABEL OpenExcel

/*

The RUN command below assumes that the Excel directory

is on your PC's PATH statement. If not, use the full path to

Excel, for example, RUN C:\Windows\Excel\EXCEL.EXE.

*/

RUN "EXCEL.EXE"

DDEINITIATE ChannelToExcel,"Excel","System"

IF NOT DDESTATUS(ChannelToExcel) THEN GOSUB DisplayError

RETURN

LABEL OpenExcelDataFile

DDEEXECUTE ChannelToExcel,'[OPEN("\DDECLASS\DDEINTRO.XLS")]'

/*

Note: You may need to modify the path of the Excel file.

*/

DDEINITIATE ChannelToXLS,"Excel","DDEINTRO.XLS"

IF NOT DDESTATUS(ChannelToXLS) THEN GOSUB DisplayError

RETURN

LABEL DisplayError

ALERT "Error Class "+STR(ERRCLASS)+", Error No.

"+STR(ERRNO),OK

HALT

LABEL ExecDDE

/*

Note that a subset of Crosstalk script commands can be initiated

over a DDE line from another Windows application, whereas the

full Excel function macro library is available over DDE.

Notice the placement of single quote and double quote delimiters

when nesting string constants; this is very important.

*/

DDEEXECUTE ChannelToXLS,'[DEFINE.NAME("DataFromXTALK","=R3C4")]'

DDEEXECUTE ChannelToXLS,'[APP.RESTORE()]'

DDEEXECUTE ChannelToXLS,'[APP.SIZE("480","200")]'

DDEEXECUTE ChannelToXLS,'[APP.MOVE("1","150")]'

RETURN

LABEL PokeDDE

ALERT "This is routine PokeDDE",OK

/*

Note that only string information may be poked with DDE.

*/

PRINT "Sending data to Excel . . ."

WAIT 1 SECOND

DDEPOKE ChannelToXLS,"DataFromXTALK",GreetingToExcel+" via DDE"

RETURN

LABEL RequestDDE

ALERT "This is routine RequestDDE",OK

/*

Again, only strings may be requested with DDE.

*/

DDEREQUEST ChannelToXLS,"DataFromExcel",ExcelData

PRINT "Receiving data from Excel . . .";

WAIT 1 SECOND

PRINT ExcelData

RETURN

LABEL TerminateDDE

ALERT "This is routine TerminateDDE", OK

PRINT : PRINT "Closing DDEINTRO.XLS"

DDETERMINATE ChannelToXLS

DDEEXECUTE ChannelToExcel,'[FILE.CLOSE()]'

DDETERMINATE ChannelToExcel

PRINT "DDE channels terminated."

RETURN

Variables and the Mainprogram routine

/*

DDEINTRO.XWS - X TALK Excel DDE demo.

XTALK script that passes the contents of variables back and forth

between Crosstalk and Microsoft Excel via DDE.

*/

INTEGER ChannelToExcel, ChannelToXLS

STRING ExcelSysInfo, ExcelData, GreetingToExcel

GreetingToExcel = "Hello from XTALK"

LABEL Mainprogram

TRAP ON

GOSUB ArrangeXTALK -- arrange the XTALK window for the Demo

GOSUB InitiateDDE -- start up DDE line with Microsoft Excel

-- with error trapping

GOSUB ExecDDE -- have XTALK execute some Microsoft

-- Excel functions

GOSUB PokeDDE -- place some data in a Microsoft Excel

-- variable

GOSUB RequestDDE -- retrieve the data from Microsoft Excel

GOSUB TerminateDDE -- terminate DDE communication session

END

The first lines of the script after the comment block initialize the integer and string variables used by the script, as discussed previously. These lines are followed by the Mainprogram routine.

Note that the only function of Mainprogram is to provide branching to subroutines that do the actual work. The TRAP ON statement disables Crosstalk’s automatic error detection that would normally stop script execution when an error is encountered. We will add our own error-trapping routines later.

Configuring the Crosstalk window

LABEL ArrangeXTALK

SHOWHSCROLL = OFF

SHOWVSCROLL = OFF

SHOWKEYBAR = OFF

SHOWSTATUSBAR = OFF

SHOWINFOBAR = OFF

CLS

SIZE 645,150 : MOVE 1,1

RETURN

The first routine, ArrangeXTALK, prepares Crosstalk for the demo. It turns off the display of the scroll and status bars so that the window, which is then sized and moved, is blank.

Initiating the DDE channels

A Windows application must meet several conditions before Crosstalk can establish a DDE session with it:

It must support DDE (not all Windows applications do).

It must be open and running on the Windows desktop.

If a specific data file or document in the application is to send or receive data, that file must be open in the application.

Scripts that use DDE effectively must test for these conditions.

Checking for the open application

Consider the first part of the InitiateDDE routine:

LABEL InitiateDDE

DDEINITIATE ChannelToExcel,"Excel","System"

IF NOT DDESTATUS(ChannelToExcel) THEN GOSUB OpenExcel

The first line uses the DDEINITIATE command. The structure of this command is:

DDEINITIATE ddechannel, app_name, topic

The ddechannel variable identifies the DDE channel used to communicate with the application. Its value is assigned by Windows. You must declare the variable name as an integer before you can use it. If you are unsure of the application’s DDE name, check the application’s documentation. The application’s topic is usually a document that is opened in the application.5 If no document is open, you can use the SYSTEM topic to initiate the DDE channel. This topic is available in all applications that support DDE.

In our example, we do not know whether Microsoft Excel or any worksheets are open, so we use the SYSTEM topic for the first DDEINITIATE statement.

The DDESTATUS function on the next line checks the result of DDEINITIATE. The structure of this function is:

DDESTATUS(ddechannel)

DDESTATUS returns TRUE if the ddechannel is open, FALSE if it is not. In our example, if it returns FALSE, we can safely assume that Microsoft Excel is not open, so we branch to the OpenExcel routine:

LABEL OpenExcel

/*

The RUN command below assumes that the Excel directory

is on your PC's PATH statement. If not, use the full path to

Excel, for example, RUN C:\Windows\Excel\EXCEL.EXE.

*/

RUN "EXCEL.EXE"

DDEINITIATE ChannelToExcel,"Excel","System"

IF NOT DDESTATUS(ChannelToExcel) THEN GOSUB DisplayError

RETURN

The next two lines after the caveats in the script comment open Microsoft Excel and DDEINITIATE the channel.

When all else fails

We test the channel again with the DDESTATUS function. If the DDE channel is still closed, there is probably a problem opening Microsoft Excel, possibly an “Out of Memory” error. At this point, the script branches to the “serious error” handling routine, DisplayError:

LABEL DisplayError

ALERT "Error Class "+STR(ERRCLASS)+", Error No. "+STR(ERRNO),OK

HALT

DisplayError uses the ALERT command to display a simple dialog box containing the ERRCLASS and ERRNO function values, which identify the type and number of the error that occurred. These codes are listed in Appendix E of the Crosstalk for Windows User’s Guide.

The script cannot continue any further from this point. The HALT command immediately stops it.

Checking for the open document--Method 1

If the DDESTATUS function in the OpenExcel routine returns TRUE, the script branches back to the InitiateDDE routine. We can now assume that Microsoft Excel is open on the desktop.

We now want to check whether the DDEINTRO.XLS worksheet is open in Microsoft Excel. There are two ways to accomplish this, depending on the release level of Microsoft Excel you are running. Either method works with Microsoft Excel; the first method is useful for other applications that do not support the retrieval of a list of the server’s available topics. This method uses the DDEINITIATE command discussed previously.

DDEINITIATE ChannelToXLS,"Excel","DDEINTRO.XLS"

IF NOT DDESTATUS(ChannelToXLS) THEN GOSUB OpenExcelDataFile

The DDEINITIATE command uses a different DDE channel for this test. The last argument on the line identifies the topic, which is the worksheet name. As before, if the DDESTATUS returns FALSE, it’s safe to assume that DDEINTRO.XLS is not open in Microsoft Excel. A GOSUB to the OpenExcelDataFile routine takes care of that, as shown in the following code:

LABEL OpenExcelDataFile

DDEEXECUTE ChannelToExcel,'[OPEN("\DDECLASS\DDEINTRO.XLS")]'

/*

Note: You may need to modify the path of the Excel file.

*/

DDEINITIATE ChannelToXLS,"Excel","DDEINTRO.XLS"

IF NOT DDESTATUS(ChannelToXLS) THEN GOSUB DisplayError

RETURN

Checking for the open document--Method 2

The second method for determining whether the Microsoft Excel worksheet is open uses the DDEREQUEST command to return Microsoft Excel’s topics. The structure of DDEREQUEST is:

DDEREQUEST ddechannel, item, stringvar

Again, ddechannel is the DDE channel used to communicate with the application. The application variable in Microsoft Excel would generally be a cell reference, but we use the DDE name Topics, which may be requested from a conversation initiated on the SYSTEM topic. The application variable must be enclosed in quotes. stringvar is a previously declared variable name that contains the information sent from the remote application.

Topics returns SYSTEM and the names and full paths of any documents currently open in the application. Examine the code fragment listed below:

/*

This is another method of checking whether the correct

data file is open, and if not, opening it.

Some applications, including earlier versions

of Microsoft Excel (before release 2.1c),

will not respond correctly to a DDEREQUEST for "Topics."

DDEREQUEST ChannelToExcel,"Topics",ExcelSysInfo

PRINT "Contents of Excel Topics -> " + ExcelSysInfo

IF INSTR(ExcelSysInfo,"DDEINTRO.XLS") = 0 THEN GOSUB

OpenExcelDataFile

*/

RETURN

The DDEREQUEST command retrieves the value of the Topics variable from Microsoft Excel and places it into the Crosstalk ExcelSysInfo script variable. The INSTR function determines the position of “DDEINTRO.XLS” in the string contained in ExcelSysInfo. If INSTR returns 0, DDEINTRO.XLS was not a part of Topics and is therefore not an open document. The script branches to the OpenExcelDataFile routine, which opens the required document. Figure 4 shows the contents of Topics as displayed by the PRINT command.

Figure 4.

CROSSTALK AS A CLIENT

As a DDE client, Crosstalk for Windows lets you initiate and conduct DDE conversations with multiple servers. All DDE client services are supported, with the exception of the ADVISE command. However, Crosstalk acting as a DDE server supports ADVISE commands from the client application. The following script commands can be used to access DDE.

DDEEXECUTE ddechannel, command

Sends a DDE EXECUTE message to the server on ddechannel, with command as the EXECUTE string. You must define the ddechannel variable and assign it a value with the DDEINITIATE command. The command must be a valid EXECUTE string supported by the server.

DDEINITIATE ddechannel, app_name, topic

Attempts to initiate a DDE conversation with the app_name application on the specified topic and assigns the channel number to the ddechannel integer variable. You must declare ddechannel as an integer before the DDEINITIATE command. The server application, app_name, must be running for the DDE conversation to take place and must support topic.

DDEPOKE ddechannel, item, string

Pokes the string text value to the specified item in the DDE server on channel ddechannel.

DDEREQUEST ddechannel, item, stringvar

Sends a DDE request to the application on ddechannel, asking for the value of item and placing it in the stringvar variable. You must define the ddechannel variable and assign it a value with the DDEINITIATE command. The item must be supported by the topic of the DDE conversation taking place on ddechannel. DDEREQUEST can send only string values.

DDESTATUS (ddechannel)

Returns a value of TRUE or FALSE indicating whether a conversation is taking place on channel ddechannel.

DDETERMINATE ddechannel

Terminates the DDE conversation taking place on channel ddechannel. DDE conversations can also be terminated by the server and are terminated automatically if Crosstalk is closed.

RUN app_name

Executes the application with the specified name. app_name may be an application developed for Windows or MS-DOSÒ and may include the path to the program, for example:

RUN "C:\WINDOWS\CONTROL.EXE"

CROSSTALK AS A SERVER

Crosstalk provides a fairly comprehensive interface for task execution and data exchange in DDE server mode.

Topics and Items

Crosstalk for Windows recognizes three types of topics:

SYSTEM

The null topic (which is treated as SYSTEM)

The name of a phone book entry

Use the phone book entry when you need to identify one of multiple Crosstalk instances running concurrently in a Windows session.

Valid items include script variables, session and system variables, and the “status” item. Script variables are introduced by the programmer. Session and system variables are built-in variables containing settings for communications, hardware, file transfers, and so forth. The Crosstalk for Windows Programmer’s Reference describes all session and system variables. Depending on Crosstalk’s current activity, the “status” item returns “Ready”, “Script”, “Kermit”, or “Transfer”.

The client application can poke values to variables, request the values of variables, and ask to be advised of changes to variables.

EXECUTE Strings

Crosstalk supports several commands through the DDE EXECUTE message. You can pass multiple commands in one EXECUTE message, with each command delimited by square brackets ([ ]). Here’s an example using WordBasic, the macro language for Word for Windows:

DDEEXECUTE ddechannel, "[Dial(cserve)][Execute(script1)]"

Note that arguments to the Dial and Execute commands are not delimited. The following table provides the syntax, description, and abbreviations for valid EXECUTE strings. The last column indicates whether you can execute the command while a script is running.

Command Description Abbreviation OK during script

Bye Disconnects the active session, if one exists. B Y
Cancel Cancels the currently running script. CA Y
Close Closes an open data file. CL Y
Dial(book_name) Dials the phone number assigned to the Number session variable in session settings for the specified phone book file. D(book_name) N
Execute(script_name) Executes the specified script. E(script_name) N
Go Connects to the port assigned to the Port session variable in communications settings without using the built-in dialing procedure. G Y
Kermit(kermit_command) Executes the specified Kermit command. K(kermit_command) N
Load(book_name) Opens the specified phone book entry and loads its contents. L(book_name) N
New Loads the default Crosstalk parameters and the NORMAL.XWP phone book entry, if one exists. N/A N
Save Saves Crosstalk settings using the current phone book name. N/A Y
SaveAs(new_book_name) Saves Crosstalk settings to the specified phone book name. N/A Y

1On some systems, the ONLINE condition returns FALSE even if a connection has been made to the host. If this is the case on your system, you will need to modify the script accordingly.

2If you want to compile the script to test for programming errors without executing it, click the Compile button instead.

3\b DDEPOKE can exchange string values only.

4\b DDEREQUEST can exchange string values only.

5The application name and topic are string constants and must be enclosed in quotation marks.