home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
kpwdemo.zip
/
DDESHOWD.SRC
< prev
next >
Wrap
Text File
|
1990-06-28
|
4KB
|
140 lines
w1 is window (,15,2,50,23,,[popup,showChildren,Siblings,DialogFrame]).
text ( '
This KB provides an example of using
DDE with Microsoft Excel. In the example
Excel is loaded, KnowledgePro asks the
user to enter a value, the value is written
to an Excel spreadsheet and, an Excel
graph is displayed.
The KB assumes that Excel and ddeshow.xls
can be reached from the current path. If not,
you should change the KB to list the correct
path before running the KB.
Be sure Excel is enabled to receive DDE
requests. This is done from the Options
menu of Excel.').
b1 is button ('Continue',continue,9,19).
button ('Cancel',cancel,30,19,11).
show_window (?w1).
set_focus (?b1).
wait ().
resize_window (?w1, 50, 10).
move_window (?w1,3,2).
set_text (,'#e
One moment ..... Loading Microsoft Excel
and current sales figures').
(***** Load Excel and save its task handle. Use TASK_WINDOWS to find the
main window of Excel. Next, open two DDE channels to Excel.
The first channel lets you read and write from a spreadsheet.
The second channel lets you execute commands in Excel.
*****)
current is current_directory ().
ExcelTask is load_program ('EXCEL ddeshow.xls',0).
if ?excelTask < 32
then error ().
ExcelWindow is first (task_windows (?ExcelTask)).
Macro1 is dde_open (ExcelTopic,Excel,System).
(***** Here we ask the user of the knowledge base for a figure for this
month's unit sales. The value is written into the spreadsheet DDESHOW,
the sales from the last period is read from the spreadsheet and,
if the monthly figure has dropped, KnowledgePro tells Excel to
display a graph of the figures.
*****)
Sales is dde_open (ExcelTopic,Excel,'ddeshow.xls').
dde_execute (?Macro1,['[APP.MOVE(120,130)]','[APP.SIZE(360,200)]']).
dde_execute (?Macro1,['[SELECT("R1C1:R2C7")]','[NEW(2)]','[FULL(TRUE)]']).
wait (,1).
show_window (?ExcelWindow,1).
set_display_window (?w1).
set_active_window (?w1).
ask ('
What are the unit sales for July?
KnowledgePro will tell Excel to graph the
new sales figures.#x5#y5',NewSales).
dde_write (?Sales,r2c7,?NewSales).
dde_request (?Sales,'r2c6').
wait ().
newRequest ().
topic newRequest.
set_display_window (?w1).
down is ' This month''s unit sales have #fred DECREASED#d.
Re-Enter unit sales: '.
up is ' This month''s unit sales have #fblue INCREASED#d.
Re-Enter unit sales: '.
if ?newSales < ?lastMonth
then text (#e,?down)
else text (#e,?up).
ed1 is edit_line (?newSales).
button (Ok,ok,15,6,6).
button (Quit,quit,25,6).
set_focus (?ed1).
topic ok.
newSales is get_text (?ed1).
set_display_window (?w1).
if ?newSales < ?lastMonth
then set_text (?w1,?down)
else set_text (?w1,?up).
dde_write (?Sales,r2c7,?newSales).
set_focus (?ed1).
end.
topic Quit.
set_text (?w1,'#e
One moment ..... Unloading Microsoft Excel').
dde_close (?Sales).
dde_execute (?Macro1,['[CLOSE(FALSE)]','[CLOSE(FALSE)]','[QUIT()]']).
wait (,1).
new_kb ('demo.ckb').
end.
end. (* newRequest *)
(**** This is the DDE Topic which is defined when the DDE channel is
opened using dde_open. Whenever a DDE event occurs, this topic
is called and is passed information about the event.
*****)
topic ExcelTopic (info,event, handle).
if element (?info,2) is r2c6
then lastMonth is first (?info) and
continue ().
end.
topic error.
window (,27.42,5.187,37,10.93,,[popup,showChildren,siblings,DialogFrame]).
warn is load_icon (exclamation_icon).
text ('
Excel cannot be found. Please
put its directory in your path
before running this example.
').
icon (?warn,8,7).
b1 is button ('Continue',continue,21,7,).
show_window ().
set_focus (?b1).
wait ().
new_kb ( concat (?current,'demo.ckb')).
end.
topic cancel.
new_kb ('demo.ckb').
end.