Back

. . Overview | MS Excel | MS Word 6.0 | MS Word 97 | MS Access | ProgMan | Quattro Pro

DDE Example: Corel WordPerfect

The following example opens a new WordPerfect document, copies some text into 
the document and formats the first line of the text.
This example can also be found in the EXAMPLES directory (file name: ddecwp7.bas). 
The DDE functions are printed in red bold characters.
10!RE-STORE "examples\ddecwp7.bas"
20    ! ***********************************************************************
30    ! *                                                                     *
40    ! *  BASIC DDE Client example for Corel WordPerfect (English/German)    *
50    ! *                                                                     *
60    ! *  Version :  1.0                                                     *
70    ! *  Author  :  Sven Henze, Tech Soft GmbH                              *
80    ! *  Created :  20-May-1999                                             *
90    ! *  Updated :  20-May-1999                                             *
100   ! *                                                                     *
110   ! *  Comments:  You must start WordPerfect before you can use           *
120   ! *             this application.                                       *
130   ! *                                                                     *
140   ! *  Copyright (c) 1999  Tech Soft GmbH. All Rights Reserved.           *
150   ! *                      Email: HTB@TechSoft.de                         *
160   ! *                      www.TechSoft.de                                *
170   ! *                                                                     *
180   ! ***********************************************************************
190   !
200   ! Description:
210   !
220   !   This example application opens a new WordPerfect document, copies some
230   !   text into the document (including some BASIC config infos).
240   !
250   !
260    IF NOT INMEM("Ddeinit") THEN LOADSUB ALL FROM "htbdde.csb"
270    INTEGER Rs,Ch1,Ch2,A,B,Lang
280    DIM Ret$[512],Topic$[256],Ncomm$[80],Doku$[80],Text$[8192]
290    !
300    Lf$=CHR$(10)
310    CLEAR SCREEN
320    PRINT "Make sure that Corel WordPerfect 7.0 is started !"
330    !
340    ! fill the text$ array
350    Text$="BASIC DDE Client Test"&Lf$&Lf$
360    Text$=Text$&"Welcome to the BASIC DDE client test for Microsoft Word for Windows."&Lf$
370    Text$=Text$&"This text was transfered from BASIC for Windows using the BASIC DDE client extension from Tech Soft."&Lf$
380    Text$=Text$&"A demo version of the BASIC DDE Client can be found on the internet:"&Lf$
390    Text$=Text$&"       http://www.TechSoft.de/htbasic"&Lf$&Lf$&Lf$
400    Text$=Text$&"****** System information ******"&Lf$
410    Text$=Text$&"Date:  "&DATE$(TIMEDATE)&Lf$
420    Text$=Text$&"Time:  "&TIME$(TIMEDATE)&Lf$
430    Text$=Text$&"BASIC version:  "&SYSTEM$("VERSION:HPBW")&Lf$
440    Text$=Text$&"Compatibility:  HP BASIC "&SYSTEM$("VERSION:BASIC")&Lf$
450    Text$=Text$&"MSI:  "&SYSTEM$("MSI")&Lf$
460    Text$=Text$&"Free memory:  "&VAL$(FRE)&Lf$&Lf$
470    !
480    Ddeinit(Rs)                          ! Initialize DDE client
490    IF Res=0 THEN
500       Ddeconnect(Ch1,"WPWin7_Macros","Commands")! Connect to WP7
510       IF Ch1>0 THEN
520          CALL Ddeexecute(Ch1,"FileNew",Rs)
530          IF Rs>0 THEN
540               BEEP
550               PRINT "WordPerfect does not respond."
560               Ddeterminate(Ch1,Rs)
570               Ddeclean(Rs)              ! Clean up ressources
580               STOP
590          END IF
600             ! goto start of document
610             Ddeexecute(Ch1,"PosDocTop",Rs)
620             ! insert text in Word document
630             Text$="Type(Text:"&CHR$(34)&Text$&CHR$(34)&")"
640             Ddeexecute(Ch1,Text$,Rs)
650             Ddeexecute(Ch1,"PosDocTop",Rs)
660             ! select whole line
670             Ddeexecute(Ch1,"SelectLineEnd",Rs)
680             ! change text attribute to "Bold"
690             Ddeexecute(Ch1,"AttributeAppearanceToggle(Attrib: Bold!)",Rs)
700             Ddeexecute(Ch1,"PosDocTop",Rs)
710          Ddeterminate(Ch1,Rs)
720          DISP "WordPerfect DDE Test finished successfully."
730       ELSE
740          BEEP
750          PRINT
760          PRINT "Connection to WordPerfect failed."
770       END IF
780       Ddeclean(Rs)                      ! Clean up ressources
790    END IF
800    END