* ADDITEM.CMD
* RLS
* MAR 1986
USE grocery&gs INDEX item&gs
STORE t TO noquit
STORE f TO flag
SET COLON ON
DO WHILE noquit
STORE t TO notready
ERASE
SET INTENSITY OFF
RESTORE FROM GRAPHICS ADDITIVE
@ 1,1 SAY gr:on
@  3, 1 SAY gr:ltc + gr:line
@  4, 1 SAY gr:vert
@  5, 1 SAY gr:vert
@  6, 1 SAY gr:vert
@  7, 1 SAY gr:vert
@  8, 1 SAY gr:vert
@  9, 1 SAY gr:lmid + gr:line
@ 10, 1 SAY gr:vert
@ 11, 1 SAY gr:vert
@ 12, 1 SAY gr:vert
@ 13, 1 SAY gr:vert
@ 14, 1 SAY gr:vert 
@ 15, 1 SAY gr:vert 
@ 16, 1 SAY gr:vert 
@ 17, 1 SAY gr:vert 
@ 18, 1 SAY gr:vert 
@ 19, 1 SAY gr:vert 
@ 20, 1 SAY gr:vert 
@ 21, 1 SAY gr:lbc + gr:line
@  9,30 SAY gr:umid
@ 10,30 SAY gr:vert
@ 11,30 SAY gr:vert
@ 12,30 SAY gr:vert
@ 13,30 SAY gr:vert
@ 14,30 SAY gr:vert
@ 15,30 SAY gr:vert
@ 16,30 SAY gr:vert
@ 17,30 SAY gr:vert
@ 18,30 SAY gr:vert
@ 19,30 SAY gr:vert
@ 20,30 SAY gr:vert
@ 21,30 SAY gr:bmid
@ 21,79 SAY gr:rbc
@ 20,79 SAY gr:vert
@ 19,79 SAY gr:vert
@ 18,79 SAY gr:vert
@ 17,79 SAY gr:vert
@ 16,79 SAY gr:vert
@ 15,79 SAY gr:vert
@ 14,79 SAY gr:vert
@ 13,79 SAY gr:vert
@ 12,79 SAY gr:vert
@ 11,79 SAY gr:vert
@ 10,79 SAY gr:vert
@  9,79 SAY gr:rmid
@  8,79 SAY gr:vert
@  7,79 SAY gr:vert
@  6,79 SAY gr:vert
@  5,79 SAY gr:vert
@  4,79 SAY gr:vert
@  3,79 SAY gr:rtc
@ 22,1 SAY gr:off
RELEASE ALL LIKE gr:*
@  6,8 SAY "d B A S E   S H O P P E R :  A D D  O R  D E L E T E  I T E M S"
DO WHILE notready
STORE " " TO mfunction
SET INTENSITY ON
@ 11,5 SAY "                Function"
SET INTENSITY OFF
@ 11,33 GET mfunction PICTURE "!"
SET INTENSITY ON
@ 11,40 SAY "<A>dd or <D>elete or <Q>uit"
SET INTENSITY OFF
READ
CLEAR GETS
IF mfunction $"ADQ"
 STORE f TO notready 
ELSE
 @ 22,10 SAY "Your selection was not acceptable.  Try again."
 SET CONSOLE OFF
 WAIT
 SET CONSOLE ON  
 @ 22,0
ENDIF
ENDDO notready
DO CASE
 CASE mfunction = "Q"
  IF flag
    @ 22,0
    @ 22,10 SAY " WORKING "
    PACK
    ?? ". . ."
    REINDEX
    ?? ". . ."
    USE grocery&gs INDEX aisle&gs
    ?? ". . . Almost done!"
    REINDEX
  ENDIF
  SET COLON OFF
  RELEASE notready, mfunction, mquit, maisle, mitem, mcoupon, mcomments, ans
  RETURN
 CASE mfunction = "A"
  STORE t TO nothru
  DO WHILE nothru
  STORE t TO noitem
  DO WHILE noitem
  STORE "                    " TO mitem
  @ 13,5 SAY "               Item name"     
  @ 13,33 GET mitem PICTURE "!!!!!!!!!!!!!!!!!!!!"
  READ
  FIND &mitem
  IF # # 0
   @ 22,10 SAY "Your item is already on the list. <Q>uit or <T>ry again."
   SET CONSOLE OFF
   WAIT TO ans
   SET CONSOLE ON
   IF !(ans)="Q"
    STORE f TO nothru,noitem
   ENDIF
   @ 22,0
  ELSE
   STORE f TO noitem
  ENDIF
  ENDDO noitem  
  IF nothru
  STORE "   " TO maisle
  STORE "                    " TO mcomments
  STORE "     " TO mcoupon
  @ 15,5 SAY "                   Aisle"  
  @ 16,5 SAY "                Comments"
  @ 17,5 SAY "                  Coupon"
  @ 15,33 GET maisle
  @ 16,33 GET mcomments
  @ 17,33 GET mcoupon
  READ
  CLEAR GETS
  APPEND BLANK
  REPLACE item WITH mitem, aisle WITH maisle, comments WITH mcomments
  REPLACE coupon WITH mcoupon
  STORE t TO flag
  @ 22,10 SAY " Add another item or quit? <A/Q> "
  SET CONSOLE OFF
  WAIT TO ans
  SET CONSOLE ON
  @ 22,0
  IF !(ans) = "Q"
    STORE f TO nothru
  ELSE
    STORE "                        " TO blank
    @ 15,5 SAY blank
    @ 16,5 SAY blank
    @ 17,5 SAY blank
    @ 17,33 SAY blank
    @ 16,33 SAY blank
    @ 15,33 SAY blank 
  ENDIF
  ENDIF nothru
  ENDDO nothru  
 CASE mfunction = "D"
  STORE t TO nothru
  DO WHILE nothru
  STORE t TO noitem
  DO WHILE noitem
  STORE "                    " TO mitem
  @ 13,5 SAY "               Item name"     
  @ 13,33 GET mitem PICTURE "!!!!!!!!!!!!!!!!!!!!"
  READ
  FIND &mitem
  IF # = 0
   @ 22,10 SAY "Your item is not on the list. <Q>uit or <T>ry again."
   SET CONSOLE OFF
   WAIT TO ans
   SET CONSOLE ON
   IF !(ans)="Q"
    STORE f TO nothru,noitem
   ENDIF
   @ 22,0
  ELSE
   STORE f TO noitem
  ENDIF
  ENDDO noitem  
  IF nothru
  STORE aisle TO maisle
  STORE comments TO mcomments
  STORE coupon TO mcoupon
  @ 15,5 SAY "                   Aisle"  
  @ 16,5 SAY "                Comments"
  @ 17,5 SAY "                  Coupon"
  @ 15,33 SAY maisle
  @ 16,33 SAY mcomments
  @ 17,33 SAY mcoupon
  @ 22, 10 SAY "Delete this item? <Y>es/<N>o "
  SET CONSOLE OFF
  WAIT TO ans
  SET CONSOLE ON
  IF !(ans) = "Y"
    DELETE
    STORE t TO flag
  ENDIF
  @ 22,0
  @ 22,10 SAY "Delete another item or quit? <D>/<Q> "
  SET CONSOLE OFF
  WAIT TO ans
  SET CONSOLE ON
  @ 22,0
  IF !(ans) = "Q"
    STORE f TO nothru
  ELSE
    STORE "                        " TO blank
    @ 15,5 SAY blank
    @ 16,5 SAY blank
    @ 17,5 SAY blank
    @ 17,33 SAY blank
    @ 16,33 SAY blank
    @ 15,33 SAY blank 
  ENDIF
  ENDIF nothru
  ENDDO nothru
ENDCASE
ENDDO noquit
