Keeps a parts inventory of five-character part numbers and quantities, with room for 1,000 or 1,500 records depending on the version loaded. A boxed menu offers add a part, delete a part, list all, adjust quantity, save and quit, and a randomly chosen block graphic runs along the top and bottom of the box while the program waits for a key. The list goes to the screen, the printer or both. Each quantity is packed into two characters of a string, which saves memory and allows values up to 65,535.
The handwritten cassette label reads "INVENTORY "STOCK 1" "STOCK 2"". The tape holds two versions of the same program, both loaded with the name INV: one sized for 1,000 records and one for 1,500. The only difference between them is the value of MAX. 131 of its 139 lines are the same as the second, smaller program in Timex's Inventory Control, which sets MAX to 1,650 and also saves its data as STOCK2. The longer first program from that package is not on this tape. Who made this adaptation is not known.
Program Analysis
Program Structure
- Lines 100–150: set
MAX, thenDIM D$(MAX,5)for part numbers andDIM Q$(MAX*2)for quantities. - Lines 500–700: the menu. Keys
A–Fare sent toGOTO 1000*(CODE J$-CODE "A"+1), so each option starts on a multiple of 1000. - Lines 1000–1210: add. Takes the first record whose first character is a space, then asks for the part number and quantity.
- Lines 2000–2410: delete. Pads the part number to five characters, searches in
FASTmode and blanks the first character of the matching record. - Lines 3000–3920: list, after asking for printer (P), screen (S) or both (B). Any key stops the listing.
- Lines 4000–4100: adjust quantity, using the search subroutine at line 8000.
- Lines 5000–5040:
SAVEunder a name you type, or STOCK2 if you just press ENTER. The data is kept in the program's variables, so it is saved with the program.
Notable Techniques
- Quantities are stored as
CHR$ Q1+CHR$ Q2, the low and high bytes, and read back withCODE Q$(J)+CODE Q$(J+1)*256. That is two bytes per record instead of the five a numeric array element needs. - A deleted record is marked only by a space in its first character, so the add routine reuses free slots without moving any data.
- The printer and screen flags are set with comparisons:
LET PRI=K$<>"S"andLET SCR=K$<>"P".
Potential Issues
- When every record is in use, line 1050 runs
GOTO DELRET, but no variable calledDELRETis ever set, so the program stops with an error. The same line is in Inventory Control. - Line 3020 sets the page counter to 5 after the header routine has set it to 20. After the first five entries the list pauses once, but the counter is never reset. A long listing then runs off the bottom of the screen and stops with report 5. Inventory Control does not have this problem: it reprints the header at every page.
- A part number longer than five characters causes an error in the padding expression at lines 2030 and 8030. A quantity above 65,535, or a negative one, causes an error in
CHR$. - When the search at line 8000 finds nothing, it uses
GOTO 513to leave aGOSUB, so each failed adjust leaves an unused return address on the stack.
Source Code
100 REM INIT
110 LET C$=" "
120 LET MAX=1500
130 DIM D$(MAX,5)
140 DIM Q$(MAX*2)
150 LET S$=" "
500 REM MAIN LOOP
505 SLOW
510 CLS
513 PRINT AT 8,0;S$+S$+S$+S$+S$
514 PRINT AT 0,0;"█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█";AT 7,0;"█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█"
515 FOR G=1 TO 6
516 PRINT AT G,0;"█";AT G,31;"█"
518 NEXT G
520 PRINT AT 1,2;"(A) ADD A PART";AT 2,2;"(B) DELETE A PART";AT 3,2;"(C) LIST ALL";AT 4,2;"(D) ADJUST QUANTITY";AT 5,2;"(E) SAVE";AT 6,2;"(F) QUIT"
530 LET R$="▒\~~\,,[~~][,,][▒]▚▞▜▛▙▟▘▝▗▖▌▄▀▐"
535 LET H=INT (RND*LEN R$)+1
537 IF R$(H)=C$ THEN GOTO 535
540 LET C$=R$(H)
550 FOR X=1 TO 15
560 PRINT AT 0,16-X;C$;AT 0,15+X;C$
565 PRINT AT 7,16-X;C$;AT 7,15+X;C$
570 LET J$=INKEY$
575 IF J$>="A" AND J$<="F" THEN GOTO 700
580 NEXT X
590 GOTO 535
700 GOTO 1000*(CODE J$-CODE "A"+1)
1000 REM ADD
1010 FOR G=1 TO MAX
1020 IF D$(G,1)=" " THEN GOTO 1100
1030 NEXT G
1040 PRINT "NO FREE RECORDS."
1050 GOTO DELRET
1100 REM
1110 PRINT "PART NUMBER: ";
1120 INPUT P$
1130 PRINT P$
1140 LET D$(G)=P$
1150 PRINT "QUANTITY: ";
1160 INPUT Q
1165 PRINT Q
1170 LET Q2=INT (Q/256)
1180 LET Q1=Q-Q2*256
1190 LET P=(G-1)*2+1
1200 LET Q$(P TO P+1)=CHR$ Q1+CHR$ Q2
1210 GOTO 513
2000 REM DELETE
2010 PRINT "PART NUMBER: ";
2020 INPUT P$
2030 LET P$=P$+" "( TO 5-LEN P$)
2035 FAST
2040 FOR G=1 TO MAX
2050 IF D$(G)=P$ THEN GOTO 2400
2060 NEXT G
2065 SLOW
2070 PRINT "PART NOT FOUND."
2080 GOSUB 3700
2090 GOTO 500
2400 LET D$(G,1)=" "
2405 SLOW
2410 GOTO 513
3000 REM LIST
3005 GOSUB 3800
3010 GOSUB 3640
3015 FAST
3020 LET SC=5
3030 FOR G=1 TO MAX
3040 IF D$(G,1)<>" " THEN GOSUB 3500
3050 IF SC=0 THEN GOSUB 3700
3055 IF INKEY$ >"" THEN GOTO 3900
3060 NEXT G
3065 SLOW
3070 GOSUB 3700
3080 GOTO 513
3500 REM
3510 LET SC=SC-1
3520 LET Q=(G-1)*2+1
3530 LET Q1=CODE Q$(Q)
3540 LET Q2=CODE Q$(Q+1)
3550 LET Q=Q1+Q2*256
3560 IF SCR THEN PRINT D$(G),Q
3565 IF PRI THEN LPRINT D$(G),Q
3570 RETURN
3630 INPUT I$
3640 CLS
3650 PRINT "PART","QUANTITY"
3660 PRINT
3665 LET SC=20
3670 RETURN
3700 REM
3720 PRINT AT 21,0;"PRESS ENTER"
3730 INPUT I$
3735 CLS
3740 RETURN
3800 REM SCR/PRI?
3810 CLS
3820 PRINT "TO PRINTER (P), SCREEN (S), OR BOTH (B)?"
3830 LET K$=INKEY$
3835 IF K$<>"P" AND K$<>"S" AND K$<>"B" THEN GOTO 3830
3840 LET PRI=K$<>"S"
3850 LET SCR=K$<>"P"
3860 RETURN
3900 REM
3910 GOSUB 3700
3915 SLOW
3920 GOTO 500
4000 REM QUAN
4010 GOSUB 8000
4015 SLOW
4020 LET J=(G-1)*2+1
4030 LET Q=CODE Q$(J)+CODE Q$(J+1)*256
4040 PRINT "OLD QUANTITY: ";Q
4050 PRINT "NEW QUANTITY: ";
4060 INPUT K
4070 LET Q1=INT (K/256)
4080 LET Q2=K-256*Q1
4090 LET Q$(J TO J+1)=CHR$ Q2+CHR$ Q1
4100 GOTO 500
5000 REM SAVE
5005 PRINT AT 20,0;"ENTER THE NAME OF THE FILE."
5010 PRINT AT 21,0;"THEN HIT [E][N][T][E][R] ON THE TS1000."
5020 INPUT U$
5025 IF U$="" THEN LET U$="STOCK2"
5030 SAVE U$
5040 GOTO 500
6000 REM QUIT
7999 STOP
8000 REM
8010 PRINT "PART NUMBER: ";
8020 INPUT P$
8030 LET P$=P$+" "( TO 5-LEN P$)
8035 FAST
8040 FOR G=1 TO MAX
8050 IF D$(G)=P$ THEN RETURN
8060 NEXT G
8065 SLOW
8070 PRINT "PART NOT FOUND."
8080 GOSUB 3700
8090 GOTO 513Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

