1 MERGE "MERGE.BAS"



10 REM 12/05/78
20 REM ** TRS-80 INVENTORY CONTROL SYSTEM **



25 IF PEEK(14312)>127 THEN PRINT "PRINTER NOT READY":GOTO 40
30 REM LPRINT CHR$(27);CHR$(20)
40 POKE 16425,1
  :CLEAR 500
  :W$=""
  :ON ERROR  GOTO 5000
  :GOSUB 32000

  
  
45 OPEN "I",1,"TRANSFER"
50 LINE  INPUT  #1,PI$:LINE  INPUT  #1,PS$:LINE  INPUT  #1,PD$
60 LINE  INPUT  #1,PT$:LINE  INPUT  #1,PR$
70 CLOSE 1:KILL "TRANSFER"
80 CLS:GOSUB 250:GOTO 200



90 REM ------------------------------------------------------
100 ON ERROR  GOTO 0
110 IF LEFT$(TIME$,2)="00" OR MID$(TIME$,3,1)<>"/" OR MID$(TIME$,6,1)<>"/" THEN CLS:GOTO 190
120 CLS:PRINT @ 458,"DATE IS SET TO ";LEFT$(TIME$,8);" . IS THIS CORRECT ? ";
130 FL=1:GOSUB 370:Q$=IN$:IF Q$<>"Y" AND Q$<>"N" THEN PRINT CHR$(8);:GOTO 130 ELSE IF Q$="N" THEN 140 ELSE 190
140 PRINT @ 588,"ENTER CORRECT DATE (MM/DD/YY) : ";
150 FL=8:GOSUB 370:DT$=IN$
160 POKE 16454,VAL(LEFT$(DT$,2)):POKE 16452,VAL(RIGHT$(DT$,2))
170 POKE 16453,VAL(MID$(DT$,4,2))
180 GOTO 110
190 CLS:GOSUB 250:GOSUB 3180:IF P$="" THEN 190 ELSE GOSUB 3170:PRINT @ 472,"INITIALIZING";CHR$(30)



200 DEFINT A,C,H,J,K,F,L,M,N,P,T,V,W:DIM V(1000)
210 DEF FNGP(IC,IP)=(IP-IC)/IP*100
215 GOSUB 3175
220 ON ERROR  GOTO 5000:POKE 16424,67:POKE 16425,1:XX=1:LF$=CHR$(32):LL$=STRING$(132,"-")
230 RESTORE:READ A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,L0$,L1$,L6$,L7$:RESTORE :GOTO 3010
240 GOSUB 250:GOTO 270
250 CLS:PRINT TAB(13)"TRS-80 INVENTORY CONTROL SYSTEM":PRINT @ 117,LEFT$(TIME$,8);:PRINT :RETURN 
260 GOSUB 250:PRINT TAB(20)"SYSTEM STATUS REPORT":PRINT :GOSUB 3070:PRINT :GOSUB 2480:RETURN 
270 PRINT "FUNCTIONS:
   :PRINT "
   :PRINT "1 - INPUT NEW ITEMS
   :PRINT "2 - ACCESS / UPDATE
   :PRINT "3 - OUTPUT REPORTS AND SUMMARIES
   :PRINT "4 - CREATE NEW INVENTORY
   :PRINT "5 - ENTER SALES TICKETS
   :PRINT "6 - END OF PERIOD PROCESSING"
280 PRINT "7 - ENTER RECEIPTS OF ON-ORDER ITEMS
   :PRINT "8 - ENTER ITEMS PLACED ON ORDER
   :PRINT "9 - DISPLAY SYSTEM STATUS
   :PRINT "@ - EXIT FROM PROGRAM"
290 PRINT :PRINT "SELECT FUNCTION > ";
300 FL=-1:GOSUB 370:S$=IN$:IF CF=1 THEN 330 ELSE IF S$<"1" OR S$>"9" THEN PRINT CHR$(8);:GOTO 300
310 ON VAL(S$) GOSUB 560,800,1530,1800,1870,2000,1300,1310,260
320 IF FD=0 THEN 240 ELSE CLS:PRINT @ 464,"LOADING IN DATA FOR SORT":CLOSE :GOSUB 2750::GOSUB 2720:GOTO 3670
330 CLS
340 PRINT @ 472,"END OF PROGRAM":PRINT :PRINT :IF ER=1 THEN CLOSE :CLEAR 50:END ELSE CLOSE :GOSUB 2750:GOSUB 2720:CLEAR 50:END
350 PRINT @ 128,CHR$(30);CHR$(29);"(TYPE @ TO EXIT TO MAIN MENU)";:RETURN 
360 PRINT @ 128,CHR$(30);CHR$(29);"(TYPE @ TO REDO ENTRY)";:RETURN 



370 REM IN$="":CF=0:W$=INKEY$:WD=0:WS=WD:WL=WD:IF FL=WD THEN FL=1
375 IN$="":CF=0:W$="":WD=0:WS=WD:WL=WD:IF FL=WD THEN FL=1
377 INPUT IN$:W=LEN(IN$):W$=RIGHT$(IN$,1):IF W$="@" THEN CF=1
378 RETURN


380 PRINT STRING$(ABS(FL),CHR$(136));STRING$(ABS(FL),CHR$(24));
390 PRINT CHR$(14);:FOR W=1 TO 25:W$=INKEY$:IF W$<>"" THEN 400 : NEXT :PRINT CHR$(15);:FOR W=1 TO 25:W$=INKEY$:IF W$<>"" THEN 400 : NEXT :GOTO 390
400 IF W$<>CHR$(13) THEN 420 ELSE PRINT STRING$(ABS(FL)-WL," ");
410 PRINT CHR$(15);:W=25:RETURN 
420 IF W$<>"@" THEN 440
430 CF=1:PRINT CHR$(15);:RETURN 
440 PRINT CHR$(14);:IF W$=CHR$(24) THEN PRINT STRING$(WL,CHR$(24));:GOTO 370
450 IF W$<>CHR$(8) THEN 490 ELSE IF WL=0 THEN 390 ELSE PRINT CHR$(24);:IF FL>0 THEN 470 ELSE IF PEEK(16418)=44 THEN 480
460 IF PEEK(16418)=46 THEN WD=0:GOTO 470 ELSE IF PEEK(16418)=43 OR PEEK(16418)=45 THEN WS=0
470 IN$=LEFT$(IN$,LEN(IN$)-1)
480 WL=WL-1:POKE 16418,136:GOTO 390
490 IF ABS(FL)=WL THEN 390 ELSE IF FL>0 THEN IF W$>=" " AND W$<="z" THEN 540
500 IF W$="." AND WD=0 THEN WD=1:GOTO 540
510 IF W$="," THEN PRINT W$;:WL=WL+1:GOTO 550
520 IF (W$="-" OR W$="+") AND WS=0 AND WL=0 THEN WS=1:GOTO 540
530 IF W$<"0" OR W$>"9" THEN 390
540 PRINT W$;:IN$=IN$+W$:WL=WL+1
550 IF ABS(FL)=1 THEN 410 ELSE 390



560 CLS:PRINT TAB(20)"INPUT NEW ITEMS":PRINT 
570 IF ER=1 THEN GOSUB 3060:RETURN 
580 J=TN
590 IF TI=1000 THEN CLS:PRINT @ 468,"SYSTEM IS FULL (1000 ITEMS)":GOSUB 2480:RETURN  ELSE PRINT @ A0,CHR$(30);:GOSUB 2510:GOSUB 350
600 IF FD<>0 THEN PRINT @ 295,"(LAST ENTRY: ";IS$;")";
610 FL=10:PRINT @ A0,;:GOSUB 370:IF CF=0 THEN IS$=IN$ ELSE 630
620 IF IS$<>"" THEN 640 ELSE 610
630 RETURN 
640 GOSUB 360
650 FL=19:PRINT @ A1,;:GOSUB 370:IF CF=0 THEN ID$=IN$ ELSE 560
660 FL=-4:PRINT @ A2,;:GOSUB 370:IF CF=0 THEN IQ%=VAL(IN$) ELSE 560
670 FL=-7:PRINT @ A3,;:GOSUB 370:GOSUB 3750:IF CF=0 THEN IC=VAL(IN$):PRINT CHR$(30); ELSE ON CF GOTO 560,670
680 FL=-7:PRINT @ A4,;:GOSUB 370:GOSUB 3750:IF CF=0 THEN IP=VAL(IN$):PRINT CHR$(30); ELSE ON CF GOTO 560,680
690 GOSUB 2830
700 FL=10:PRINT @ A5,;:GOSUB 370:IF CF=0 THEN IL$=IN$ ELSE 560
710 FL=-4:PRINT @ A6,;:GOSUB 370:IF CF=0 THEN IR%=VAL(IN$) ELSE 560
720 PRINT " / ";:FL=-4:GOSUB 370:IF CF=0 THEN IN%=VAL(IN$) ELSE 560
730 FL=-4:PRINT @ A7,;:GOSUB 370:IF CF=0 THEN IO%=VAL(IN$) ELSE 560
740 FL=8:PRINT @ A8,;:GOSUB 370:IF CF=0 THEN IM$=IN$ ELSE 560
750 FL=6:PRINT @ A9,;:GOSUB 370:IF CF=0 THEN IV$=IN$ ELSE 560
760 P1=0:P2=0:GOSUB 3860
770 TC#=TC#+IC*IQ%:TP#=TP#+IP*IQ%:TR#=TR#+IO%*IC:TI=TI+1
780 FD=1:GOSUB 3130:GOSUB 2630:GOSUB 2660:GOSUB 2650:GOSUB 2540
790 GOSUB 2600:GOSUB 2560:TN=TN+1:J=TN:GOSUB 2510:GOTO 590



800 CLS:PRINT TAB(20)"ACCESS / UPDATE DATA":PRINT 
810 IF ER=1 THEN GOSUB 3060:RETURN 
820 PRINT @ A0,CHR$(31);:GOSUB 2510
830 GOSUB 2780:PRINT "ENTER STOCK # (TYPE @ TO EXIT) ----> ";
840 FL=10:GOSUB 370:IF CF=0 THEN IS$=IN$ ELSE 1270
850 GOSUB 2420
860 IF K=0 THEN PRINT @ AB,"ITEM NOT IN LISTING";:GOSUB 2500:GOSUB 2510:GOTO 830
870 GOSUB 2760
880 GOSUB 2780:PRINT "SELECT (U)PDATE, (S)EARCH, (N)EXT ITEM, (P)REVIOUS ITEM,
   :PRINT "(A)DJUST QTY, (D)ELETE, (@) TO EXIT TO MAIN MENU --> ";
890 FL=1:GOSUB 370:IF CF=1 THEN 1270 ELSE O$=IN$:IF O$<>"U" AND O$<>"S" AND O$<>"N" AND O$<>"P" AND O$<>"D" AND O$<>"A" THEN PRINT CHR$(8);:GOTO 890
900 IF O$="D" THEN 1210
910 IF O$="S" THEN 820
920 IF O$="U" THEN 970
930 IF O$="A" THEN 1240
940 IF O$="P" AND N<>1 THEN N=N-1:J=V(N):IF SGN(J)=-1 THEN 940 ELSE GOSUB 2630:GOSUB 2660:GOSUB 2670:GOSUB 2760:GOTO 880
950 IF O$="N" AND N+1<>TN THEN N=N+1:J=V(N):GOTO 960 ELSE PRINT CHR$(8);:GOTO 890
960 IF SGN(J)=-1 THEN 950 ELSE GOSUB 2630:GOSUB 2660:GOSUB 2670:GOSUB 2760:GOTO 880
970 GOSUB 2780:PRINT "SELECT LINE TO BE UPDATED (TYPE @ TO RESTART)--> ";
980 FL=-1:GOSUB 370:IF CF=0 THEN U$=IN$:IF U$<"1" OR U$>"9" THEN PRINT CHR$(8);:GOTO 980
990 IF CF<>0 THEN 880
1000 GOSUB 2780:ON VAL(U$) GOTO 1010,1030,1050,1070,1090,1110,1140,1160,1180
1010 GOSUB 2780:PRINT "1 - DESCRIPTION : ";
1020 FL=19:GOSUB 370:IF CF=0 THEN ID$=IN$:GOTO 1200 ELSE 990
1030 GOSUB 2780
1040 PRINT "2 - QUANTITY : ";:FL=-4:GOSUB 370:IF CF=0 THEN GOSUB 1280:IQ%=VAL(IN$):GOSUB 1290:GOTO 1200 ELSE 990
1050 GOSUB 2780
1060 PRINT "3 - COST : ";:FL=-7:GOSUB 370:GOSUB 3750:IF CF=0 THEN GOSUB 1280:IC=VAL(IN$):GOSUB 1290:PRINT CHR$(30);:GOTO 1200 ELSE ON CF GOTO 990,1050
1070 GOSUB 2780
1080 PRINT "4 - RETAIL PRICE : ";:FL=-7:GOSUB 370:GOSUB 3750:IF CF=0 THEN GOSUB 1280:IP=VAL(IN$):GOSUB 1290:PRINT CHR$(30);:GOTO 1200 ELSE ON CF GOTO 990,1070
1090 GOSUB 2780:PRINT "5 - LOCATION : ";
1100 FL=10:GOSUB 370:IF CF=0 THEN IL$=IN$:GOTO 1200 ELSE 990
1110 GOSUB 2780:PRINT "6 - REORDER POINT/QTY : ";
1120 FL=-4:GOSUB 370:IF CF=0 THEN IR%=VAL(IN$) ELSE 990
1130 PRINT " / ";:FL=-4:GOSUB 370:IF CF=0 THEN IN%=VAL(IN$):GOTO 1200 ELSE 990
1140 GOSUB 2780:PRINT "7 - # ON ORDER : ";
1150 FL=-4:GOSUB 370:IF CF=0 THEN GOSUB 1280:IO%=VAL(IN$):GOSUB 1290:GOTO 1200 ELSE 990
1160 GOSUB 2780:PRINT "8 - DATE LAST ORDER : ";
1170 FL=8:GOSUB 370:IF CF=0 THEN IM$=IN$:GOTO 1200 ELSE 990
1180 GOSUB 2780:PRINT "9 - VENDOR : ";
1190 FL=6:GOSUB 370:IF CF=0 THEN IV$=IN$:GOTO 1200 ELSE 990
1200 GOSUB 2560:GOSUB 2510:GOSUB 2860:GOTO 880
1210 V(N)=-J
1220 TI=TI-1:GOSUB 1280:F=F+1
1230 IF N+1=TN THEN PRINT @ A0,CHR$(31);:GOSUB 2510:GOTO 830 ELSE N=N+1:J=V(N):IF SGN(J)=1 THEN GOSUB 2630:GOSUB 2660:GOSUB 2670:GOTO 870 ELSE 1230
1240 GOSUB 2780:PRINT "ENTER + OR - AND CHANGE IN QUANTITY ---> ";
1250 FL=-4:GOSUB 370:IF CF=0 THEN CH$=IN$ ELSE 990
1260 IQ%=IQ%+VAL(CH$):TC#=TC#+IC*VAL(CH$):TP#=TP#+IP*VAL(CH$):GOTO 1200
1270 RETURN 
1280 TC#=TC#-IQ%*IC:TP#=TP#-IQ%*IP:TR#=TR#-IO%*IC:RETURN 
1290 TC#=TC#+IQ%*IC:TP#=TP#+IQ%*IP:TR#=TR#+IO%*IC:RETURN 
1300 CLS:PRINT TAB(10)"ENTER RECEIPTS OF ON-ORDER ITEMS":PRINT :GOTO 1320
1310 CLS:PRINT TAB(15)"ENTER ITEMS PLACED ON ORDER":PRINT 
1320 IF ER=1 THEN GOSUB 3060:RETURN 
1330 PRINT @ A0,CHR$(31);:GOSUB 2510
1340 GOSUB 2780:PRINT "ENTER STOCK# (TYPE @ TO EXIT) ----> ";
1350 FL=10:GOSUB 370:IF CF=0 THEN IS$=IN$ ELSE 1270
1360 GOSUB 2420
1370 IF K=0 THEN PRINT @ AB,"ITEM NOT IN LISTING";:GOSUB 2500:GOSUB 2510:GOTO 1340
1380 GOSUB 2760
1390 IF S$="8" THEN 1490
1400 GOSUB 2780:PRINT "QUANTITY RECEIVED: ";
1410 FL=-4:GOSUB 370:IF CF=0 THEN GOSUB 1280:IQ%=IQ%+VAL(IN$):IO%=IO%-VAL(IN$) ELSE 1340
1420 GOSUB 2780:PRINT "CHANGE IN COST (HIT <ENTER> TO SKIP): ";
1430 FL=-7:GOSUB 370:IF CF<>0 THEN 1340 ELSE IF IN$="" THEN 1450 ELSE GOSUB 3750
1440 IF CF=0 THEN IC=VAL(IN$):PRINT CHR$(30); ELSE 1420
1450 GOSUB 2780:PRINT "CHANGE IN SELL PRICE (HIT <ENTER> TO SKIP): ";
1460 FL=-7:GOSUB 370:IF CF<>0 THEN 1340 ELSE IF IN$="" THEN 1480 ELSE GOSUB 3750
1470 IF CF=0 THEN IP=VAL(IN$):PRINT CHR$(30); ELSE 1450
1480 GOSUB 1290:GOSUB 2560:GOSUB 2510:GOSUB 2860:GOTO 1340
1490 GOSUB 2780:PRINT "QUANTITY ORDERED (HIT <ENTER> FOR DEFAULT QTY): ";
1500 FL=-4:GOSUB 370:IF CF<>0 THEN 1340 ELSE GOSUB 1280:IF IN$="" THEN IO%=IO%+IN% ELSE IO%=IO%+VAL(IN$)
1510 GOSUB 2780:PRINT "DATE OF ORDER (HIT <eNTER> FOR LAST ENTERED DATE): ";
1520 FL=8:GOSUB 370:IF IN$<>"" THEN IP$=IN$:IM$=IN$:GOTO 1480 ELSE IM$=IP$:GOTO 1480
1530 CLS:PRINT TAB(15)"OUTPUT REPORTS AND SUMMARIES":PRINT 
1540 IF ER=1 THEN GOSUB 3060:RETURN 
1550 PRINT "OPTIONS:
    :PRINT "
    :PRINT "1 - PRINTOUT COMPLETE LISTING
    :PRINT "2 - PRINTOUT OF NOT-IN-STOCK ITEMS
    :PRINT "3 - PRINTOUT ALL ITEMS ON ORDER
    :PRINT "4 - PRINTOUT ALL ITEMS AT OR BELOW REORDER POINT
    :PRINT "5 - PRINTOUT BY VENDOR
    :PRINT "6 - PRINTOUT BY PREFIX / SUFFIX"
1560 PRINT "7 - PRINT SUGGESTED PURCHASE ORDER TO VENDOR
    :PRINT "8 - TEST PRINTER
    :PRINT "@ - EXIT TO MAIN MENU"
1570 PRINT :PRINT "SELECT OPTION --> ";
1580 FL=-1:GOSUB 370:IF CF=1 THEN RETURN  ELSE O$=IN$:IF O$<"1" OR O$>"8" THEN PRINT CHR$(8);:GOTO 1580
1590 GOSUB 3730:IF XX=1 THEN 1530
1600 GOSUB 3000
1610 O=VAL(O$):IF O=8 THEN FOR T=0 TO 131:LPRINT "*";:NEXT :CLS:GOTO 1530
1620 GOSUB 2960:IF O<>7 THEN GOSUB 2970:GOSUB 3000
1630 ON O GOSUB 3250,3270,3290,3310,3330,3360,3430
1640 IF O<>7 THEN GOSUB 2890 ELSE GOSUB 3780
    :FOR N=1 TO TN-1
1650 J=V(N):IF SGN(J)=-1 THEN 1680
1660 ON O GOSUB 3260,3280,3300,3320,3350,3400,3450
1670 REM EN$=INKEY$:IF EN$="@" THEN LPRINT " ":LPRINT "   * TERMINATED *":POKE 16425,1:GOTO 1530
1680 NEXT 
1690 IF O<>1 AND O<>3 AND O<>7 AND O<>5 AND O<>6 THEN 1770
1700 IF O=3 THEN 1760
1710 IF O=7 THEN 3830
1720 IF O=5 OR O=6 THEN 3480
1725 IF  GI<>TI  AND  GC#<>TC#  AND  GP#<>TP#  AND  GR#<>TR#  THEN GOSUB 4050
1730 GI=0:GC#=0:GP#=0:GR#=0:LPRINT " ":LPRINT "TOTAL ITEMS LISTED:";TAB(25)TI
1740 IF CC=0 THEN LPRINT "TOTAL COST VALUE:";TAB(25);:LPRINT  USING L6$;TC#
1750 LPRINT "TOTAL RETAIL VALUE:";TAB(25);:LPRINT  USING L6$;TP#
1760 IF CC=0 THEN LPRINT " ":LPRINT "TOTAL COST OF ORDERS:";TAB(25);:LPRINT  USING L6$;TR#
1770 GOSUB 3240:CLS:GOTO 1530
1780 GOSUB 2630:GOSUB 2660:GOSUB 2670:RETURN 
1790 GOSUB 2540:GOSUB 2600:GOSUB 2610:GOSUB 4000:RETURN 
1800 CLS:PRINT TAB(20)"CREATE NEW INVENTORY"
1810 IF ER=0 THEN PRINT @ 448,"SYSTEM CONTAINS INVENTORY DATA. IF YOU WISH TO THEN ERASE ALL DATA,
    :PRINT "TYPE (SHIFT) K OR ELSE TYPE @ TO RETURN TO MAIN MENU --> "; ELSE 1840
1820 FL=1:GOSUB 370:IF CF=1 THEN RETURN  ELSE T$=IN$:IF T$<>"k" THEN PRINT CHR$(8);:GOTO 1820
1830 CLOSE :KILL PI$:KILL PD$:KILL PT$:KILL PS$:KILL PR$:CLS:PRINT @ 468,"ALL DATA ERASED":ER=1:PRINT :PRINT :GOSUB 2480:RETURN 
1840 TC#=0:TP#=0:TR#=0:TI=0:TN=1:HI=0:HN=1:F=0:ER=0:GOSUB 2530
1850 PRINT @ 460,"SYSTEM READY FOR NEW INVENTORY"
1860 PRINT :PRINT :GOSUB 2480:RETURN 



1870 CLS:PRINT TAB(21)"ENTER SALES TICKETS":PRINT 
1880 IF ER=1 THEN GOSUB 3060:RETURN 
1890 GOSUB 2350:H=HN:HC=0
1900 IF HI<1000 THEN 1910
1901 CLS
1902 PRINT @ 448,"SALES FILE IS FULL (1000 ITEMS). USE FUNCTION 6 TO"
1903 PRINT "POST SALES AND CLEAR THE FILE."
1904 CLOSE 1
1905 GOSUB 2500
1906 RETURN 
    
1910 GOSUB 350
1920 PRINT @ 256,"                           " ' CHR$(31);
1930 IF HC<>0 THEN PRINT @ 295,"(LAST ENTRY: ";HA$;")";
1940 PRINT @ 256,"STOCK NUMBER: ";
1950 FL=10:GOSUB 370:IF CF=0 THEN HA$=IN$ ELSE CLOSE 1:RETURN 
1960 GOSUB 360:PRINT @ 384,"QUANTITY SOLD: ";
1970 FL=-4:GOSUB 370:IF CF=0 THEN HB=VAL(IN$) ELSE 1910
1980 GOSUB 2360:GOSUB 2400:GOSUB 2380
1990 HI=HI+1:HN=HN+1:H=HN:HC=1:GOTO 1900



2000 CLS:PRINT TAB(20)"END OF PERIOD PROCESSING":PRINT 
2010 IF ER=1 THEN GOSUB 3060:RETURN 
2020 PRINT @ 128,"FUNCTIONS:"
    :PRINT "
    :PRINT "1 - POST SALES TICKETS AND CLEAR TICKET FILE
    :PRINT "
    :PRINT "2 - CLEAR CURRENT SALES FIGURES FROM INVENTORY
    :PRINT "
    :PRINT "3 - CLEAR CURRENT AND CUMULATIVE SALES FIGURES FROM INVENTORY
    :PRINT "
    :PRINT "@ - EXIT TO MAIN MENU
    :PRINT "
2030 PRINT "SELECT FUNCTION > ";
2040 FL=-1:GOSUB 370:IF CF=1 THEN RETURN  ELSE HO$=IN$:IF HO$<"1" OR HO$>"3" THEN PRINT CHR$(8);:GOTO 2040
2045 IF VAL(HO$)>1 THEN PRINT "  ARE YOU SURE (Y/N)";:FL=1:GOSUB 370:IF IN$<>"Y" THEN 2000
2050 ON VAL(HO$) GOTO 2060,2260,2280
2060 GOSUB 3730:IF XX=1 THEN 2000
2070 IF HI=0 THEN CLS:PRINT @ 460,"NO UNPOSTED SALES TICKETS IN FILE":GOSUB 2500:GOTO 2000 ELSE GOSUB 2190
2080 CLS:PRINT @ 468,"pOSTING IN PROGRESS"
2090 GOSUB 2350:HT=HI:HC#=0
2100 FOR H=1 TO HI
2110 GOSUB 2360:GOSUB 2400:GOSUB 2410:IS$=HA$
2120 GOSUB 2420:IF K=0 THEN GOSUB 2200:GOTO 2170
2130 GOSUB 2540:GOSUB 2600:GOSUB 2610
2140 P1=P1+HB:P2=P2+HB:HC#=HC#+HB*IC
2150 IQ%=IQ%-HB:TC#=TC#-HB*IC:TP#=TP#-HB*IP:IF IQ%<0 THEN GOSUB 2220
2160 GOSUB 2560:HT=HT-1:PRINT @ 596,"TICKETS REMAINING: ";HT
2170 NEXT :GOSUB 2230
2180 HI=0:HN=1:CLOSE 1:KILL PR$:GOTO 2000
2190 GOSUB 2960:LPRINT TAB(30)"SALES TICKET POSTING REPORT":LPRINT LF$:RETURN 
2200 LPRINT "E R R O R : STOCK # ";HA$;" IS NOT IN INVENTORY LISTING AND WAS NOT POSTED":LPRINT LF$
2210 RETURN 
2220 LPRINT "N O T E : STOCK # ";HA$;" NOW HAS A QUANTITY OF ";IQ%:LPRINT LF$:RETURN 
2230 LPRINT "NUMBER OF ITEMS POSTED: ";HI-HT
2240 LPRINT "TOTAL COST OF GOODS SOLD: "; USING L6$;HC#
2250 GOSUB 3240:RETURN 
2260 CLS:PRINT @ 463,"CLEARING CURRENT SALES FIGURES"
2270 GOSUB 2300:GOTO 2000
2280 CLS:PRINT @ 460,"CLEARING CURRENT AND CUMULATIVE SALES FIGURES"
2290 GOSUB 2300:GOTO 2000
2300 FOR J=1 TO TN-1
2310 GOSUB 2540:GOSUB 2600:GOSUB 2610
2320 IF HO$="3" THEN P2=0
2330 P1=0
2340 GOSUB 2560:NEXT :RETURN 
2350 OPEN "R",1,PR$,PR%
2355 RETURN 
2360 HR = H : HD = 0 ' HR=INT((H-1)/20)+1:HD=H-20*INT((H-1)/20)-1
2370 FIELD 1,10 AS H1$,ZINT AS H2$:RETURN 
2380 LSET H1$=HA$:RSET H2$=MKI$(HB)
2390 PUT 1,HR:RETURN 
2400 GET 1,HR:RETURN 
2410 HA$=H1$:HB=CVI(H2$):RETURN 



2420 NL=0:NH=TN
2430 K=INT((NH-NL)/2):IF K=0 THEN RETURN  ELSE N=K+NL
2435 IF N=NH THEN NH=INT((NH-NL)/2)+NL:GOTO 2430 ELSE IF V(N)<0 THEN N=N+1:GOTO 2435
2440 J=ABS(V(N)):GOSUB 2630:GOSUB 2660:IF IS$+STRING$(10-LEN(IS$)," ")=N$ THEN IS$=N$:GOTO 2470
2450 IF IS$+STRING$(10-LEN(IS$)," ")<N$ THEN NH=N:GOTO 2430
2460 NL=N:GOTO 2430
2470 IF SGN(V(N))=-1 THEN K=0:RETURN  ELSE RETURN 



2480 PRINT TAB(10)"TYPE @ TO RETURN TO MAIN MENU --> ";
2490 FL=1:GOSUB 370:IF CF=1 THEN RETURN  ELSE PRINT CHR$(8);:GOTO 2490
2500 FOR T=1 TO 2500:NEXT :RETURN 
2510 PRINT @ 256,"0 - STOCK # -------->
    :PRINT "1 - DESCRIPTION ---->
    :PRINT "2 - QUANTITY ------->
    :PRINT "3 - COST ----------->
    :PRINT "4 - SELL ----------->
    :PRINT "5 - LOCATION ------->
    :PRINT "6 - REORDER PT/QTY-->
    :PRINT "7 - # ON ORDER ----->
    :PRINT "8 - DATE LAST ORDER->
    :PRINT "9 - VENDOR --------->";CHR$(31);
2520 RETURN 
2530 OPEN "R",2,PD$,PD%
2535 OPEN "R",3,PS$,PS%
2537 RETURN 
2540 JR = J : JD = 0 ' JR=INT((J-1)/4)+1:JD=J-4*INT((J-1)/4)-1
2550 FIELD 2, 19 AS FD$, ZINT AS FQ$, ZSNG AS FC$, ZSNG AS FP$, 10 AS FL$, ZINT AS FR$, ZINT AS FA$, ZINT AS FO$, 8 AS FM$, 6 AS FV$, ZINT AS P1$, ZINT AS P2$:RETURN 
2560 LSET FD$=ID$:RSET FQ$=MKI$(IQ%):RSET FC$=MKS$(IC)
2570 RSET FP$=MKS$(IP):LSET FL$=IL$:RSET FR$=MKI$(IR%):RSET FA$=MKI$(IN%)
2580 RSET FO$=MKI$(IO%):LSET FM$=IM$:LSET FV$=IV$:RSET P1$=MKI$(P1):RSET P2$=MKI$(P2)
2590 PUT 2,JR:RETURN 
2600 GET 2,JR:RETURN 
2610 ID$=FD$
2611 IQ%=CVI(FQ$)
2612 IC=CVS(FC$)
2613 IP=CVS(FP$)
2614 IL$=FL$
2620 IR%=CVI(FR$)
2621 IN%=CVI(FA$)
2622 IO%=CVI(FO$)
2623 IM$=FM$
2624 IV$=FV$
2625 P1=CVI(P1$)
2626 P2=CVI(P2$)
2627 RETURN 
2630 JR = J : JD = 0 ' JR=INT((J-1)/25)+1:JD=J-25*INT((J-1)/25)-1
2640 FIELD 3, 10 AS N$:RETURN 
2650 LSET N$=IS$:PUT 3,JR:RETURN 
2660 GET 3,JR:RETURN 
2670 IS$=N$:RETURN 
2680 OPEN "I",1,PI$,PI%
2685 OPEN "I",3,PT$,PT%
2690 INPUT  #3,TC#,TP#,TR#,TI,HI:CLOSE 3
2700 INPUT  #1,TN,HN,F
2710 FOR N=1 TO TN-1:INPUT  #1,V(N):NEXT :CLOSE 1:RETURN 
2720 OPEN "O",1,PI$,PI%
2730 WRITE #1,TN,HN,F
2740 FOR N=1 TO TN-1:WRITE #1,V(N):NEXT :CLOSE 1:RETURN 
2750 OPEN "O",3,PT$,PT%
2755 WRITE #3,TC#,TP#,TR#,TI,HI:CLOSE 3:RETURN 
2760 PRINT @ A0,CHR$(30);:GOSUB 2510:GOSUB 2540:GOSUB 2600:GOSUB 2610:PRINT @ A0,IS$;:GOSUB 2860:RETURN 
2770 DATA 281,345,409,473,537,601,665,729,793,857,128,490,960
2780 PRINT @ AA,CHR$(30):PRINT CHR$(30);:PRINT @ AA,;:RETURN 
2790 DATA "####"
2800 DATA "####.##" ' HERE-HERE-HERE
2810 DATA "$$###,####.##"
2820 DATA "###.#"
2830 IF IP<>0 THEN PRINT @ 552,"GROSS PROFIT= ";:PRINT USING L7$;FNGP(IC,IP);:PRINT " %";:RETURN  ELSE RETURN 
2840 IF CC=1 THEN LPRINT "  ****";:RETURN 
2850 IF IP<>0 THEN LPRINT " "; USING L7$;FNGP(IC,IP);:RETURN  ELSE RETURN 



2860 PRINT @ A1,ID$:PRINT @ A2,IQ%:PRINT @ A3, USING L1$;IC:PRINT @ A4, USING L1$;IP:GOSUB 2830
2870 PRINT @ A5,IL$:PRINT @ A6,IR%;"/";IN%:PRINT @ A7,IO%:PRINT @ A8,IM$:PRINT @ A9, IV$:GOSUB 3860




2880 RETURN 
2890 LPRINT "STOCK #     DESCRIPTION           QTY     COST     SELL  GP %  LOCATION    R/O PT / QTY   ON ORDER  DATE      VENDOR   CURR / CUML"
2900 LPRINT "=======     ===========           ===     ====     ====  ====  ========    =====   ====   ========  ====      ======   ====   ===="
2910 LPRINT " ":RETURN 



2915 REM FUNKY USING ERROR
2920 GOSUB 3720:LPRINT IS$;TAB(12)ID$;TAB(33);:LPRINT  USING L0$;IQ%;:LPRINT TAB(39);:IF CC=0 THEN LPRINT  USING L1$;IC; ELSE LPRINT "   ****";
2930 LPRINT TAB(48);USING L1$;IP;:GOSUB 2840
2940 LPRINT TAB(63)IL$;"  ";:LPRINT  USING L0$;IR%;:LPRINT " / ";:LPRINT  USING L0$;IN%;:LPRINT "      ";:LPRINT  USING L0$;IO%;:LPRINT "    ";IM$;"  ";IV$;"   "; USING L0$;P1;:LPRINT " / "; USING L0$;P2
2950 RETURN 




2960 LPRINT LL$:LPRINT LF$:LPRINT LF$:LPRINT LEFT$(TIME$,8):LPRINT LF$:RETURN 
2970 CLS:PRINT @ 456,"DO YOU WANT TO SUPPRESS COST AND PROFIT FIGURES ? ";
2980 FL=1:GOSUB 370:IF IN$<>"Y" AND IN$<>"N" THEN PRINT CHR$(8);:GOTO 2980
2990 IF IN$="N" THEN CC=0:RETURN  ELSE CC=1:RETURN 
3000 PRINT @ 128,CHR$(31):PRINT @ 470,"** PRINTING **":RETURN 
3010 GOSUB 2680:IF ER=1 THEN RESUME 3050
3020 PRINT @ 128,CHR$(31);
3030 GOSUB 2530
3040 GOTO 240
3050 PRINT @ 448,CHR$(30);CHR$(29);"NO DATA IN SYSTEM. USE FUNCTION 4 OF MENU TO CREATE INVENTORY.":PRINT :GOSUB 2480:GOTO 240
3060 PRINT @ 458,"NO DATA IN SYSTEM! USE FUNCTION 4 FIRST!":GOSUB 2500:RETURN 
3070 PRINT :PRINT "NUMBER OF ITEMS CURRENTLY IN LISTING: ";TI
3080 PRINT "NUMBER OF UNPOSTED SALES TICKETS: ";HI
3090 PRINT "TOTAL COST (WHOLESALE) VALUE: ";:PRINT USING L6$;TC#
3100 PRINT "TOTAL RETAIL SALE VALUE ----: ";:PRINT USING L6$;TP#
3110 PRINT "TOTAL VALUE OF ITEMS ORDERED: ";:PRINT USING L6$;TR#
3120 RETURN 
3130 IF F=0 THEN V(J)=J:RETURN 
3140 FOR N=1 TO TN-1
3150 IF SGN(V(N))=-1 THEN V(N)=ABS(V(N)):J=V(N):TN=TN-1:F=F-1:RETURN 
3160 NEXT :F=0:V(J)=J:RETURN 
3170 PI$="INDEXFIL"
    :PD$="DATAFILE"
    :PT$="INFOFILE"
    :PS$="STOCKNUM"
    :PR$="SALEDATA"
3175 ZINT = LEN(MKI$(0)) 
    :ZSNG = LEN(MKS$(0)) 
    :PI%=80
    :PD%=19 + ZINT + ZSNG + ZSNG + 10 + ZINT + ZINT + ZINT + 8 + 6 + ZINT + ZINT
    :PT%=80
    :PS%=10
    :PR%=10 + ZINT
    :RETURN


3180 PRINT @ 472,"ENTER PASSWORD ---> ";
3185 INPUT P$ : RETURN
3190 P$="":FOR X=1 TO 8
3200 PE$=INKEY$:IF PE$="" THEN 3200 ELSE IF PE$<" " OR PE$>"Z" THEN 3220
3210 P$=P$+PE$:PRINT "#";:GOTO 3230
3220 IF ASC(PE$)=13 THEN RETURN  ELSE 3200
3230 NEXT :RETURN 


3240 LPRINT " ":LPRINT "END OF LISTING":LPRINT LL$:LPRINT CHR$(12):RETURN 
3250 LPRINT TAB(30)"COMPLETE INVENTORY LISTING":LPRINT " ":RETURN 
3260 GOSUB 1780
    :GOSUB 1790
    :GOSUB 2920
    :RETURN 



3270 LPRINT TAB(30)"LISTING OF NOT-IN-STOCK ITEMS":LPRINT " ":RETURN 
3280 GOSUB 1790:IF IQ%>0 THEN RETURN  ELSE GOSUB 1780:GOSUB 2920:RETURN 
3290 LPRINT TAB(30)"LISTING OF ALL ITEMS ON ORDER":LPRINT " ":RETURN 
3300 GOSUB 1790:IF IO%=0 THEN RETURN  ELSE GOSUB 1780:GOSUB 2920:RETURN 
3310 LPRINT TAB(30)"LISTING OF ALL ITEMS AT OR BELOW REORDER POINT":LPRINT " ":RETURN 
3320 GOSUB 1790:IF IQ%>IR% THEN RETURN  ELSE GOSUB 1780:GOSUB 2920:RETURN 
3330 GOSUB 3530:GOSUB 3000
3340 LPRINT TAB(30)"LISTING BY VENDOR: ";IX$:LPRINT " ":GOSUB 3460:RETURN 
3350 GOSUB 1790:IF LEFT$(IV$,LEN(IX$))<>IX$ THEN RETURN  ELSE GOSUB 1780:GOSUB 3470:GOSUB 2920:RETURN 
3360 CLS:GOSUB 3460:PRINT @ 468,"(P)REFIX OR (S)UFFIX ? "
3370 S$=INKEY$:IF S$<>"P" AND S$<>"S" THEN 3370
3380 IF S$="P" THEN PRINT @ 532,"ENTER PREFIX --> ";:FL=10:GOSUB 370:K$=IN$:GOSUB 3000:LPRINT TAB(30)"LISTING BY PREFIX: ";K$:LPRINT " ":RETURN 
3390 PRINT @ 532,"ENTER SUFFIX --> ";:FL=10:GOSUB 370:K$=IN$:GOSUB 3000:LPRINT TAB(30)"LISTING BY SUFFIX: ";K$:LPRINT " ":RETURN 
3400 GOSUB 1780:IF S$="S" THEN 3420
3410 IF LEFT$(IS$,LEN(K$))<>K$ THEN RETURN  ELSE GOSUB 1790:GOSUB 3470:GOSUB 2920:RETURN 
3420 IF RIGHT$(IS$,LEN(K$))<>K$ THEN RETURN  ELSE GOSUB 1790:GOSUB 3470:GOSUB 2920:RETURN 
3430 GOSUB 3530:GOSUB 3000
3440 LPRINT TAB(20)"SUGGESTED PURCHASE ORDER TO VENDOR: ";IX$:LPRINT " ":TT=0:T1#=0:RETURN 
3450 GOSUB 1790:IF LEFT$(IV$,LEN(IX$))<>IX$ OR IQ%>IR% OR IR%<(IO%+IQ%) THEN RETURN  ELSE GOSUB 1780:GOSUB 3800:RETURN 
3460 TT=0:T1#=0:T2#=0:T3#=0:RETURN 
3470 TT=TT+1:T1#=T1#+IQ%*IC:T2#=T2#+IQ%*IP:T3#=T3#+IO%*IC:RETURN 
3480 LPRINT " ":LPRINT "NUMBER OF ITEMS:";TAB(25)TT
3490 IF CC=0 THEN LPRINT "TOTAL COST VALUE:";TAB(25) USING L6$;T1#
3500 LPRINT "TOTAL RETAIL VALUE:";TAB(25) USING L6$;T2#
3510 IF CC=0 THEN LPRINT "TOTAL COST OF ORDERS:";TAB(25) USING L6$;T3#
3520 GOSUB 3240:CLS:GOTO 1540
3530 CLS:PRINT @ 450,"ENTER ENOUGH LETTERS TO IDENTIFY VENDOR --> ";
3540 FL=6:GOSUB 370:IX$=IN$:RETURN 


3550 REM ------------------------------------------------------
3555 IF ERR/2+1=54 THEN ER=1:RETURN 
3560 IF ERR/2+1=57 THEN 3610
3570 IF ERR/2+1=68 THEN CLS:CLOSE :PRINT @ 458,"NO DISK IN DRIVE #1 - RUN TERMINATED":CLEAR 50:PRINT :PRINT :END
3580 IF ERR/2+1=70 THEN CLS:PRINT @ 465,"UNAUTHORIZED ACCESS TO INVENTORY SYSTEM
    :PRINT ""TAB(28)"RUN TERMINATED":PRINT :CLEAR 50:END
3590 PRINT :PRINT CHR$(30);"UNEXPECTED ERROR CODE ";ERR/2+1;"IN LINE";ERL:GOSUB 2500:GOTO 330



3600 ON ERROR  GOTO 0
3610 CLS:PRINT @ 404,"** DISK I/O ERROR **":TE=TE+1
3620 PRINT @ 586,"TOTAL I/O ERRORS THIS RUN: ";TE
3630 PRINT @ 650,"THIS ERROR OCCURRED IN LINE";ERL
3640 PRINT @ 778,"(T)RY AGAIN OR (E)XIT FROM PROGRAM ? ";
3650 FL=1:GOSUB 370:IF IN$<>"T" AND IN$<>"E" THEN PRINT CHR$(8);:GOTO 3650
3660 IF IN$="T" THEN RESUME  ELSE 330
3670 OPEN "O",1,"TRANSFER"
3680 PRINT #1,PI$:PRINT #1,PS$:PRINT #1,PD$:PRINT #1,PT$:PRINT #1,PR$
3690 CLOSE 1:CLEAR 50
3700 PRINT "*** RUNNING DATASORT ***":RUN "DATASORT.BAS"
3710 END
3720 IF PEEK(&H4029)<58 THEN RETURN  ELSE LPRINT CHR$(12):GOSUB 2960:GOSUB 2890:RETURN 
3730 IF PEEK(14312)<=127 THEN XX=0:RETURN 
3740 CLS:PRINT @ 468,"PRINTER NOT READY !!":XX=1:GOSUB 2500:CLS:RETURN 
3750 IF CF<>0 THEN RETURN 
3760 IF LEN(IN$)>=3 THEN IF MID$(IN$,LEN(IN$)-2,1)="." THEN RETURN 
3770 PRINT " INVALID FORMAT !";:FOR T=1 TO 1000:NEXT :CF=2:RETURN 
3780 LPRINT " QTY       STOCK #         DESCRIPTION             COST         EXTENSION"
3790 LPRINT " ===        ========       ===========             ====         =========":LPRINT " ":RETURN 
3800 TT=TT+1:T1#=T1#+IN%*IC
3810 LPRINT  USING L0$;IN%;:LPRINT TAB(12)IS$;TAB(27)ID$;:LPRINT TAB(48) USING L1$;IC;:LPRINT TAB(60) USING L6$;IN%*IC
3820 RETURN 
3830 LPRINT " ":LPRINT "TOTAL ITEMS:";TT
3840 LPRINT "TOTAL COST OF ORDER:";TAB(20) USING L6$;T1#
3850 GOSUB 3240:CLS:GOTO 1540
3860 PRINT @ 616,"CURRENT SALES   : ";P1;
3870 PRINT @ 680,"CUMULATIVE SALES: ";P2;
3880 RETURN 
4000 GC#=GC#+IQ%*IC:GP#=GP#+IQ%*IP:GR#=GR#+IO%*IC:GI=GI+1:RETURN 
4050 TI=GI:TC#=GC#:TP#=GP#:TR#=GR#:RETURN 

5000 REM -----------------------------------
5010 REM CHECK FOR MISSING FILES
5020 REM -----------------------------------
5100 IF ERL =   45 THEN RESUME 110
5110 IF ERL = 2611 THEN IQ%=0 : RESUME NEXT
5120 IF ERL = 2612 THEN IC =0 : RESUME NEXT
5130 IF ERL = 2613 THEN IP =0 : RESUME NEXT
5140 IF ERL = 2620 THEN IR%=0 : RESUME NEXT
5150 IF ERL = 2621 THEN IN%=0 : RESUME NEXT
5160 IF ERL = 2622 THEN IO%=0 : RESUME NEXT
5170 IF ERL = 2625 THEN P1 =0 : RESUME NEXT
5180 IF ERL = 2626 THEN P2 =0 : RESUME NEXT



5300 PRINT:PRINT "UNEXPECTED ERROR CODE";ERR;"IN LINE";ERL
5310 IF ERL = 2350 THEN PRINT "MISSING RANDOM FILE:";PR$
5320 IF ERL = 2530 THEN PRINT "MISSING RANDOM FILE:";PD$
5330 IF ERL = 2535 THEN PRINT "MISSING RANDOM FILE:";PS$
5340 IF ERL = 2680 THEN PRINT "MISSING INPUT  FILE:";PI$
5350 IF ERL = 2685 THEN PRINT "MISSING INPUT  FILE:";PT$
5360 IF ERL = 2720 THEN PRINT "MISSING OUTPUT FILE:";PI$
5370 IF ERL = 2750 THEN PRINT "MISSING OUTPUT FILE:";PT$
5380 IF ERL = 3670 THEN PRINT "MISSING OUTPUT FILE:";"TRANSFER"


9999 END



