1 REM PROGRAM INV1
5 CLS
10 PRINT"        INVENTORY CONTROL FOR TRS-80
20 PRINT"                   BY DR. PETER SHENKIN
30 PRINT" *******************************************************
40 PRINT"THIS PROGRAM IS A RELATIVELY COMPLETE INVENTORY CONTROL PROGRAM
45 PRINT"THE ONLY REAL LIMITATION OF WHICH IS THAT IT IS IN MEMORY AND
50 PRINT"THUS ONLY HANDLES 50 DIFFERENT INVENTORY ITEMS. ACTUALLY
55 PRINT"THIS LIMITATION MAY BE RELAXED BY CHANGING THE APPROPRIATE
60 PRINT"DIMENSION STATEMENTS IF ENOUGH MEMORY IS AVAILABLE. 
65 PRINT"   THE PROGRAM SUPPORTS LINE PRINTER OUTPUT AND ALLOWS THE
70 PRINT"THE INVENTORY FILE TO BE STORED ON EITHER CASSETTE OR DISKETTE."
75 PRINT"REPORTS INCLUDE A LIST OF ALL DATA AND AN ACTIVITY REPORT
80 PRINT"WHICH OUTLINE PAST ACTIVITY FOR EACH ITEM. AN AVERAGE COST IS
85 PRINT"KEPT UPDATED FOR EACH ITEM."
120 PRINT" *****************************************************+
130 PRINT
140 GOSUB 10100
145 CLS
150 INPUT"ARE DISK DRIVES ATTACHED(Y/N)";ZD$
155 IF ZD$<>"Y" AND ZD$<>"N" THEN GOSUB 10000:GOTO 150
190 CLEAR 2500
200 DIM N$(50),D$(50),V$(50),Q(50),U(50),P(50),AC(50)
210 DIM RL(50),RA(50),S(3,50)
230 NI=0
240 GOSUB 3200
400 CLS
410 PRINT "          INVENTORY CONTROL"
420 PRINT " ENTER NUMBER OF DESIRED OPTION."
425 PRINT 
430 PRINT "1.ADD ITEM TYPES TO INVENTORY FILE(OR START FILE)"
440 PRINT "2.INVENTORY LIST(ENTIRE OR BY CLASS OR BY VENDOR)"
450 PRINT "3.PROCESSING CHANGES OF INVENTORY AMOUNTS"
460 PRINT "4.READ INVENTORY FILE FROM CASSETTE"
465 PRINT "5.READ INVENTORY FILE IN FROM DISKETTE
470 PRINT "6.WRITE INVENTORY FILE ONTO CASSETTE"
475 PRINT "7.WRITE INVENTORY FILE ONTO DISKETTE"
480 PRINT "8.UPDATE TO BEGIN NEW INVENTORY PERIOD"
483 PRINT "9.ACTIVITY REPORT"
486 PRINT "10.EDITING INVENTORY FILE"
490 PRINT "11.END THIS PROGRAM"
500 PRINT
510 INPUT "INPUT OPTION NUMBER & PRESS ENTER";OP
520 ON OP GOSUB 1000,1300,1600,1900,2000,2200,2300,2500,3000,3500,2800
540 GOTO 400
1000 REM SUBROUTINE FOR ADDING ITEM TYPES TO INVENTORY FILE
1010 CLS
1015 PRINT "ADDITIONAL INVENTORY ITEM SUBROUTINE":PRINT
1020 PRINT "HAS ANY EXISTING FILE BEEN READ FROM TAPE OR DISKETTE?(Y/N);
1030 INPUT Z9$
1040 IF Z9$="N" GOTO 1290
1050 IF Z9$="Y" GOTO 1075
1060 GOSUB 5200
1070 GOTO 1010
1075 I=NI+1
1080 CLS
1085 PRINT "INPUT DATA FOR NEXT ITEM.":PRINT
1090 GOSUB 6700
1230 REM EXHIBIT DISPLAY FOR THIS ITEM
1240 GOSUB 6000
1250 GOSUB 6200
1260 IF Z8=0 GOTO 1080
1270 GOSUB 6500
1280 NI=NI+1:IF Z9$= "Y" GOTO 1075
1290 RETURN
1300 REM SUBROUTINE GIVING INVENTORY LIST
1310 CLS:PRINT "CHOOSE DESIRED OPTION AND PRESS ENTER"
1320 PRINT "1. COMPLETE INVENTORY LIST"
1330 PRINT "2. INVENTORY LIST BY VENDOR"
1340 PRINT "3. LIST OF ITEMS BELOW REORDER POINT"
1350 INPUT "OPTION # ";N8
1355 GOSUB 10800:IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:GOTO 1355
1360 ON N8 GOSUB 1380,1410,1440
1370 RETURN
1380 FOR I=1 TO NI
1390 GOSUB 6000
1395 IF Z2$="Y" THEN GOSUB 6100
1400 FOR J = 1 TO 2000:NEXT J
1403 NEXT I
1405 RETURN
1410 INPUT "DESIRED VENDOR NUMBER ";VN$
1420 FOR I=1 TO NI
1430 IF V$(I)<>VN$ THEN GOTO 1435
1432 GOSUB 6000
1433 IF Z2$="Y" THEN GOSUB 6100
1434 FOR J= 1 TO 1000:NEXT J
1435 NEXT I
1439 RETURN
1440 FOR I= 1 TO NI
1450 IF Q(I) >= RL(I) THEN GOTO 1470
1460 GOSUB 6000
1462 IF Z2$="Y" THEN GOSUB 6100
1465 FOR J= 1 TO 1000:NEXT J
1470 NEXT I
1480 RETURN
1600 REM SUBROUTINE FOR CHANGING INVENTORY AMOUNTS
1610 REM AVERAGE COST AUTOMATICALLY CHANGED WITH ADDITIONS
1615 REM TO INVENTORY
1620 CLS
1630 PRINT "      CHANGING INVENTORY AMOUNTS"
1640 PRINT
1650 PRINT "FOR EACH ITEM OF INTEREST IT WILL BE NECESSARY TO
1660 PRINT "ENTER THE ITEM NUMBER AND PRESS ENTER. INFORMATION
1670 PRINT "ABOUT THAT ITEM WILL THEN BE DISPLAYED. THEN THE
1680 PRINT "USER MUST INDICATE WHETHER THE ITEM SUPPLY IS BEING" 
1690 PRINT "DIMINISHED OR INCREASED,AND BY HOW MUCH."
1695 FOR I=1 TO 1000:NEXT I
1700 CLS
1705 I=0
1710 PRINT @ 320,"ITEM NUMBER :";:INPUT IT$
1720 I = I+1
1730 IF IT$=N$(I) GOTO 1800
1740 IF I=NI GOTO 1770
1750 GOTO 1720
1770 PRINT:PRINT "ITEM NOT ON INVENTORY LIST."
1775 FOR J=1 TO 200:NEXT J
1780 GOTO 1870
1800 GOSUB 6000 : REM LIST ITEM INFORMATION
1810 PRINT "INPUT A FOR ADDITIONS,D FOR DELETIONS,R FOR END"
1812 INPUT R$
1814 IF R$ = "R" THEN  RETURN
1815 IF R$="A" OR R$="D" GOTO 1820
1817 GOSUB 5200
1819 GOTO 1800
1820 IF R$="A" GOTO 1840
1822 CLS:PRINT"HOW MANY ITEMS DO YOU WISH TO DELETE";:INPUT Q1
1824 IF Q1<= Q(I) GOTO 1828
1825 PRINT:PRINT "ONLY ";Q(I);" ITEMS IN INVENTORY.TRY AGAIN"
1826 FOR I= 1 TO 300:NEXT I
1827 GOTO 1822
1828 PRINT "ARE YOU SURE YOU WANT TO DELETE ";Q1;" ITEMS(Y/N)";
1829 INPUT Z9$
1831 IF Z9$="Y" OR Z9$="N" GOTO 1834
1832 GOSUB 5200
1833 GOTO 1828
1834 IF Z9$="N" GOTO 1800
1835 Q(I)=Q(I) - Q1:S(0,I)=S(0,I)+Q1
1836 GOTO 1870
1840 INPUT "INPUT NO. OF UNITS TO ADD";Q1
1845 INPUT "UNIT COST";UI
1847 Z5=0
1850 INPUT "PRESS 1 AND ENTER IF IN ERROR.JUST ENTER IF OK";Z5
1855 IF Z5=1 GOTO 1800
1858 AC=(AC(I)*Q(I)+Q1*UI)/(Q(I)+Q1)
1859 AC(I)=INT(100*AC)/100
1860 Q(I)=Q(I) + Q1
1862 U(I)=UI
1865 GOTO 1870
1870 GOSUB 6500
1875 IF Z9$= "Y" GOTO 1700
1880 RETURN
1900 REM SUBROUTINE FOR READING INV. FILE FROM CASSETTE
1910 CLS:PRINT "PREPARE TAPE RECORDER AND INV. TAPE."
1920 INPUT "PRESS ENTER WHEN READY";Z7
1925 ' IF ZD$="Y" THEN CMD"T"
1930 INPUT #-1,NI
1940 FOR I=1 TO NI
1950 GOSUB 5000
1960 NEXT I
1970 RETURN
2000 REM SUBROUTINE FOR READING INV FILE IN FROM DISKETTE
2010 CLS:PRINT"PLACE INVENTORY DATA DISKETTE IN DRIVE."
2020 INPUT"PRESS ENTER WHEN READY";Z7
2025 OPEN "I",1,"INVDATA"
2030 INPUT #1,NI
2035 PRINT:PRINT NI;" ITEMS TO BE READ"
2040 FOR I=1 TO NI
2050 GOSUB 5050
2060 NEXT I
2070 CLOSE #1:RETURN
2200 REM SUBROUTINE FOR WRITING INV FILE ONTO CASSETTE
2210 CLS:PRINT "PREPARE TAPE RECORDER AND INV. TAPE."
2220 INPUT "PRESS ENTER WHEN READY";Z7
2225 ' IF ZD$="Y" THEN CMD"T"
2230 WRITE #-1,NI
2240 FOR I= 1 TO NI
2250 GOSUB 5100
2260 NEXT I
2270 RETURN
2300 REM SUBROUTINE FOR WRITING INV FILE ONTO DISKETTE
2310 CLS:PRINT"PREPARE INVENTORY MASTER DISKETTE
2320 INPUT"PRESS ENTER WHEN READY";Z7
2325 PRINT:PRINT"THERE ARE ";NI;" ITEMS"
2330 OPEN "O",1,"INVDATA"
2335 WRITE # 1,NI
2340 FOR I=1 TO NI
2350 GOSUB 5150
2360 NEXT I
2370 CLOSE #1:RETURN
2500 REM UPDATE TO BEGIN NEW INVENTORY PERIOD
2510 FOR I=1 TO NI
2520 S(2,I) = S(1,I) : S(1,I)=S(0,I) : S(0,I) = 0
2530 NEXT I
2535 CLS:PRINT "UPDATE COMPLETE":FOR I=1 TO 200:NEXT I
2540 RETURN
2800 REM END PROGRAM SUBROUTINE
2805 CLS
2810 INPUT"ARE YOU SURE YOU WISH TO END PROGRAM(Y/N)";Z7$
2820 IF Z7$="N" THEN RETURN
2830 IF Z7$="Y" THEN END
2840 GOSUB 5200
2850 GOTO 2805
3000 REM SUBROUTINE FOR ACTIVITY REPORT
3005 CLS:GOSUB 10800:IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:GOTO 3005
3010 CLS:GOSUB 3300
3015 IF Z2$="Y" THEN LPRINT H$:LPRINT" "
3020 FOR I= 1 TO NI
3030 GOSUB 3250
3040 IF I/10 = INT(I/10) GOTO 3070
3050 NEXT I
3055 PRINT
3056 INPUT "END OF REPORT. PRESS ENTER TO RETURN TO MENU";Z4
3060 RETURN
3070 PRINT:INPUT "PRESS ENTER FOR MORE OF REPORT";Z4
3080 CLS
3090 GOSUB 3300
3100 GOTO 3050
3200 REM SUBROUTINE WITH PRINT USING FORMAT VARIABLES
3210 H$="ITEM NO.   DESCRIPTION     ON HAND    THIS PER.    LAST PER."
3220 Z$="%     %  %               % #######    #######      #######  "
3225 RETURN
3250 REM SUBROUTINE FOR PRINTING ACTIVITY INFORMATION
3260 PRINT USING Z$;N$(I),D$(I),Q(I),S(0,I),S(1,I)
3265 IF Z2$="Y" THEN LPRINT USING Z$;N$(I),D$(I),Q(I),S(0,I),S(1,I)
3270 RETURN
3300 REM SUBROUTINE FOR PRINTING HEADING
3310 PRINT H$
3320 RETURN
3500 REM EDITING SUBROUTINE
3510 CLS
3520 PRINT "         EDITING ITEM ENTRIES"
3530 PRINT
3540 PRINT "FOR EACH ITEM MAKE THE APPROPRIATE CHANGES AND"
3550 PRINT "AND PRESS ENTER AFTER EACH CHANGE. JUST PRESS
3560 PRINT "ENTER WHEN ITEM IS NOT CHANGED."
3570 FOR I= 1 TO 1000:NEXT I
3580 CLS
3590 I=0
3600 PRINT @ 320,"ITEM NUMBER (99999 FOR RETURN)";:INPUT IT$
3610 IF IT$="99999" THEN RETURN
3620 I=I+1
3630 IF IT$=N$(I) GOTO 3700
3640 IF I = NI GOTO 3670
3650 GOTO 3620
3670 PRINT:PRINT "ITEM NOT ON INVENTORY LIST."
3675 FOR J=1 TO 200:NEXT J
3680 GOTO 3755
3700 GOSUB 6000 : REM LIST ITEM INFORMATION
3710 PRINT
3720 GOSUB 6700
3730 CLS
3740 GOSUB 6000
3750 PRINT:PRINT
3755 GOSUB 6500 : REM QUERY SUBROUTINE
3760 IF Z9$="Y" GOTO 3590
3780 RETURN
5000 REM SUBROUTINE FoR READING RECORD FROM CASSETTE
5010 INPUT #-1,N$(I),D$(I),V$(I),Q(I),U(I),P(I),AC(I),RL(I),RA(I),S(0,I),S(1,I),S(2,I)
5020 RETURN
5050 REM SUBROUTINE FOR READING DATA FROM DISKETTE
5060 INPUT # 1,N$(I),D$(I),V$(I),Q(I),U(I),P(I),AC(I),RL(I),RA(I),S(0,I),S(1,I),S(2,I)
5070 RETURN
5100 REM SUBROUTINE FOR COPYING RECORD ONTO CASSETTE
5110 WRITE #-1,N$(I),D$(I),V$(I),Q(I),U(I),P(I),AC(I),RL(I),RA(I),S(0,I),S(1,I),S(2,I)
5120 RETURN
5150 REM SUBROUTINE FOR COPYING RECORD ONTO DISKETTE
5160 WRITE # 1,N$(I),D$(I),V$(I),Q(I),U(I),P(I),AC(I),RL(I),RA(I),S(0,I),S(1,I),S(2,I)
5170 RETURN
5200 REM SUBROUTINE FOR INPUT ERROR
5210 PRINT:PRINT "INPUT ERROR. ENTER AGAIN."
5220 FOR K=1 TO 1000:NEXT K
5230 PRINT:RETURN
6000 REM SUBROUTINE DISPLAYING DATA FOR 1 ITEM
6010 CLS
6020 PRINT "ITEM NO.     : ";N$(I);"   DESCRIP. :";D$(I)
6030 PRINT "VENDOR NO.   : ";V$(I)
6040 PRINT "QUANT. ON HAND: ";Q(I);" LAST  UNIT COST:";U(I)
6050 PRINT "SELLING PR. :";P(I);"   AVERAGE COST : ";AC(I)
6060 PRINT "REORDER PT.: ";RL(I);"  MAX INV.: ";RA(I)
6070 PRINT "ORDERS THIS INV. PERIOD : ";S(0,I)
6080 PRINT "ORdERS LAST INV. PER:";S(1,I);" PREV. PER:";S(2,I)
6085 PRINT
6090 RETURN
6100 REM SUBROUTINE PRINTING DATA FOR 1 ITEM
6120 LPRINT "ITEM NO.     : ";N$(I);"   DESCRIP. :";D$(I)
6130 LPRINT "VENDOR NO.   : ";V$(I)
6140 LPRINT "QUANT. ON HAND: ";Q(I);" LAST  UNIT COST:";U(I)
6150 LPRINT "SELLING PR. :";P(I);"   AVERAGE COST : ";AC(I)
6160 LPRINT "REORDER PT.: ";RL(I);"  MAX INV.: ";RA(I)
6170 LPRINT "ORDERS THIS INV. PERIOD : ";S(0,I)
6180 LPRINT "ORDERS LAST INV. PER:";S(1,I);" PREV. PER:";S(2,I)
6185 LPRINT " ":LPRINT " ":LPRINT " "
6190 RETURN
6200 REM OK SUBROUTINE
6210 PRINT
6220 PRINT "IF OK PRESS 1,OTHERWISE PRESS 0";:INPUT Z8
6230 IF Z8=0 OR Z8=1 GOTO 6270
6240 GOSUB 5200
6250 GOSUB 6000
6260 GOTO 6210
6270 REM
6290 RETURN
6500 REM QuERY SUBROUTINE
6510 PRINT "DO YOU DESIRE MORE ENTRIES ?(Y/N)":INPUT Z9$
6520 IF Z9$<> "Y" AND Z9$<> "N" GOTO 6530
6525 RETURN
6530 GOSUB 5200
6540 CLS:GOTO 6510
6700 REM DATA ITEM INPUT SUBROUTINE
6710 INPUT "ITEM NUMBER               ";N$(I)
6720 INPUT "DESCRIPTION( < 20 CHAR)   ";D$(I)
6730 INPUT "VENDOR NUMBER             ";V$(I)
6740 INPUT "QUANTITY ON HAND          ";Q(I)
6750 INPUT "LAST ORDER UNIT COST      ";U(I)
6760 INPUT "SELLING PRICE             ";P(I)
6770 INPUT "AVERAGE UNIT COST         ";AC(I)
6780 INPUT "REORDER POINT             ";RL(I)
6790 INPUT "MAXIMUM INVENTORY         ";RA(I)
6800 INPUT "# SOLD THIS INV. PERIOD   ";S(0,I)
6810 INPUT "# SOLD LAST INV. PERIOD   ";S(1,I)
6820 INPUT "# SOLD 2 INV. PER. AGO    ";S(2,I)
6830 RETURN
10000 PRINT"INPUT ERROR! TRY AGAIN:FOR JZ=1 TO 500:NEXT:RETURN
10100 INPUT"PRESS ENTER TO CONTINUE";Z9$:RETURN
10800 Z2$="":INPUT"IS PRINTED OUTPUT DESIRED(Y/N)";Z2$:RETURN
10900 IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:RETURN
