So, now that we can do screen dumps and engage the various printer control functions, how about a word processor? Sorry folks, but this is where your BASIC fails you utterly. It is just too slow for most people, especially if there is any input checking. So while there have been several valiant attempts at coding full-feature (or even not-so-full feature) word~processors in BASIC, all have the speed problem inherent in floating-point, interpretive high-level languages.
Now the good news. If all you need to do is write letters and other text that won’t require extensive editing, and you aren’t too annoyed by operating in FAST mode, then you can put together a workable “typewriter” in BASIC with a minimum of effort. Such a program is presented here. The program will print any selected number of columns, but it won’t right-justify. It uses one long string to hold the text, and employs string slicing to change/add/delete words. You could extend it to edit larger blocks (such as sentences and paragraphs), but keep in mind that the more programming you add the less space you have for text. Another BASIC drawback; it’s extravagant with memory. String slicing, while easy to implement, requires up to 3 times the length of the string during intermediate operations, so your practical limit is about 5K of text in 16K of memory, even with the most austere of BASIC drivers. However, it’s easy, relatively fast and quite workable, if you’re a reasonably good typist and don’t have to do extensive editing. The first three issues of SWN (through 1:2) were written on a slight variation of this very program shown below! Though I now use Memotext exclusively, my “Caveman WP” served me well for correspondence and even newslettering for quite some time. I hope it does the same for some of you.
First, a few notes are prescribed. To avoid the double line-feed problem when printing strings over 64 characters long, the program adjusts the line feed to 1/2 of normal when the line is over 64 spaces long. This is somewhat more reliable than the suggested “double CHR$ terminator,” on my printer this has on occasion caused “lock-up.” Though a little cumbersome, the alternative works every time.
The first part of the program prints a graphic letterhead logo that you may have seen somewhere before. You can change this to whatever graphic creation you desire, or simply omit it. Control codes are accessed the same way as in the Demo, using a string to hold the control sequence and a subroutine to POKE it into the line 1 REM for execution.
The text printing routine may look familiar; it is based on an example in the CIF manual. Array A holds the start position of each paragraph in the long text string; if you want more paragraphs, DIMension a larger array. By the way, the lines (830-834) that edit the string require that the string be stored twice; if you replaced these lines with the apparently simpler LET S$=S$(TO S-N1)+B$+S$(F+N1 TO), it takes THREE TIMES the length of the string during slicing. So although it’s a couple more program lines, step-at-a-time slicing is more memory efficient. This is, by the way, where you’ll bomb with out-of-memory code 4/831. Delete some luxuries until GOTO 830 keeps the program going. Operating instructions are given after the program listing.
MEMOTECH I/F USERS
Add the listing as shown to your line 1 REM ASCII buffer/ conversion table. Controls are handled just like in the demo, except that the strings are defined using the characters instead of CHR$ number to conserve space; only problem with this approach is that the inverse periods prevent LLISTing with the Memo I/F. (Which is why I made the listing on a 2040.) Also, BEWARE of inverse periods in your text!!! If unintentional, these will falsely flag the I/F that a control is coming, with a crash likely to result. You CAN use it to imbed “Group I” controls (see last issue) in your text; experiment.
TS2040 USERS
You can use this program with your TS2040 with some simple changes. Delete lines 38, 50, 60. Change LET Z$= in lines 100, 110, 120, 130 to LPRINT commands (no need for graphics translation) and delete 105, 115, 125, and 135. Delete 145, remove the control codes for double width from 150 & 155. Delete lines 1065, 1172, and everything from 8000 on.
INSTRUCTIONS
FAST mode is recommended, though SLOW will work.
Enter RUN to start the program. It prints the letterhead, and prompts for date and heading (name and address). Pressing “Y” prints the date and heading. Enter number of columns desired (to 80, or 32 for TS2040).
The program goes right on to the text input section, with paragraph 1 (which might be “Dear ??,” etc), Input as much or as little text as you like, and press enter whenever you feel like it to move the input line to the top part of the screen. To go on to the next paragraph, enter “*” (asterisk) as your last character. The completed paragraph is shown, press Enter to go on to the next. When entering a long paragraph, you might run out of screen; enter CONT to keep going. The first spaces of each paragraph are left alone, so you can indent by entering spaces.
When you’ve entered all your paragraphs, pressing ENTER (only) gets you out of “text creating” mode and goes on to the review/print menu.
Press “R” to review; each paragraph is displayed in sequence. (If the paragraph is longer than one screen, then it is automatically split into two or more screens). Press any key (eg. “R” or ENTER) to go on to the next screen or paragraph.
If you find an error, press “E” (for edit). You are asked “which line;” count down how many lines (on the screen) the error is and enter the number, (If the error is in the second screen of a long paragraph, add 22 to the line number; e.g., the top line of the second screen would be 23, etc). At this point, you can also return to menu by entering “R” or to the next paragraph with ENTER only. Otherwise, you’re now asked “which word?” Count how many spaces occur on that line before the incorrect word; enter this and the word is brought down to line 22. (If it starts right at the edge of the line, enter 0. Negative numbers are allowed, so you can even “space back” to a previous line if you goofed on the line number.) Now re-type it as it should be, complete with leading AND trailing space (or inverse space; we’re using the I/F’s conversion table here); and the offending word will be replaced with the correct version and the paragraph reprinted. If you omit the leading or trailing space, then the word will be run together with the preceding or following word. To delete the word, enter a single space. To leave it the way it was, press ENTER only. With a little practice and experimentation you’ll quickly get the hang of it.
The end of paragraph marker * is left in, but ignored in printing (actual limits are stored in array A, which is updated every time you make a change). Also, though the screen will show exactly as you typed and will make words wrap to the next line, your printed output will never split a word, See SWN through No. 2 for sample output. Build your own custom program from the pieces available here and elsewhere. You’ll find that this kind of programming can be rather fun… though I wouldn’t want to do it for a living!