Quick and Easy Routines

Author(s): Robert Hartung
Publication: Update Magazine
Pub Details: Update October 1987
Date: October 1987
Pages: 14

THE QUICKIE LIST: Sometimes the shorties are the most useful. This one was sent by Mr. Robert Hartung. Did you digest his articles in CTM? If not you should back up four issues of CTM and dig his series. (quote) To make a hard copy of a disk CAT for, labels, or an index, or a copying a screen: <OPEN #2,”P”: LET /p=o> When CAT/ is entered the disk directory goes to the printer instead of the screen. Or, any PRINT statement will go to the printer. When finished, <CLOSE #2> to terminate. (Thanks Bob!)

YES – NO INKEY$ for use after a prompt requiring YES or NO: GO SUB 200 will cause line 200 to loop itself until a Y, y, N, or n key is touched. YES assigns z=1 or NO assigns z=2. <200 PAUSE VAL “4e4″: LET T$= INKEY$ : IF T$<>”y” AND T$<>”y” AND T$<>”n” AND T$<>”N” THEN GO TO 200> <202 LET z=(1 and T$=”y” OR t$=”Y”)+(2 AND T$=”n” OR T$=”N”: RETURN>

INKEY$ Prompt for any key: Any key touched will result in its character being input to T$. Numbered characters will be represented by variable Z. Ideal for use with <GO SUB> after menu that has several selection options. (200 PAUSE VAL “4e4”: LET T$=INKEY$: LET z=CODE T$-48: RETURN>.

KEY LOCK after the above INKEY$ routine is used: Suppose that you have a MENU with 9 selection choices 1-9. <GO SUB 200 will wait until a key is touched, then assign “Z=key struck”. BUT, we want to lock out all except 1-9. <90 menu print statements: GO UB 200> <102 If Z<1 OR z>9 THEN GO TO 90>. Better still, lets use one line to lock the keys, PLUS- take action on ALL 9 menu selections. <102 GO TO (z<1 OR z>9)*90+ (z=1)*150+ (z=2)*200+ (z=3)*300+ (z=4)*400+ (z=5)*500+(z=6)*600+ (z=7)*700+ (z=8)*800+ (z=9)*900>. In this case there are 10 IF THEN logicals in line 102 that sends the program to the line numbers following the condition enclosed in brackets. (BOOLEAN Logicals works just fine, and conserves lots of memory. We will publish an article soon about Mr. Boolean’s 19th Century works and how the logic applies to BASIC Computer programming.)

THE SDOS PRINTER DRIVER: <LET /P=0> enables the built in Centronics printer driver. LPRINT commands then sends character streams through the Oliger or Aerco printer interface to a centronics printer. There are two TS-2068 memory addresses that one needs to know. The LET /P=0 safe disk command “zeroes address 23324, which is used as a switch to command a line feed. If PEEK 23324=0 then NO line feed is directed by the printer driver. So, if your printer requires a line feed, you must POKE 23324,10. Another important address is 23323 which contains “Maximum Line Length”. LET/P=0 places 255 as the content of Adr 23323. For most printers this is O.K., even if the printer’s maximum line is shorter than 255 characters. If you want to limit the printed line to any given length, say 60 characters, then POKE 23323,60. Then you must take TAB into consideration. For example: <LPRINT TAB 20;A$> would be O.K. if the length (LEN) of a$ were 40 characters. An additional character (41) would force a line feed and wrap print to the next line. A problem would occur if printing lines of a character array where the empty ends of the array lines are spaces. LLISTS in columns of 60 lines are easily printed by <LET/P=0: POKE 23323,60: LLIST>. If you want double spaced LLIST lines, add <POKE 23324,10> before the LLIST command.

SOFTWARE CHECK OF PRINTER STATUS: This may come as a “EUREKA! revelation” to some who are having trouble constructing program lines to COMMAND A PRINTER to change formats or print styles. When your printer is sitting there with lights on, it is in a READY STATUS. To be sure you can Type <PRINT IN 127 ENTER>. If the printer is READY, a “237” will appear on screen. When constructing program lines to COMMAND the printer to do such things as changing a print style or set EXPANDED characters, the programming is <OUT 127,number> then <OUT 127,another number> until all required “change commands” are sent. The problem is, a printer is slow to execute the commands, while the computer is fast in sending the commands. Most likely, the computer will finish sending three or more commands before the printer has executed the first one. As a result, the printer may not SEE some commands. A program loop is needed to make the software WAIT until the printer is in a READY status. Here it is: <100 IF IN 127=253 THEN GO TO 100>: RETURN>. When the printer is NOT READY, the command <PRINT IN 127 ENTER> returns the number 253 (BUSY). So, a <GO SUB 100> placed between each printer command will loop at line 100 until the printer is READY, and then RETURN for the next command. The COMMAND LINE would look like this: <50 GO SUB 100: OUT 127,27: GO SUB 100: OUT 127,60>. A printer BUSY status would hold up each command at line 100 until the printer status changes to READY (237).

PSEUDO HEX VARS TABLE with LETTERHEAD DATA

This vars file can be stored in disk for call up to your programs. Numbers 0 through 20 are represented by “double 0 vars” as, oo=0, ob=2, oc=3, through ou=20. When used in a program, each number 0-9 usage will conserve 5 bytes of memory. Each usage of the vars for numbers 10-20 conserves 6 bytes. N$ array is set up to service a LETTERHEAD, SIGN OFF, and SALUTATION BLOCK needs for letter correspondance. See the listing for designations.

 5 REM *** Type <CLEAR> then  <GO SUB 10> then <SAVE/"pseu"VAL>Note the letter support data forN$ array.  Array lines 1-5 are  reserved for Salutation block:  1=Company name. 2=Dept. 3=Streetaddress. 4=City State Zip. 5=   correspondants first name.   10=input date.  11=spare line.
6 REM ***Use <LOAD/"pseu"VAL>in a program line to initialize the variable table into a activeprogram.
10 LET oo=0: LET oa=1: LET ob=2: LET oc=3: LET od=4: LET oe=5: LET of=6: LET og=7: LET oh=8: LET oi=9: LET oj=10: LET ok=11: LET ol=12: LET om=13: LET on=14: LET op=15: LET oq=16: LET or=17: LET os=18: LET ot=19: LET ou=20: DIM n$(13,31): LET n$(6)="letterhead first line": LET n$(7)="second line": LET n$(8)="third line": LET n$(9)="fourth line": LET n$(11)="Sincerely": LET n$(13)="Signature line": RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.