A Poor Programmer's Word Processor
Frank Roberts
Ft. Wayne, IN
A few days ago I walked into a local computer store for new software for my Atari 800. I was informed—just as expected—that there wasn't much available yet, "but a lot was expected real soon." Well, being impatient, low on cash and desperately wanting something besides Star Raiders to play with I decided to tackle one of those "soon-to-be-available" projects myself. After all, didn't I really buy my Atari to have fun with? The following program is a primitive (but workable) method of justifying left and right margins for letters and texts—sort of a poor man's word processor.
Program 1
1 REM ***** PSEUDO WORD PROCESSOR (D:WRITE. LET) 5 GRAPHICS 0 10 DIM A$(100), B$(100) 20 REM 30 ? :? "HOW MUCH MARGIN "; :INPUT MARGIN 40 ? :? "ENTER TEXT (IN DOUBLE LINES)" 50 ? :? "WHEN FINISHED, ENTER ‘999’" 60 ? :? "TO BEGIN, HIT RETURN "; :INPUT A $ 70 WIDTH = INT (80-(2*MARGIN)): POKE 83, INT(WIDTH)/2 + 2 80 POKE 201, MARGIN-1 90 INPUT A$: IF A$ = "999" THEN 140 95 IF LEN(A$) = 0 THEN 120 100 IF LEN(A$ = 0 WIDTH + 1 THEN B$ = A$: GOTO 120 110 GOSUB 1000 120 LPRINT " ", B$:B$ = " ": PRINT 130 GOTO 90 140 END 1000 REM ***** SUBROUTINE: JUSTIFY RIGHT MARGIN 1010 C = 0 1020 FOR J = 1 TO LEN(A$) 1030 IF LEN(B$)= WIDTH + 1 THEN 1070 1040 C = C + 1: B$(C)=A$(J) 1050 IF A$ (J,J)="" THEN C = C + 1: B$ (C, C) = " " 1060 NEXT J 1070 RETURN
Program 2.
20 OPEN #1, 8, 0, "D: FILE. LET" 50 ? :? "DO YOU WANT PRINTOUT NOW ";: INPUT A$ 80 PRINT #1; MARGIN 120 PRINT #1; B$: B$ = "": PRINT 160 IF A$ = "NO" THEN END 170 RUN "D: TYPE.LET"
Program 3.
1 REM *** FETCH TEXT AND PRINT (D: TYPE. LET) 10 DIM A$(100) 20 ? :? "WHEN READY, HIT RETURN ";: INPUT A$ 30 OPEN #1, 4, 0, "D: FILE.LET" 40 TRAP 80 50 INPUT #1, MARGIN: POKE 201, MARGIN 60 INPUT #1, A$: LPRINT " ", A$ 70 GOTO 60 80 CLOSE #1 90 ? :? "DESTROY FILE NOW (Y-N) ";: INPUT A$ 100 IF A$(1, 1) = "N" THEN END 110 XI0 33, #1, 0, 0, "D: FILE.LET"
How It Works
Line 70 calculates the parameters of the text string according to the MARGIN selected and POKEs the right margin of the screen monitor to one-half the width. The latter is necessary to accomodate one full line of typing for each A$ to be printed (the screen is only 40 columns wide). The user enters two lines for each single line of text and types as close to the right margin as possible without hyphenating the last word in the middle of a syllable. The subroutine beginning at LINE 1000 counts the characters within each line of text and adjusts the length of the text by inserting the proper number of spaces into the string.
The program is designed to print directly to an AXIOM II printer, but with the following modifications (Program 2) a temporary file (D:FILE.LET) can be made which will allow storage of the text for future printout or multiple copy.
There is also a file retrieval program (Program 3; LINE 110 automatically deletes the unwanted file without going to DOS).