REM 12xi97nv.bas thro' v.bat  *********
REM *************** For Scrollable lists, this is a good model ******
REM *********** Found to be the best on 11th November, 1997 07.45 hrs ***
REM ********* Right upto saving in lsy and muritm everything seems ok ***********

dupl = 0
selslno = 0
OPEN "c:\1213fils\16699cst.dat" FOR INPUT AS #1
 OPEN "c:\1213fils\16699csc.dat" FOR OUTPUT AS #2
REM  IF EOF(1) = False THEN
 DO WHILE NOT EOF(1)
REM IF EOF(1) = False THEN
INPUT #1, slno, type$, name$, comp$, rate
 quan = 0!
 itmamt = 0!
 WRITE #2, slno, type$, name$, comp$, rate, quan, itmamt
dupl = dupl + 1
LOOP
REM enddo
REM END IF
CLOSE #1
CLOSE #2

down$ = CHR$(0) + CHR$(80)
up$ = CHR$(0) + CHR$(72)
return$ = CHR$(13)
esc$ = CHR$(27)
ra$ = CHR$(0) + CHR$(77)
la$ = CHR$(0) + CHR$(75)
del$ = CHR$(0) + CHR$(83)

DIM slno(dupl), type$(dupl), name$(dupl), rate(dupl), comp$(dupl), quan(dupl), itmamt(dupl)
DIM mslno(dupl), mtype$(dupl), mname$(dupl), mrate(dupl), mcomp$(dupl), mquan(dupl), mitmamt(dupl)

CLS
OPEN "c:\1213fils\16699csc.DAT" FOR INPUT AS #1
counter = 0
FOR counter = 0 TO (dupl - 1)
INPUT #1, slno(counter), type$(counter), name$(counter), comp$(counter), rate(counter), quan(counter), itmamt(counter)
NEXT counter
CLOSE #1

90
CLS
LOCATE 12, 5
INPUT "  Enter the first letter of the name of the medicine you want :  ", mednam$

100
CLS
COLOR 10, 0
row = 4
dupl2 = 0
selslno = 0
FOR dupl1 = 0 TO (dupl - 1)
  IF UCASE$(MID$(name$(dupl1), 1, 1)) = UCASE$(mednam$) THEN 'AND quan(dupl1) = 0 THEN
  IF quan(dupl1) = 0 THEN
   mslno(dupl2) = slno(dupl1)
   mtype$(dupl2) = type$(dupl1)
   mname$(dupl2) = name$(dupl1)
   mcomp$(dupl2) = comp$(dupl1)
   mrate(dupl2) = rate(dupl1)
   mquan(dupl2) = quan(dupl1)
   mitmamt(dupl2) = itmamt(dupl1)
   IF mslno(dupl2) > 0 AND row <= 20 THEN
    LOCATE row, 1
    PRINT TAB(10); mslno(dupl2); TAB(15); mtype$(dupl2); TAB(20); mname$(dupl2); TAB(70); mquan(dupl2)
    row = row + 1
    END IF
   dupl2 = dupl2 + 1
   END IF
 END IF
NEXT dupl1
GOSUB 200


COLOR 10, 0
CLS
medbltot = 0
selslno = 0
FOR dupl1 = 0 TO (dupl - 1)
 IF quan(dupl1) > 0 THEN
 selslno = selslno + 1
 itmamt(dupl1) = quan(dupl1) * rate(dupl1)
 medbltot = medbltot + itmamt(dupl1)
 PRINT TAB(2); selslno; "."; TAB(6); type$(dupl1); "."; TAB(10); name$(dupl1); TAB(43); quan(dupl1); TAB(50); USING "##,###.##"; itmamt(dupl1)
 END IF
NEXT dupl1
PRINT "Estimated Total is"; TAB(46); "Rs."; TAB(50); USING "##,###.##"; medbltot
SYSTEM
END


200 recno = 0
  first = 0
  LOCATE 23, 10
  COLOR 10, 0
  PRINT "Press <Esc> key after entering all the quantity in this screen"
  row = 4
  COLOR 8, 7
  LOCATE 4, 1
  PRINT SPACE$(80)
  LOCATE 4, 1
  PRINT TAB(10); mslno(0); TAB(15); mtype$(0); TAB(20); mname$(0); TAB(70); mquan(0)
  stri$ = ""
  col = 70
  DO WHILE tmp$ <> CHR$(27)
   tmp$ = INKEY$
   res$ = ""
IF (tmp$ > CHR$(47) AND tmp$ < CHR$(58)) THEN
    IF col > 72 THEN
      LOCATE row, 70
      PRINT "   "
      stri$ = ""
      col = 70
    END IF
    stri$ = LTRIM$(stri$) + LTRIM$(tmp$)
    res$ = LTRIM$(stri$)
    COLOR 10, 0
    LOCATE row, col
    PRINT LTRIM$(tmp$)
   col = col + 1
  mquan(recno) = VAL(LTRIM$(res$))
  END IF
 
IF tmp$ = down$ OR tmp$ = return$ THEN
   col = 70
   COLOR 10, 0
   LOCATE row, 1
   PRINT SPACE$(80)
   LOCATE row, 1
   PRINT TAB(10); mslno(recno); TAB(15); mtype$(recno); TAB(20); mname$(recno); TAB(70); mquan(recno)
   row = row + 1
   recno = recno + 1
   IF row > 20 AND mslno(recno) <> 0 THEN
     row = 3
     first = first + 1
     FOR dupl1 = first TO (dupl - 1)
      IF row <= 20 THEN
       row = row + 1
       LOCATE row, 1
       PRINT TAB(10); mslno(dupl1); TAB(15); mtype$(dupl1); TAB(20); mname$(dupl1); TAB(70); mquan(dupl1)
      END IF
     NEXT dupl1
     LOCATE 21, 1
     PRINT SPACE$(80)
     row = 20
   END IF
 
   IF mslno(recno) = 0 THEN
    PLAY "l16o2bcd"
    recno = recno - 1
    row = row - 1
   END IF
   COLOR 8, 7
   LOCATE row, 1
   PRINT SPACE$(80)
   LOCATE row, 1
   PRINT TAB(10); mslno(recno); TAB(15); mtype$(recno); TAB(20); mname$(recno); TAB(70); mquan(recno)
   stri$ = ""
END IF

IF tmp$ = up$ THEN
   col = 70
   COLOR 10, 0
   LOCATE row, 1
   PRINT SPACE$(80)
   LOCATE row, 1
   PRINT TAB(10); mslno(recno); TAB(15); mtype$(recno); TAB(20); mname$(recno); TAB(70); mquan(recno)
   recno = recno - 1
   row = row - 1

   IF recno < 0 THEN
     PLAY "l16o2bcd"
     row = 4
     recno = 0
   ELSE
  
IF row < 4 AND selslno(recno) <> 0 THEN
    row = 3
    first = first - 1
    IF first < 0 THEN first = 0
    FOR dupl1 = first TO (dupl - 1)
     IF row <= 20 THEN
      row = row + 1
      LOCATE row, 1
      PRINT TAB(10); mslno(dupl1); TAB(15); mtype$(dupl1); mname$(dupl1); TAB(70); mquan(dupl1)
     END IF
    NEXT dupl1
    row = 4
    LOCATE 21, 1
    PRINT SPACE$(80)
   END IF
   END IF
 
   COLOR 8, 7
   LOCATE row, 68
   PRINT "       "
   stri$ = ""
   LOCATE row, 1
   PRINT SPACE$(80)
   LOCATE row, 1
   PRINT TAB(10); mslno(recno); TAB(15); mtype$(recno); TAB(20); mname$(recno); TAB(70); mquan(recno)
 END IF
 IF UCASE$(tmp$) > CHR$(64) AND UCASE$(tmp$) < CHR$(91) THEN
 mednam$ = UCASE$(tmp$)
 CLS
 COLOR 10, 0
 FOR dupl1 = 0 TO (dupl - 1)
   IF mquan(dupl1) > 0 THEN
    FOR dupl2 = 0 TO (dupl - 1)
     IF slno(dupl2) = mslno(dupl1) THEN quan(dupl2) = mquan(dupl1)
    NEXT dupl2
   END IF
 NEXT dupl1
GOTO 100
     END IF

LOOP
 FOR dupl1 = 0 TO (dupl - 1)
   IF mquan(dupl1) > 0 THEN
    FOR dupl2 = 0 TO (dupl - 1)
     IF slno(dupl2) = mslno(dupl1) THEN quan(dupl2) = mquan(dupl1)
    NEXT dupl2
   END IF
 NEXT dupl1
RETURN

300 CLS
SYSTEM
RETURN



