3 ms·
Here's a FORTH program to simulate a 7 bit paper tape puncher. Type PTAPE <cr> and then start typing. It will terminate and cut the tape when you type a <null>.
by DonHopkins 7y ago
Here's a FORTH program to simulate a 7 bit paper tape puncher. Type PTAPE <cr> and then start typing. It will terminate and cut the tape when you type a <null>.
\ FORTH PAPER TAPE PUNCHER:
: PT# ( L --- L/2 )
DUP 1 AND IF
ASCII @
ELSE BL THEN
HOLD
2/
;
: PT. ( N --- )
<# PT# PT# PT#
ASCII . HOLD
PT# PT# PT# PT#
#> TYPE
;
: CUT
." -----------" CR
;
: PTAPE
CUT
BEGIN
KEY ?DUP WHILE
DUP ." |" PT. ." |" SPACE EMIT CR
REPEAT
CUT
;
PS: I rewrote PTAPE in PostScript for NeWS, so it makes a window with actual holes punched into it in the shape of a piece of paper tape with the text you pass in as a parameter:
https://www.donhopkins.com/home/archive/news-tape/fun/ptape/ptape https://www.donhopkins.com/home/archive/news-tape/fun/ptape/...
Can anybody write that for X11 using the SHAPES extension to punch the holes in fewer lines of code? ;)
(The comments about an elliptical canvas and round shape must have been copied from some other old code, because the shape of the window (and icon) it makes is rectangular with lots of round holes punched into it.)