Category : Files from Magazines
Archive   : DDJ-9002.ZIP
Filename : DUNTEMAN.LST

 
Output of file : DUNTEMAN.LST contained in archive : DDJ-9002.ZIP
_STRUCTURED PROGRAMMING COLUMN_
by Jeff Duntemann

[LISTING ONE]

MODULE JTerm;

(* Stony Brook Modula-2 -- Last modified 10/31/89 *)
(* by Jeff Duntemann -- For DDJ 2/90 *)

FROM CommPort IMPORT BaudRate, Parity, InitPort, StartReceiving,
StopReceiving, SendChar, GetChar, CommStatus;

FROM FileSystem IMPORT Close, File, Length, Lookup, Reset, SetPos, WriteChar;

FROM Keyboard IMPORT GetKey, CarriageReturn, LineFeed, AltX, F7, F8;

FROM Screen IMPORT CreateWindow, CloseWindow, Color, DrawBorder,
MakeColorAttr, Position, SetCursor, Window,
WriteString, WriteLn, Xpos, Ypos;

FROM Terminal IMPORT Write, CharAvail, Read;

CONST
Blink = TRUE;
NoBlink = FALSE;
AsPopup = TRUE;
NotAsPopup = FALSE;
CreateFile = TRUE;

VAR
CaptureOn : BOOLEAN;
CaptureFile : File;
ItsLength : LONGINT;
Status : CommStatus;
Ch : CHAR;
OutString : ARRAY[0..1] OF CHAR;
Keystroke : CARDINAL;
W : Window;
WhiteOnBlue : CHAR;

BEGIN
(* First set up the window to hold the terminal session: *)
WhiteOnBlue := MakeColorAttr(White,Blue,NoBlink);
W := CreateWindow(0,0,80,24,WhiteOnBlue,AsPopup);
DrawBorder(W,MakeColorAttr(White,LightCyan,NoBlink));
Position(W,1,0);
WriteString(W,'\\\\JTERM\\\\ by Jeff Duntemann ',
MakeColorAttr(Black,LightCyan,Blink));
Position(W,1,1);
SetCursor(W);

(* Here we look for the capture file CAPTURE.TXT; open it if it *)
(* exists, and create it if it doesn't: *)
Lookup(CaptureFile,"CAPTURE.TXT",CreateFile);
Length(CaptureFile,ItsLength); (* Find out how long file is... *)
SetPos(CaptureFile,ItsLength); (* ...and position it to EOF. *)
CaptureOn := FALSE; (* Default to NOT capturing text *)

(* Next, set up the interrupt-driven serial port and turn it on: *)
Status := InitPort(0,Baud1200,7,1,Even);
Status := StartReceiving(0,256);

(* We check for keystrokes, then check for incoming data: *)
LOOP (* EXIT the loop (and the program) on Alt-X *)
IF CharAvail() THEN
GetKey(Keystroke); (* Get a keystroke from the buffer *)
CASE Keystroke OF
CarriageReturn: (* If CR was pressed, send CR *AND* LF: *)
SendChar(0,CHR(CarriageReturn),FALSE);
SendChar(0,CHR(LineFeed),FALSE); |
F7: CaptureOn := TRUE; | (* F7/F8 toggle capture *)
F8: CaptureOn := FALSE; | (* on and off *)
AltX: EXIT; (* Alt-X quits the program *)
(* Send any non-command to the serial port: *)
ELSE SendChar(0,CHR(Keystroke),FALSE);
END;
END;
(* If a char's waiting in the comm buffer, get it and parse it: *)
IF GetChar(0,Ch) = Success THEN
OutString[0] := Ch;
CASE ORD(Ch) OF
(* This is how we fake TTY backspace: *)
8: IF Xpos(W) > 0 THEN
Position(W,Xpos(W)-1,Ypos(W));
WriteString(W,' ',WhiteOnBlue);
Position(W,Xpos(W)-1,Ypos(W));
SetCursor(W);
END; |
13: WriteLn(W);
SetCursor(W);
IF CaptureOn THEN
WriteChar(CaptureFile,Ch)
END; |
10: IF CaptureOn THEN
WriteChar(CaptureFile,Ch)
END;
ELSE WriteString(W,Ch,WhiteOnBlue);
SetCursor(W);
IF CaptureOn THEN
WriteChar(CaptureFile,Ch);
END;
END;
END;
END;
(* Finally, we shut down the interrupt-driven input buffer: *)
Status := StopReceiving(0);
Close(CaptureFile);
END JTerm.




  3 Responses to “Category : Files from Magazines
Archive   : DDJ-9002.ZIP
Filename : DUNTEMAN.LST

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/