TERM [port]
A terminal program for a serial port. TERM opens port (COM2, where the PCjs demo pages put a modem, unless port names another, with or without the settings that MODE accepts, eg, COM1:9600,N,8,1), sends each key typed to it, and displays everything it receives, until CTRL-] ends TERM. Keys without a character (eg, the arrow keys) aren’t sent.
TERM carries out the ANSI escape sequences that most bulletin board systems send: ESC [ row;col H (or f) moves the cursor, ESC [ n A, B, C, and D move it up, down, right, and left, ESC [ 2 J clears the screen, ESC [ K erases the rest of the line, and ESC [ n;… m sets the colors (0 resets them, 1 is bold, 30-37 set the foreground color, and 40-47 the background). Any other escape sequence is dropped.
The modem on COM2 of the 20Mb Drive and Networking demo pages answers the usual Hayes AT commands (eg, ATI3 lists the numbers in its phone book), which TERM lets you type, and ATDT number dials one of them (ATH hangs up). A PCjs modem can also dial a host on the Internet: ATDT host:port (or just host, if it has a . in it, for port 23) connects to it, and carries out the Telnet protocol for you, so ATDT bbs.example.com:2323 reaches a Telnet BBS (the Telnet BBS Guide lists hundreds). For example:
TERM
ATDT telehack.com
connects to Telehack, a re-creation of the 1980s ARPANET and Usenet, and ATDT vert.synchro.net to Vertrauen, the home BBS of Synchronet. NO ANSWER means the host couldn’t be reached, and NO CARRIER that it ended the call. On a web page, the modem reaches a host through a relay, which allows only port 23 and ports 1024 and up; in pc.js, --modem gives COM2 a modem that can dial any host.
A port without settings is opened as COM2:9600,N,8,1,RTS,1024 (or COM1, and so on), which uses RTS/CTS flow control (the RTS option of CON=): whenever TERM falls behind (eg, displaying a screenful of colors on a 4.77 MHz PC), the port drops RTS, and the modem holds what it receives until TERM catches up, so nothing is lost. With settings of your own, add RTS for the same, if the other end supports it (eg, TERM COM1:9600,N,8,1,RTS); without it, characters that arrive while TERM is behind can be lost.
If port can’t be opened, TERM displays Device unavailable and sets ERRORLEVEL to 68, Device timeout and 24, or Unable to use port and the error’s number. A switch (TERM has none), a second operand, or a port that isn’t a COM port is a usage error.
Source: TERM.BAS
Copyright (c) 2020-2026 Jeff Parsons Released under MIT License