*COMPARE.CMD
ERASE
SET TALK OFF
ACCEPT "DO YOU WANT TO PRINT THIS FILE? (Y/N)" TO P
IF P="N" .OR. P="n"
SET FORMAT TO SCREEN
ERASE
ELSE
@ 5,5 SAY "GET YOUR PRINTER READY NOW. I'LL WAIT."
WAIT
SET EJECT OFF
SET FORMAT TO PRINT
ENDIF
SET MARGIN TO 0
@  0, 0 SAY CHR(15)+"MONTH OF"
ACCEPT "ENTER MONTH" TO MO
@  0,10 SAY MO
@  1, 0 SAY "COMPARED WITH YEAR-TO-DATE"
@  3, 0 SAY "=================================================="
@  3,50 SAY "==============================================="
@  4,12 SAY "|  PCS SOLD |      COST         |   SELLING PRICE "      
@  4,64 SAY "|    GROSS PROFIT   |  GROSS %  "
@  5,0  SAY "------------|-----------|-------------------|-------------------"
@  5,64 SAY "|-------------------|------------"
@  6, 0 SAY "LINE        |"
@  6,14 SAY mo
@  6,20 SAY "YTD |"
@  6,29 SAY mo
@  6,37 SAY "YTD    |"
@  6,49 SAY mo
@  6,58 SAY "YTD   |"
@  6,69 SAY mo
@  6,78 SAY "YTD   |"
@  6,85 SAY mo
@  6,92 SAY "YTD  "
@  7, 0 SAY "------------|-----------|-------------------|-------------------"
@  7,64 SAY "|-------------------|------------"
USE B:LINEFILE
STORE 7 TO X
SELECT SECONDARY
USE B:ITEMS
STORE 0 TO MOPCT
STORE 0 TO YRPCT
STORE 0 TO MOCT
STORE 0 TO YRCT
STORE 0 TO MOPT
STORE 0 TO YRPT
STORE 0 TO MOGT
STORE 0 TO YRGT
STORE 0 TO MGPT
STORE 0 TO YGPT
SELECT PRIMARY
GOTO TOP
DO WHILE .NOT. EOF
STORE LINE TO LN
@ X+1,0 SAY LN
SELECT SECONDARY
USE B:ITEMS
@  X+1,12 SAY "|"
   COUNT FOR (LINE=LN .AND. SELLPRICE>1 .AND. MONTH=MO) TO MOPC
   @  X+1,13 SAY mopc USING '#####'
   COUNT FOR (LINE=LN .AND. SELLPRICE>1) TO YRPC
   @  X+1,19 SAY yrpc USING '#####'
   @  X+1,24 SAY "|"
   SUM COST FOR (LINE=LN .AND. SELLPRICE>1 .AND. MONTH=MO) TO MOC
   @  X+1,25 SAY moc USING '#####.##'
   SUM COST FOR (LINE=LN .AND. SELLPRICE>1) TO YRC
   @  X+1,35 SAY yrc USING '#####.##'
   @  X+1,44 SAY "|"
   SUM SELLPRICE FOR (LINE=LN .AND. SELLPRICE>1 .AND. MONTH=MO) TO MOP 
   @  X+1,45 SAY mop USING '#####.##'
   SUM SELLPRICE FOR (LINE=LN .AND. SELLPRICE>1) TO YRP
   @  X+1,55 SAY yrp USING '#####.##'
   @  X+1,64 SAY "|"
   SUM (SELLPRICE-COST) FOR LINE=LN .AND. SELLPRICE>1 .AND. MONTH=MO TO MOG
   @  X+1,65 SAY mog USING '#####.##'
   SUM (SELLPRICE-COST) FOR LINE=LN .AND. SELLPRICE>1 TO YRG
   @  X+1,75 SAY yrg USING '#####.##'
   @  X+1,84 SAY "|"
IF MOP=0
STORE 0 TO MGP
@ X+1,85 SAY MGP USING '#.##' 
ELSE
     STORE MOG/MOP TO MGP
     STORE "(INT((MGP+.005)*100))/100.00" TO MPC
     @  X+1,85 SAY &MPC USING '#.##'
ENDIF
     IF YRP=0
     STORE 0 TO YGP
     @ X+1,91 SAY YGP USING '#.##'
ELSE
     STORE YRG/YRP TO YGP
     STORE "(INT((YGP+.005)*100))/100.00" TO YPC
     @  X+1,91 SAY &YPC USING '#.##'
ENDIF
STORE X+1 TO X
   STORE MOPCT+MOPC TO MOPCT
   STORE YRPCT+YRPC TO YRPCT
   STORE MOCT+MOC TO MOCT
   STORE YRCT+YRC TO YRCT
   STORE MOPT+MOP TO MOPT
   STORE YRPT+YRP TO YRPT
   STORE MOGT+MOG TO MOGT
   STORE YRGT+YRG TO YRGT
SELECT PRIMARY
SKIP
ENDDO
STORE X+1 TO X
@  X, 0 SAY "------------|-----------|-------------------|-------------------"
@  X,64 SAY "|-------------------|------------"
STORE X+1 TO X
@ X,0 SAY "TOTALS"
@ X,12 SAY "|"
   @ X,13 SAY MOPCT USING '#####'
   @ X,19 SAY YRPCT USING '#####'
   @ X,24 SAY "|"
   @ X,25 SAY MOCT USING '#####.##'
   @ X,35 SAY YRCT USING '#####.##'
   @ X,44 SAY "|"
   @ X,45 SAY MOPT USING '#####.##'
   @ X,55 SAY YRPT USING '#####.##'
   @ X,64 SAY "|"
   @ X,65 SAY MOGT USING '#####.##'
   @ X,75 SAY YRGT USING '#####.##'
   @ X,84 SAY "|"
STORE MOGT/MOPT TO MPERCENT
STORE "(INT((MPERCENT+.005)*100))/100.00" TO MTOT
   @ X,85 SAY &MTOT USING '#.##'
   STORE YRGT/YRPT TO YPERCENT
   STORE "(INT((YPERCENT+.005)*100))/100.00" TO YTOT
   @ X,91 SAY &YTOT USING '#.##'
@ X,0 SAY CHR(18)+' '
ENDDO
RELEASE ALL
SET PRINT OFF
SET FORMAT TO SCREEN
WAIT
DO B:INVCON
