(FILECREATED "14-May-86 16:24:37" {QV}<NOTECARDS>1.2K>LIBRARY>LEXDEMO.;1 17129 changes to: (VARS LEXDEMOCOMS) previous date: "24-Oct-85 17:49:01" {QV}<NOTECARDS>RELEASE1.2I>LIBRARY>LEXDEMO.;16) (* Copyright (c) 1985, 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT LEXDEMOCOMS) (RPAQQ LEXDEMOCOMS ((FNS LEXDEMO.MakeMainMenu LEXDEMO.TURNON SPECIALFUNCTIONKEYS LISTEN CHANGEDISPLAYSTATE CREPLACE DEALWITH DIALPHONENUMBER DISPLAYPAIRFROM GETCHARATTRIBUTE GETESCAPESEQUENCE PHONEPADMENU PRINT.INPUTBLOCK REVERSETEXT UNDERLINETEXT TALK LEXDEMO.SHUTOFF) (FILES (FROM LISPUSERS) DLRS232C RS232CHAT) (P (MOVEW (SETQ LEXDEMO.MainMenu (ADDMENU (LEXDEMO.MakeMainMenu NC.MainMenuWindow))) (fetch LEFT of (GETWINDOWPROP NC.MainMenuWindow (QUOTE REGION))) (DIFFERENCE (fetch BOTTOM of (GETWINDOWPROP NC.MainMenuWindow (QUOTE REGION))) (fetch HEIGHT of (GETWINDOWPROP LEXDEMO.MainMenu (QUOTE REGION)))))))) (DEFINEQ (LEXDEMO.MakeMainMenu [LAMBDA (MAINWINDOW) (* Todd "28-Aug-85 16:26") (create MENU ITEMS ←[LIST (LIST "ON" (QUOTE (LEXDEMO.TURNON))) (LIST "OFF" (QUOTE (LEXDEMO.SHUTOFF] TITLE ← "Lexis Interface" CENTERFLG ← T MENUFONT ←(FONTCREATE (QUOTE HELVETICA) 12 (QUOTE BRR)) MENUCOLUMNS ← 2 ITEMHEIGHT ← 25 ITEMWIDTH ←(IQUOTIENT (DIFFERENCE (fetch WIDTH of (GETWINDOWPROP MAINWINDOW (QUOTE REGION) )) 2) 2) MENUBORDERSIZE ← 1]) (LEXDEMO.TURNON (LAMBDA NIL (* fgh: "24-Oct-85 00:05") (* * LEXDEMO.TURNON initiates an RS232 interface to a LEXIS/NEXIS host machine. It creates a record of the transception, which is saved as {DSK}<LISPFILES>LEXIS-SESSION, and provides a shift-selection capability while the transception is in progress. --- John Todd) (PROG ((LEXSTREAM (OPENSTREAM (QUOTE {CORE}LEXIS-SESSION) (QUOTE BOTH))) (LEXWINDOW (CREATEW (GETBOXREGION 600 400 NIL NIL NIL "Please specify area for LEXIS display window") "LEXIS display window")) (REPLYWINDOW (CREATEW (CREATEREGION 0 0 600 80) NIL 8)) TextStream TempString TempStringStream InsertString RS232InputStream RS232OutputStream FUNCTIONKEYS.MENU) (SETQ TextStream (OPENTEXTSTREAM NIL LEXWINDOW NIL NIL (QUOTE (READONLY T)))) (SETQ TempStringStream (OPENSTRINGSTREAM (SETQ TempString (ALLOCSTRING 8000)) (QUOTE BOTH))) (SETQ InsertString "") (ATTACHWINDOW REPLYWINDOW LEXWINDOW (QUOTE BOTTOM) (QUOTE LEFT)) (SETQ FUNCTIONKEYS.MENU (ADDMENU (SPECIALFUNCTIONKEYS LEXWINDOW))) (SETQ LEXDEMOWINDOWS (LIST LEXWINDOW REPLYWINDOW FUNCTIONKEYS.MENU)) (ATTACHWINDOW FUNCTIONKEYS.MENU LEXWINDOW (QUOTE RIGHT) (QUOTE BOTTOM)) (RS232C.INIT 1200 7 (QUOTE EVEN) 1) (SETQ RS232InputStream (OPENSTREAM (QUOTE {RS232}) (QUOTE INPUT))) (SETQ RS232OutputStream (RS232C.OTHER.STREAM RS232InputStream)) (WINDOWPROP FUNCTIONKEYS.MENU (QUOTE RS232OutputStream) RS232OutputStream) (WINDOWPROP LEXWINDOW (QUOTE RS232OutputStream) RS232OutputStream) (WINDOWPROP LEXWINDOW (QUOTE RS232InputStream) RS232InputStream) (DIALPHONENUMBER RS232OutputStream) (ADD.PROCESS (LIST (QUOTE LISTEN) LEXSTREAM LEXWINDOW FUNCTIONKEYS.MENU TextStream TempString TempStringStream InsertString RS232InputStream RS232OutputStream)) (ADD.PROCESS (LIST (QUOTE TALK) REPLYWINDOW RS232OutputStream))))) (SPECIALFUNCTIONKEYS (LAMBDA (WINDOW) (* fgh: "23-Oct-85 23:57") (create MENU ITEMS ←(QUOTE (("NEXT PAGE" ".NP") ("PREVIOUS PAGE" ".PP") ("FIRST PAGE" ".FP") ("NEXT DOCUMENT" ".ND") ("PREVIOUS DOCUMENT" ".PD") ("FIRST DOCUMENT" ".FD") ("KWIC" ".KW") ("FULL" ".FU") ("CITE" ".CI") ("SEGMTS" ".SE") ("SELECT SERV" ".SS") ("EXIT SERV" ".ES") ("PRINT DOCUMENT" ".PR") ("MAIL IT" ".MI") ("SCREEN PRINT" ".SP") ("NEW SEARCH" ".NS") ("CHANGE FILE" ".CF") ("CHANGE LIBRARY" ".CL") ("SIGN OFF" ".SO"))) TITLE ← "SPECIAL KEY FUNCTIONS" CENTERFLG ← T MENUFONT ←(FONTCREATE (QUOTE HELVETICA) 10 (QUOTE BOLD)) MENUCOLUMNS ← 2 MENUBORDERSIZE ← 1 WHENSELECTEDFN ←(FUNCTION (LAMBDA (ITEM MENUNAME MOUSEKEY) (LET ((RS232OutputStream (WINDOWPROP (WFROMMENU MENUNAME) (QUOTE RS232OutputStream)))) (PRIN1 (CONCAT (CADR ITEM) (CHARACTER 13)) RS232OutputStream) (FORCEOUTPUT RS232OutputStream))))))) (LISTEN (LAMBDA (LEXSTREAM LEXWINDOW FUNCTIONKEYS.MENU TextStream TempString TempStringStream InsertString RS232InputStream RS232OutputStream) (* fgh: "24-Oct-85 09:58") (* * comment) (LET ((ReadpEvent (RS232C.READP.EVENT RS232InputStream))) (PUTWINDOWPROP LEXWINDOW (QUOTE CHARDISPLAYBEGIN) 0) (PUTWINDOWPROP LEXWINDOW (QUOTE CHARDISPLAYSTATE) (QUOTE NORMAL)) (PUTWINDOWPROP LEXWINDOW (QUOTE PAGEBEGIN) 0) (PUTWINDOWPROP LEXWINDOW (QUOTE REVLIST) (TCONC NIL 1)) (PUTWINDOWPROP LEXWINDOW (QUOTE UNDLIST) (TCONC NIL 1)) (while T do (AWAIT.EVENT ReadpEvent) (while (READP RS232InputStream) do (DEALWITH (BIN RS232InputStream) RS232InputStream TempStringStream LEXSTREAM LEXWINDOW)) (PRINT.INPUTBLOCK TempString TempStringStream InsertString TextStream LEXWINDOW))))) (CHANGEDISPLAYSTATE (LAMBDA (DISPLAYWINDOW NEWSTATE TempStringStream) (* fgh: "24-Oct-85 09:17") (LET ((CHARDISPLAYSTATE (GETWINDOWPROP DISPLAYWINDOW (QUOTE CHARDISPLAYSTATE))) (CHARDISPLAYBEGIN (GETWINDOWPROP DISPLAYWINDOW (QUOTE CHARDISPLAYBEGIN)))) (COND ((EQUAL CHARDISPLAYSTATE NEWSTATE) NIL) (T (COND ((EQUAL CHARDISPLAYSTATE (QUOTE REVERSE)) (TCONC (GETWINDOWPROP DISPLAYWINDOW (QUOTE REVLIST)) (DISPLAYPAIRFROM CHARDISPLAYBEGIN TempStringStream))) ((EQUAL CHARDISPLAYSTATE (QUOTE UNDERLINE)) (TCONC (GETWINDOWPROP DISPLAYWINDOW (QUOTE UNDLIST)) (DISPLAYPAIRFROM CHARDISPLAYBEGIN TempStringStream)))) (WINDOWPROP DISPLAYWINDOW (QUOTE CHARDISPLAYBEGIN) (GETFILEPTR TempStringStream)))) NEWSTATE))) (CREPLACE [LAMBDA (INCHAR) (* Todd "13-Jun-85 16:42") (SELECTQ INCHAR (0 32) (10 32) (127 32) (NIL 32) (LOGAND 127 INCHAR]) (DEALWITH (LAMBDA (INCHAR RS232InputStream TempStringStream LEXSTREAM LEXWINDOW) (* fgh: "24-Oct-85 09:58") (* * Looking for acceptable control characters.) (AND LEXSTREAM (BOUT LEXSTREAM INCHAR)) (SELECTQ (CREPLACE INCHAR) (7 (RINGBELLS)) (27 (GETESCAPESEQUENCE LEXWINDOW (BIN RS232InputStream) RS232InputStream TempStringStream)) (BOUT TempStringStream (CREPLACE INCHAR))))) (DIALPHONENUMBER (LAMBDA (RS232OutputStream) (* fgh: "24-Oct-85 14:49") (* * comment) (PROG (PrintString CH (KEYPADMENU (ADDMENU (PHONEPADMENU)))) (PROMPTPRINT "Please dial desired telephone number.") (PUTWINDOWPROP KEYPADMENU (QUOTE PROCESS) (THIS.PROCESS)) (WINDOWPROP KEYPADMENU (QUOTE DIALEVENT) (CREATE.EVENT)) (PUTWINDOWPROP KEYPADMENU (QUOTE BUFFER) NIL) (SETQ PrintString (CONCAT "I" (CHARACTER 13))) (while (SETQ CH (GNC PrintString)) do (PRIN1 CH RS232OutputStream) (FORCEOUTPUT RS232OutputStream)) (DISMISS 10000) (SETQ PrintString (CONCAT (CHARACTER 5) (CHARACTER 13))) (while (SETQ CH (GNC PrintString)) do (PRIN1 CH RS232OutputStream) (FORCEOUTPUT RS232OutputStream)) (DISMISS 1000) (SETQ PrintString (CONCAT "D" (CHARACTER 13))) (while (SETQ CH (GNC PrintString)) do (PRIN1 CH RS232OutputStream) (FORCEOUTPUT RS232OutputStream)) (DISMISS 1000) (SETQ PrintString (CONCAT (PROGN (AWAIT.EVENT (WINDOWPROP KEYPADMENU (QUOTE DIALEVENT))) (WINDOWPROP KEYPADMENU (QUOTE BUFFER))) (CHARACTER 13))) (while (SETQ CH (GNC PrintString)) do (PRIN1 CH RS232OutputStream) (FORCEOUTPUT RS232OutputStream)) (DISMISS 1000) (SETQ PrintString (CONCAT (CHARACTER 13))) (while (SETQ CH (GNC PrintString)) do (PRIN1 CH RS232OutputStream) (FORCEOUTPUT RS232OutputStream))))) (DISPLAYPAIRFROM (LAMBDA (DISPLAYBEGIN TempStringStream) (* fgh: "24-Oct-85 17:04") (* * comment) (CONS (ADD1 DISPLAYBEGIN) (DIFFERENCE (GETFILEPTR TempStringStream) (ADD1 DISPLAYBEGIN))))) (GETCHARATTRIBUTE (LAMBDA (LEXWINDOW INCHAR RS232InputStream TempStringStream) (* fgh: "24-Oct-85 09:18") (* * Control character indicates a change of display mode. What to change it to?) (SELECTQ (CREPLACE INCHAR) (48 (WINDOWPROP LEXWINDOW (QUOTE CHARDISPLAYSTATE) (CHANGEDISPLAYSTATE LEXWINDOW (QUOTE NORMAL) TempStringStream)) (GETCHARATTRIBUTE LEXWINDOW (BIN RS232InputStream) RS232InputStream TempStringStream)) (50 (CREPLACE (BIN RS232InputStream))) (52 (WINDOWPROP LEXWINDOW (QUOTE CHARDISPLAYSTATE) (CHANGEDISPLAYSTATE LEXWINDOW (QUOTE UNDERLINE) TempStringStream)) (GETCHARATTRIBUTE LEXWINDOW (BIN RS232InputStream) RS232InputStream TempStringStream)) (55 (WINDOWPROP LEXWINDOW (QUOTE CHARDISPLAYSTATE) (CHANGEDISPLAYSTATE LEXWINDOW (QUOTE REVERSE) TempStringStream)) (GETCHARATTRIBUTE LEXWINDOW (BIN RS232InputStream) RS232InputStream TempStringStream)) NIL))) (GETESCAPESEQUENCE (LAMBDA (LEXWINDOW NEXTCHAR RS232InputStream TempStringStream) (* fgh: "24-Oct-85 09:19") (* * Found conrol character. What does it mean?) (SELECTQ (CREPLACE NEXTCHAR) (61 NIL) (91 (GETCHARATTRIBUTE LEXWINDOW (BIN RS232InputStream) RS232InputStream TempStringStream)) NIL))) (PHONEPADMENU [LAMBDA NIL (* GSC "17-Oct-85 23:42") (create MENU ITEMS ←(QUOTE (1 2 3 4 5 6 7 8 9 * 0 # "," "Done" "Redial")) TITLE ← "Phone keypad" CENTERFLG ← T MENUCOLUMNS ← 3 MENUFONT ←(FONTCREATE (QUOTE HELVETICA) 12 (QUOTE BRR)) ITEMHEIGHT ← 30 ITEMWIDTH ← 45 MENUBORDERSIZE ← 1 WHENSELECTEDFN ←(FUNCTION (LAMBDA (ITEM MENU BUTTON) (COND ((EQUAL ITEM "Done") (NOTIFY.EVENT (WINDOWPROP (WFROMMENU MENU) (QUOTE DIALEVENT))) (CLOSEW (WFROMMENU MENU)) (CLEARW PROMPTWINDOW)) ((EQUAL ITEM "Redial") (WINDOWPROP (WHICHW) (QUOTE BUFFER) NIL) (PROMPTPRINT "Please dial desired telephone number.")) (T (PRIN1 ITEM PROMPTWINDOW) (WINDOWPROP (WHICHW) (QUOTE BUFFER) (COND ((NULL (GETWINDOWPROP (WHICHW) (QUOTE BUFFER))) (MKSTRING ITEM)) (T (CONCAT (GETWINDOWPROP (WHICHW) (QUOTE BUFFER)) ITEM]) (PRINT.INPUTBLOCK (LAMBDA (TempString TempStringStream InsertString TextStream LEXWINDOW) (* fgh: "24-Oct-85 09:56") (* * The host machine has stopped transmitting for WAITTIME. Respond by displaying the host machine's output.) (LET (InsertPoint) (AND (SUBSTRING TempString 1 (GETFILEPTR TempStringStream) InsertString) (TEDIT.INSERT TextStream InsertString (SETQ InsertPoint (GETEOFPTR TextStream)) NIL NIL)) (SETFILEPTR TempStringStream 0) (WINDOWPROP LEXWINDOW (QUOTE REVLIST) (REVERSETEXT LEXWINDOW TextStream InsertPoint)) (WINDOWPROP LEXWINDOW (QUOTE UNDLIST) (UNDERLINETEXT LEXWINDOW TextStream InsertPoint)) (WINDOWPROP LEXWINDOW (QUOTE CHARDISPLAYBEGIN) 0) NIL))) (REVERSETEXT (LAMBDA (DISPLAYWINDOW TextStream InsertPoint) (* fgh: "24-Oct-85 09:54") (* * An input block has been read. Given the positions and lengths of reverse-videod sections in REVLIST, display the text block.) (PROG ((REVLIST (GETWINDOWPROP DISPLAYWINDOW (QUOTE REVLIST))) SELECTION) (for X in (NTH (CAR REVLIST) 2) do (SETQ SELECTION (TEDIT.SETSEL TextStream (IPLUS InsertPoint (CAR X)) (CDR X) (QUOTE LEFT))) (TEDIT.LOOKS TextStream (QUOTE (FACE BRR)))) (TEDIT.SHOWSEL TextStream NIL) (RETURN (TCONC NIL 1))))) (UNDERLINETEXT (LAMBDA (DISPLAYWINDOW TextStream InsertPoint) (* fgh: "24-Oct-85 17:48") (* * An input block has been read. Given the positions and lengths of underlined sections in UNDLIST, display the text block.) (AND NIL (PROG ((UNDLIST (GETWINDOWPROP DISPLAYWINDOW (QUOTE UNDLIST))) SELECTION) (for X in (NTH (CAR UNDLIST) 2) do (SETQ SELECTION (TEDIT.SETSEL TextStream (IPLUS InsertPoint (CAR X)) (CDR X) (QUOTE LEFT))) (TEDIT.LOOKS TextStream (QUOTE (UNDERLINE ON)))) (TEDIT.SHOWSEL TextStream NIL) (RETURN (TCONC NIL 1)))))) (TALK (LAMBDA (REPLYWINDOW RS232OutputStream) (* fgh: "23-Oct-85 23:54") (* * comment) (TTY.PROCESS (THIS.PROCESS)) (while T do (PRIN1 (CONCAT (COND ((PROMPTFORWORD ">" NIL NIL REPLYWINDOW NIL NIL (LIST 9 10 13 27))) (T "")) (CHARACTER 13)) RS232OutputStream) (FORCEOUTPUT RS232OutputStream) (TERPRI REPLYWINDOW)))) (LEXDEMO.SHUTOFF (LAMBDA NIL (* fgh: "24-Oct-85 00:02") (* * comment) (DEL.PROCESS (QUOTE TALK)) (DEL.PROCESS (QUOTE LISTEN)) (* CLOSEF RS232InputStream) (* CLOSEF RS232OutputStream) (COND ((BOUNDP (QUOTE LEXDEMOWINDOWS)) (for WINDOW in LEXDEMOWINDOWS do (CLOSEW WINDOW)))) (CLEARW PROMPTWINDOW) (PRIN1 (CONCAT "Closing LEXIS connection ... " (CHARACTER 13)) PROMPTWINDOW) (COND ((OPENP (QUOTE {CORE}LEXIS-SESSION)) (CLOSEF (QUOTE {CORE}LEXIS-SESSION)) (PRIN1 (CONCAT "A record of your LEXIS session is stored as " (COPYFILE (QUOTE {CORE}LEXIS-SESSION) (QUOTE {DSK}<LISPFILES>LEXIS-SESSION)) (CHARACTER 13)) PROMPTWINDOW) (DELFILE (QUOTE {CORE}LEXIS-SESSION)))) (PRIN1 "... connection closed." PROMPTWINDOW) (TERPRI PROMPTWINDOW))) ) (FILESLOAD (FROM LISPUSERS) DLRS232C RS232CHAT) (MOVEW (SETQ LEXDEMO.MainMenu (ADDMENU (LEXDEMO.MakeMainMenu NC.MainMenuWindow))) (fetch LEFT of (GETWINDOWPROP NC.MainMenuWindow (QUOTE REGION))) (DIFFERENCE (fetch BOTTOM of (GETWINDOWPROP NC.MainMenuWindow (QUOTE REGION))) (fetch HEIGHT of (GETWINDOWPROP LEXDEMO.MainMenu (QUOTE REGION))))) (PUTPROPS LEXDEMO COPYRIGHT ("Xerox Corporation" 1985 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (988 16681 (LEXDEMO.MakeMainMenu 998 . 1627) (LEXDEMO.TURNON 1629 . 3990) ( SPECIALFUNCTIONKEYS 3992 . 5184) (LISTEN 5186 . 6181) (CHANGEDISPLAYSTATE 6183 . 7078) (CREPLACE 7080 . 7297) (DEALWITH 7299 . 7833) (DIALPHONENUMBER 7835 . 9694) (DISPLAYPAIRFROM 9696 . 9966) ( GETCHARATTRIBUTE 9968 . 11123) (GETESCAPESEQUENCE 11125 . 11551) (PHONEPADMENU 11553 . 12730) ( PRINT.INPUTBLOCK 12732 . 13620) (REVERSETEXT 13622 . 14337) (UNDERLINETEXT 14339 . 15088) (TALK 15090 . 15547) (LEXDEMO.SHUTOFF 15549 . 16679))))) STOP