;Super DDE Demo STOP CLEAR excelpath$ = "C:\WINDOWS" qepath$ = "C:\WINDOWS\QE" m1 = ADDBAR ADDCOMMAND(m1,2,"&WinComm Menu") sm1 = ADDMENU(m1,"DD&E") ADDCOMMAND(sm1,3,"&Client Server") ADDCOMMAND(sm1,4,"&Excel") ADDCOMMAND(sm1,5,"&Q+E") SHOWBAR(m1) MACROHALT(1) DIALOGBOX 71, 20, 235, 98, 21, "Dynamic Data Exchange Demo" LTEXT 8, 10, 225, 24, "This part of the TOUR will demonstrate WinComm acting both as a DDE Client and as a DDE Server. The Client Server menu selection requires only WinComm to be installed. The other " LTEXT 8, 34, 230, 16, "selections require Microsoft Excel and Pioneer Software Q+E to be installed and in the path. If they are not the demo will terminate." DEFCANCELBUTTON 91, 69, 50, 14, "&OK" DEND DO i = DIALOG? UNTIL(i != 255) main_loop: i = MENU? IF(i==2) GOTO win_return ELSE IF(i==3) GOTO clint_ser ELSE IF(i==4) GOTO excel ELSE IF(i==5) GOTO qpluse GOTO main_loop ;************************** DDE|Client Server ****************************** clint_ser: DIALOGBOX 87, 20, 201, 129, 21, "WinComm Client Server Demo" LTEXT 18, 11, 165, 18, "This demo will start another copy of WinComm and will exchange data with it." LTEXT 18, 31, 165, 51, "This WinComm will get the session notes from the other WinComm and then set up an ADVISE on one of its variables. Double click on the other WinComm and see the variable changing. When finished watching, close the other WinComm." DEFCANCELBUTTON 76, 98, 50, 14, "&OK" DEND DO i = DIALOG? UNTIL(i != 255) ENABLEMENU(m1,2,1) ;disable menu ENABLEMENU(sm1,3,1) ENABLEMENU(sm1,4,1) ENABLEMENU(sm1,5,1) SHOWBAR(m1) WINMOVE(1,1,638,410) ;position and size wincomm a$ = "" wcpath$ = GETSESSSTR(25) wcpath$ = wcpath$+"\WINCOMM.EXE" ddechan = DDEINIT("WINCOMM","DDESERV.WMC") ;test to see if there is a wincomm there IF(ddechan==0){ ;guess not... RUN(wcpath$,"",2) ;start one as an icon ddechan = DDEINIT("WINCOMM","DDESERV.WMC") ;same as the other DDEINIT causes WinComm IF(ddechan==0){ ;to load and run DDESERV macro ALERT("Initaite Failed, result = "+strint(ddechan )) SHOW(3) ;Things are not going well GOTO exit } } DDEREQ(ddechan,a$,"1000") ;asking for the "notes" string variable of the session file PRINT("Notes are ["+a$+"]^M^J") ;DDE session integers and strings are identified using the a$="" ;id's in the macro manual + 1000 DDEADVISE(ddechan,a$,"a$") ;asks the other wincomm to let this one know when its a$ variable again: ;has changed i = TIME?+5 ; DO ;a test to see when the other wincomm UNTIL( (NULL(a$)!=1) || (TIME?>i)) ;goes away---if nothing happens in five IF(TIME?>i){ ;seconds, shut this sucker down SHOW(3) ; GOTO exit ; } PRINT(a$+"^M^J") ;otherwise print the variable sent from the other wincomm a$="" goto again ;************************* DDE|Excel *************************************** excel: CLEAR chartchan = 0 ENABLEMENU(m1,2,1) ;disable menu ENABLEMENU(sm1,3,1) ENABLEMENU(sm1,4,1) ENABLEMENU(sm1,5,1) SHOWBAR(m1) DIALOGBOX 87, 27, 201, 83, 21, "WinComm Client/Excel Server Demo" LTEXT 18, 11, 157, 18, "For this demo to work, Excel must be installed with the the path below." DEFPUSHBUTTON 43, 65, 50, 14, "&OK" CANCELBUTTON 102, 65, 50, 14, "&Cancel" EDIT 19, 47, 157, 12, excelpath$ LTEXT 19, 33, 45, 9, "Excel Path:" DEND DO dg = DIALOG? UNTIL(dg != 255) IF(dg == 0) GOTO exit1 a$ = "" ddechan = DDEINIT("EXCEL","Sheet1") ;now try dde if(ddechan==0){ inst = RUN(excelpath$+"\excel.exe","",1) ;start EXCEL if(inst<32){ ALERT("Problem running EXCEL. Check path or available memory and re-run.") GOTO exit1 } ddechan = DDEINIT("EXCEL"+STRINT(inst),"Sheet1") ;now try it again if(ddechan==0){ ALERT("Excel Initiate Failed, result = "+strint(ddechan )) GOTO exit1 } } WINMOVE(0,240,640,240) ;position and size wincomm syschan = DDEINIT("EXCEL","System") ;set up a system channel to take control of Excel DDEEXEC(syschan,"[APP.RESTORE()]") ;if excel is maximized it must be restored DDEEXEC(syschan,"[APP.MOVE(0,0)]") ;to change its size DDEEXEC(syschan,"[APP.SIZE(480,180)]") ;which we do here DDEEXEC(syschan,"[FULL(TRUE)]") ;makes sheet1 full size DDEEXEC(syschan,"[COLUMN.WIDTH(75)]") ;widens the A column ;the following pokes give instructions for operation of this demo DDEPOKE(ddechan,"R1C1","This is a demonstration of WinComms Client DDE Macro Capability") DDEPOKE(ddechan,"R2C1","Excel and WinComm have been positioned on the screen by the WinComm Macro.") DDEPOKE(ddechan,"R3C1","Cell A5 is set up as an ADVISE to WinComm. Whatever is typed there will display") DDEPOKE(ddechan,"R4C1","in the WinComm Window. Try it! Type EXIT in A5 to quit or CHART for a chart demo.") DDEADVISE(ddechan,a$,"R5C1") ;this is where the instructions come from i = 1 DO SENDSPECKEY(0,0,40) i = i+1 UNTIL(i == 5) ;move the active cell to A5 again1: a1$ = a$ DO UNTIL(CMP(a1$,a$) != TRUE) ;test to see when there is a change in A5 PRINT(a$) ;if there is display it a$ = UPPERCASE(a$) IF(CMP(a$,"EXIT"+CHAR(13)+CHAR(10)) == TRUE){ ;test here to see if "exit" has been typed in DDEUNADVISE(ddechan,"R5C1") ;if so shut everything down GOTO terminate } ELSE IF(CMP(a$,"CHART"+CHAR(13)+CHAR(10)) == TRUE) GOTO chart ;test here to see if "chart" was typed GOTO again1 ;if neither, go look for more changes chart: DDEEXEC(syschan,"[APP.MAXIMIZE()]") ;maximize excel for full effect DDEPOKE(ddechan,"R11C2","5/1") ;put a date value in row 11 collumn 2 i = 1 DO SENDSPECKEY(0,0,40) ;move selected cell i = i+1 ;down UNTIL(i == 7) ;seven positions SENDSPECKEY(0,0,39) ;and right one i = 1 ;to position it at r11c2 DO SENDSPECKEY(3,0,39) ;move the active cell right i = i+1 ;12 positions with the shift UNTIL(i == 12) ;key down--thats what the 3 does DDEEXEC(ddechan,"[DATA.SERIES(1,3,3)]") ;this data series gives us 12 months j=0 i=0 DO col = j + 2 ;this loop puts some vaules under the 12 months DDEPOKE(ddechan,"R12C"+STRINT(col),STRINT(i)) j=j+1 i=i+100 UNTIL(j == 12) SENDSPECKEY(3,0,40) ;shift down SENDSPECKEY(3,0,35) ;shift --the dates and the values are now selected DDEEXEC(syschan,"[NEW(2)]") ;open a new chart if(chartchan==0) chartchan = DDEINIT("EXCEL","Chart1") ;Set up channel to chart DDEEXEC(syschan,"[GALLERY.LINE(2)]") ;change to a line chart DDEEXEC(syschan,"[ATTACH.TEXT(1)]") ;set up to do title text SENDSPECKEY(0,0,32) ;sets the "edit" check SENDKEY("Widget Sales") ;type it in SENDSPECKEY(0,0,13) ;enters the text delay = TIME? + 5 DO UNTIL(delay == TIME?) DDEEXEC(syschan,"[ACTIVATE.NEXT()]") ;lets go back and look at the sheet j=5 i=300 ;this loop modifies some of the numbers DO DDEPOKE(ddechan,"R12C"+STRINT(j),STRINT(i)) j=j+1 i=i+1000 UNTIL(j == 14) DDEEXEC(syschan,"[ACTIVATE.NEXT()]") DDEEXEC(syschan,"[ATTACH.TEXT(4,1,4)]") ;some text at data point 4 SENDSPECKEY(0,0,32) SENDKEY("After Advertising") SENDSPECKEY(0,0,13) delay = TIME? + 5 DO UNTIL(delay == TIME?) DDETERM(chartchan) DDEEXEC(syschan,"[ARRANGE.ALL()]") ;move some things around DDEEXEC(syschan,"[ACTIVATE.NEXT()]") SENDSPECKEY(0,0,36) i = 1 DO SENDSPECKEY(0,0,38) i = i+1 UNTIL(i == 7) ;reposition the active cell to the advise cell DDEEXEC(syschan,"[APP.RESTORE()]") GOTO again1 ;start looking for some thing else terminate: ;we want to shut things down now DDETERM(ddechan) DDEEXEC(syschan,"[CLOSE(FALSE)]") ; we had a chart ignore excel save if(chartchan) DDEEXEC(syschan,"[CLOSE(FALSE)]") DDEEXEC(syschan,"[QUIT()]") SHOW(3) GOTO exit ;lets go back and process the menu bar ;******************************** DDE|Q+E ********************************** qpluse: CLEAR ; clear screen ENABLEMENU(m1,2,1) ; disable menu ENABLEMENU(sm1,3,1) ENABLEMENU(sm1,4,1) ENABLEMENU(sm1,5,1) SHOWBAR(m1) DIALOGBOX 87, 20, 212, 104, 21, "WinComm Client/Q+E Server Demo" LTEXT 8, 18, 198, 33, "For this demo to work, 'Q+E' must be installed and in the path given below. The default query will select all cities so you can see the entries in the other fields for your own queries." CANCELBUTTON 118, 80, 50, 14, "&Cancel" DEFPUSHBUTTON 43, 80, 50, 14, "&OK" EDIT 13, 63, 188, 12, QEPATH$ LTEXT 13, 52, 42, 9, "Q+E path:" DEND DO dg=DIALOG? UNTIL(dg != 255) IF(dg==0) GOTO exit1 macropath$ = GETSESSSTR(28) FCLOSE(FOPEN(4096,macropath$+"\QUERY.TXT")) ;create a null file query.txt query1$ = macropath$+"\QUERY.TXT" ddechan = DDEINIT("QE","SYSTEM") IF(ddechan==0){ inst = RUN(qepath$+"\QE.EXE","",2) IF(inst < 32){ ALERT("Problem running Q+E. Check path or available memory and re-run.") GOTO exit1 } ddechan = DDEINIT("QE","SYSTEM") IF(ddechan==0){ ALERT("Q+E Initiate Failed, result = "+strint(ddechan )) GOTO exit1 } } WINMOVE(1,1,638,400) ;position and size wincomm ACTIVATE ;give the focus back to WinComm to display dialog box VAR1$="Fill in Query Form:" city$ = "%" DIALOGBOX 70, 5, 204, 190, 21, "Opportunity Query" VTEXT 49, 13, 107, 9, VAR1$ CTEXT 52, 23, 23, 9, "City:" EDIT 11, 33, 110, 12, CITY$ CTEXT 149, 23, 26, 9, "State:" EDIT 143, 32, 40, 12, STATE$ CTEXT 46, 46, 42, 9, "Specialty:" EDIT 11, 55, 110, 12, SPECIALTY$ CTEXT 147, 46, 31, 9, "Region:" EDIT 143, 55, 40, 12, REGION$ UPDATEPB 19, 90, 65, 14, "&Query" CANCELBUTTON 119, 90, 65, 14, "&Cancel" STEXT 4, 126, 195, 61, QUERY1$ CTEXT 75, 110, 58, 9, "Query Results" LTEXT 9, 74, 191, 9, "* or % can be used as a 'select all' wildcard." DEND again2: DO dg=DIALOG? UNTIL(dg!=255) IF(dg==100){ ENABLECTL(0,0) ENABLECTL(100,0) ;disable push buttons during query b$ = "" SUBST("*",CITY$,"%",99) SUBST("?",CITY$,"_",99) a$="'SELECT CITY,STATE,SPECIALTY FROM "+macropath$+"\OPP.DBF WHERE " if(NULL(CITY$)==0) b$= b$+"(City LIKE "+QUOTE(CITY$)+" OR "+"SUBURB_OF LIKE "+QUOTE(CITY$)+") AND " if(NULL(STATE$)==0) b$= b$+"State LIKE "+QUOTE(STATE$)+" AND " if(NULL(REGION$)==0) b$= b$+"REGION LIKE "+QUOTE(REGION$)+" AND " if(NULL(SPECIALTY$)==0) b$= b$+"Specialty LIKE "+QUOTE(SPECIALTY$)+" AND " b$ = left(b$,len(b$)-5) b$ = UPPERCASE(b$) b$ = b$+"'" PRINT("^M^J") DDEEXEC(ddechan,"[OPEN("+a$+b$+")]") PRINT(a$+b$) DDEEXEC(ddechan,"[SAVE.TEXT.AS("+"'"+macropath$+"\QUERY.TXT',80,60,FALSE,FALSE)]") Var1$="Enter New Query" ENABLECTL(0,1) ENABLECTL(100,1) ;re-enable push buttons UPDATEDLG(255) GOTO again2 } DDEEXEC(ddechan,"[EXIT()]") DDETERM(ddechan) DELETEFILE(macropath$+"\QUERY.TXT") ;delete file query.txt SHOW(3) exit: CLEAR SHOW(1) exit1: ENABLEMENU(m1,2,0) ;re-enable the menu items ENABLEMENU(sm1,3,0) ENABLEMENU(sm1,4,0) ENABLEMENU(sm1,5,0) SHOWBAR(m1) GOTO main_loop ;go back to menu bar processing ;****** WinComm Menu ** win_return: ;somebody wants to go back to wincomms menu i = GETSESSINT(68) PUTSESSINT(68,0) ; disable auto sizing OPEN("TOUR.WSF","",1) PUTSESSINT(68,i) ; disable auto sizing HALT END