home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Cobol 24 Hours
/
Sams_Cobol_24_Hours.iso
/
Cobol32
/
PowerCBL
/
powercbl.Z
/
dde.prc
< prev
next >
Wrap
Text File
|
1997-03-13
|
5KB
|
147 lines
@POWER POWSHEET SHEET1 SPECIAL-NAMES
SYMBOLIC CONSTANT
MAX-ROW-NUMBER IS 2
.
@POWER POWSHEET SHEET1 OPENED
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
* Set the following information on EXCEL to the DDE SERVER.
* POW-DDESERVICE - Application name (Excel).
* POW-DDETOPIC - Topic name (full name of Excel sheet).
* POW-DDEITEM - Item name (Applicables range of cells).
MOVE "Excel" TO POW-DDESERVICE OF DDE1.
* MOVE "M:\POWER\SAMPLES\DDE\EXCELDDE.XLS"
* TO POW-DDETOPIC OF DDE1.
MOVE "EXCELDDE.XLS"
TO POW-DDETOPIC OF DDE1.
MOVE "R2C1:R3C3" TO POW-DDEITEM OF DDE1.
@POWER POWSHEET SHEET1 CLOSE
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
* Close the DDE conversation and end the advise loop.
* with the DDE client (DDE1).
CALL CLOSEDDE OF DDE1.
@POWER POWDDE DDE1 DDECHANGE
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
* Set the area where the data from EXCEL is to be received.
77 DDE-EXCEL-DATA PIC X(4096).
* Set the area to decompose the data from EXCEL into each table cell.
01 DDE-ROW-DATA.
02 DDE-ROW PIC X(100) OCCURS MAX-ROW-NUMBER TIMES.
01 DDE-COL-DATA.
02 DDE-DATA-ROW OCCURS MAX-ROW-NUMBER TIMES.
03 DDE-COL-DATA1 PIC X(20).
03 DDE-COL-DATA2 PIC X(20).
03 DDE-COL-DATA3 PIC 9(9).
* Set the working area..
77 DDE-ROW-INDEX PIC 9(8) COMP-5.
77 DDE-TEXT-WORK PIC X(30).
77 DDE-NUMERIC-WORK PIC 9(9).
01 POINT-CURRENT-TOP PIC 9(9) COMP-5.
PROCEDURE DIVISION.
* When a cell in the Excel table is modified, it is also modified
* in the table and the user is notified of this change.
MOVE "The Excel table has been updated." TO POW-TEXT OF LABEL2.
* Obtain modified data from the EXCEL file.
MOVE POW-DDEDATA OF DDE1 TO DDE-EXCEL-DATA.
* Decompose each line of data.
UNSTRING DDE-EXCEL-DATA DELIMITED BY X"0D0A"
INTO DDE-ROW ( 1 )
DDE-ROW ( 2 )
END-UNSTRING.
* Decompose the data from each line into cells.
MOVE 1 TO POINT-CURRENT-TOP
PERFORM VARYING DDE-ROW-INDEX FROM 1 BY 1
UNTIL DDE-ROW-INDEX > MAX-ROW-NUMBER
UNSTRING DDE-ROW ( DDE-ROW-INDEX )
DELIMITED BY ","
INTO DDE-COL-DATA1 ( DDE-ROW-INDEX )
DDE-COL-DATA2 ( DDE-ROW-INDEX )
WITH POINTER POINT-CURRENT-TOP
END-UNSTRING
UNSTRING DDE-ROW ( DDE-ROW-INDEX )
DELIMITED BY SPACE
INTO DDE-COL-DATA3 ( DDE-ROW-INDEX )
WITH POINTER POINT-CURRENT-TOP
END-UNSTRING
END-PERFORM.
* Set the decomposed Excel data to each cell of the
* table.
PERFORM VARYING DDE-ROW-INDEX FROM 1 BY 1
UNTIL DDE-ROW-INDEX > MAX-ROW-NUMBER
MOVE DDE-COL-DATA1 ( DDE-ROW-INDEX ) TO DDE-TEXT-WORK
CALL SETCELLTEXT OF TABLE1 USING DDE-TEXT-WORK DDE-ROW-INDEX 1
MOVE DDE-COL-DATA2 ( DDE-ROW-INDEX ) TO DDE-TEXT-WORK
CALL SETCELLTEXT OF TABLE1 USING DDE-TEXT-WORK DDE-ROW-INDEX 2
MOVE DDE-COL-DATA3 ( DDE-ROW-INDEX ) TO DDE-NUMERIC-WORK
CALL SETCELLNUMERIC OF TABLE1 USING DDE-NUMERIC-WORK DDE-ROW-INDEX 3
END-PERFORM.
@POWER POWPSBTN PUSH1 CLICK
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
* Set the area where the data from EXCEL is to be received.
77 DDE-EXCEL-DATA PIC X(4096).
* Set the area to decompose the data from EXCEL into each table cell.
01 DDE-ROW-DATA.
02 DDE-ROW PIC X(100) OCCURS MAX-ROW-NUMBER TIMES.
01 DDE-COL-DATA.
02 DDE-DATA-ROW OCCURS MAX-ROW-NUMBER TIMES.
03 DDE-COL-DATA1 PIC X(20).
03 DDE-COL-DATA2 PIC X(20).
03 DDE-COL-DATA3 PIC 9(9).
* Set the working area.
77 DDE-ROW-INDEX PIC 9(8) COMP-5.
77 DDE-TEXT-WORK PIC X(30).
77 DDE-NUMERIC-WORK PIC 9(9).
01 POINT-CURRENT-TOP PIC 9(9) COMP-5.
PROCEDURE DIVISION.
* Open a conversation with the DDE server and begin the advise loop.
CALL OPENDDE OF DDE1.
* Obtain the table data from the specified EXCEL file.
MOVE POW-DDEDATA OF DDE1 TO DDE-EXCEL-DATA.
* Decompose each line of data.
UNSTRING DDE-EXCEL-DATA DELIMITED BY X"0D0A"
INTO DDE-ROW ( 1 )
DDE-ROW ( 2 )
END-UNSTRING.
* Decompose the data from each line into cells.
PERFORM VARYING DDE-ROW-INDEX FROM 1 BY 1
UNTIL DDE-ROW-INDEX > MAX-ROW-NUMBER
MOVE 1 TO POINT-CURRENT-TOP
UNSTRING DDE-ROW ( DDE-ROW-INDEX )
DELIMITED BY ","
INTO DDE-COL-DATA1 ( DDE-ROW-INDEX )
DDE-COL-DATA2 ( DDE-ROW-INDEX )
WITH POINTER POINT-CURRENT-TOP
END-UNSTRING
UNSTRING DDE-ROW ( DDE-ROW-INDEX )
DELIMITED BY SPACE
INTO DDE-COL-DATA3 ( DDE-ROW-INDEX )
WITH POINTER POINT-CURRENT-TOP
END-UNSTRING
END-PERFORM.
* Set the decomposed Excel data to each cell of the
* table.
PERFORM VARYING DDE-ROW-INDEX FROM 1 BY 1
UNTIL DDE-ROW-INDEX > MAX-ROW-NUMBER
MOVE DDE-COL-DATA1 ( DDE-ROW-INDEX ) TO DDE-TEXT-WORK
CALL SETCELLTEXT OF TABLE1 USING DDE-TEXT-WORK DDE-ROW-INDEX 1
MOVE DDE-COL-DATA2 ( DDE-ROW-INDEX ) TO DDE-TEXT-WORK
CALL SETCELLTEXT OF TABLE1 USING DDE-TEXT-WORK DDE-ROW-INDEX 2
MOVE DDE-COL-DATA3 ( DDE-ROW-INDEX ) TO DDE-NUMERIC-WORK
CALL SETCELLNUMERIC OF TABLE1 USING DDE-NUMERIC-WORK DDE-ROW-INDEX 3
END-PERFORM.
@POWER POWPSBTN PUSH2 CLICK
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
* Close the sample application.
CALL CLOSESHEET OF SHEET1.