Using Scripts with Other Windows Applications

A ChemFinder (CAL) script can communicate with other Windows applications using either of two commands:
  • EXEC--to start an application and possibly pass information on the command line.
  • DDE--to communicate using Dynamic Data Exchange with a DDE-ready application.

Using EXEC is straightforward, but limited. You can start all Windows applications by this command. Most can be passed a filename on the command line, such that the specified file is opened (or printed) on startup. A few applications can accept more detailed instructions. Consult the application's manual for information about how it can be operated using the command line.

If you have Visual Basic or similar programming language, you can extend the power of EXEC. You can write an application using the advanced features of Visual Basic, and then call the application from within ChemFinder using the EXEC command.

Using DDE is more complicated. You can operate most Microsoft Office components and many other programs to varying extents with DDE. For example, practically every command on the Excel menu can be executed by DDE. The syntax is rather difficult, but can usually be worked out by experimenting and consulting online help. An example is given below.

DDE is the most direct way of using Excel to view data from ChemFinder.

To use Excel to view ChemFinder data:

  1. Start Excel. You can start it manually using a CAL script or by starting the application in Windows.
  2. In ChemFinder, obtain the hit list you want to transmit to Excel. If you want to work with the entire database, from the Search menu, choose Retrieve All.
  3. Execute a short CAL script (below) which exports the hit list as comma-delimited text to a temporary file, then instructs Excel with DDE to load that file into a spreadsheet.
  4. Activate Excel to work with the data in the spreadsheet.

This procedure takes data one way, from ChemFinder to Excel. 

The following script starts Excel:

*RUNEXCEL.CFS - script to start Excel

*

EXEC "c:\msoffice\excel\excel.exe"

If the Excel program is on your search path, you can eliminate the complete pathname and just give the executable name ("exec excel.exe"); if not, you may need to modify this script to indicate where EXCEL.EXE is located on your system.

The following script transfers the current hit list from ChemFinder to Excel:

*TOEXCEL.CFS - script to send data
*to Excel
*
WRITETEXT C:\DATA.TMP
DDE Excel System [OPEN("C:\DATA.TMP")]
DDE Excel
System [COLUMN.WIDTH(1,"C1:C4",,3,1)]

The first line writes out the current ChemFinder hit list as a temporary delimited ASCII file. By default, all fields that appear in boxes on the current form--except structure, but including formula and molecular weight--are written. The second line instructs Excel to open the file. Excel can automatically recognize the file format as tab-delimited. The third line instructs Excel to auto-size column widths 1-4 to fit their contents.

Note: For Excel to read the file correctly, the ASCII File Export option on the Preferences dialog box General tab must be set to Tab delimited.

For more information, see Program Execution commands.



2005 CambridgeSoft Corporation. All Rights Reserved. Privacy Statement
Tel  800 315-7300 / 617 588-9300     Fax  617 588-9390     Email   info@cambridgesoft.com
CambridgeSoft Corporation, 100 CambridgePark Drive, Cambridge, MA 02140 USA