* "DBGMINIT.cmd         KRP        7/1/84" *************************************
SET escape OFF
SET talk OFF
STORE t TO start
DO WHILE start
 STORE '99,99,99' TO begin
 ERASE
 @ 10,1 SAY "Enter todays date" GET begin PICTURE "99/99/99" 
 READ
 IF $(begin,1,2)< '01' .OR. $(begin,1,2)> '12' .OR. $(begin,4,2)< '01' .OR. ;
  $(begin,4,2)> '31' .OR. $(begin,7,2)< '00' .OR. $(begin,7,1)> '99' 
  @ 12,1 SAY "Year must 1-99, Month 1-12, Day 1-31" 
  WAIT
 ELSE
  SET DATE TO &begin
  STORE f TO start
 ENDIF $(begin,1,2)< '01' .OR. $(begin,1,2)> ' 1
ENDDO WHILE start
RELEASE begin,start
STORE 'B' TO drive
STORE t TO ever
DO WHILE ever
 USE
 STORE ' ' TO usefile
 SET DEFAULT TO &drive
 ERASE
 RESET
 ? "The following files are on drive: &drive" 
 DISPLAY files
 ? "Enter the file you want to use include .dbf" 
 ACCEPT 'Carriage return to change drives.' TO usefile
 IF usefile= ' ' 
  STORE f TO more
  ACCEPT "Enter new drive letter" TO drive
  STORE !(drive) TO drive
 ELSE
  IF FILE( '&usefile' ) 
   USE &usefile
   GOTO BOTTOM
   STORE str(#,5) TO lastrec
   RESET
   STORE t TO more
   STORE "#>0" TO qualifier
   STORE "NONE" TO indexpr
  ELSE
   STORE f TO more
  ENDIF FILE( '&usefile' )= 'T' 
 ENDIF usefile= ' ' 
 DO WHILE more
  set default to &drive
  USE &usefile
  GOTO BOTTOM
  STORE str(#,5) TO lastrec
  IF indexpr# 'NONE' 
   USE &usefile INDEX &INDEX
  ENDIF indext= 'Y' 
  ERASE
  ? "The default drive is &drive" 
  ? 'The File you are using is &usefile' 
  ? 'Index = &indexpr' 
  ? "Qualifier =" ,qualifier
  ? "This file has &lastrec records." 
  ?
  ? " A.  Add new data to file." 
  ? " E.  Edit data in file." 
  ? " C.  enter a dbase Command." 
  ? " Q.  Quit using dbase." 
  ? " U.  Use another database." 
  ? " R.  Run programs available on disk." 
  ? " S.  Search database & change qualifier." 
  ? " D.  Display records or mailing labels." 
  ? " I.  Index the data base." 
  ?
  ACCEPT "Enter your choice" TO choice
  DO CASE
   CASE !(choice)= 'A' 
    DO WHILE !(CHOICE)='A'
     ERASE
     ? "Do you want information from previous record" 
     ? "carryed over for entry of current record?" 
     ? "i.e. 'Name' from record 1 shows in 'name' field" 
     ACCEPT "while entering record 2. (Y)es (N)o." TO yescarry
     IF !(yescarry)= 'Y' 
      SET carry ON
     ENDIF !(yescarry)= 'Y' 
     ERASE
     ? "Carriage return in first field to quit entrys." 
     WAIT
     APPEND
     ERASE
     GOTO BOTTOM
     store # to place
     STORE 'R' to choice
     DO WHILE !(choice)='R' .or. !(choice)='B'
      ACCEPT "(R)eview,(B)rowse <-type of edit,(A)dd,e(X)it " to choice
      If !(choice)='R'
       goto place
       SKIP -10
       store # to place
       display next 11
      endif
      IF !(choice)='B'
       ? "Hold <ctrl> key down and push 'W' to end."
       wait
       Browse
      ENDIF 
     ENDDO WHILE !(choice)='R'    
     SET carry OFF
    ENDDO
    RELEASE place
   CASE !(choice)= 'E' 
    ERASE
    ? "To end editing current record:" 
    ? "Hold <ctrl> key down and press 'W' key." 
    ? "To end all editing:"
    ? "carriage return at 'ENTER RECORD #:'" 
    WAIT
    EDIT
   CASE !(choice)= 'C' 
    STORE 'a' TO command 
    DO WHILE command# ' ' 
     ? "You are now entering the realm of dbaseII." 
     ACCEPT "Enter command" TO command 
     IF command# ' ' 
      &command
     ENDIF command# ' ' 
    ENDDO WHILE command# ' ' 
   CASE !(choice)= 'Q' 
    STORE f TO more
    STORE f TO ever
    QUIT
   CASE !(choice)= 'U' 
    STORE f TO more
   CASE !(choice)= 'R' 
    SAVE TO temp
    ERASE
    ? "The drive you are using is drive &drive" 
    ? "The file you are using is &usefile." 
    ? "Index = &indexpr" 
    ?
    ? "The programs available on this disk are:" 
    LIST files LIKE *.cmd
    ?
    ? "What program do you want to run" 
    ACCEPT "include '.cmd'" TO program
    IF FILE( '&program' ) 
     DO &program
    ELSE
     ?
     ? "Program not found." 
     WAIT
    ENDIF FILE( '&program' )= 'T' 
    RELEASE ALL
    RESTORE FROM temp
    ****************************************************************************
   CASE !(choice)= 'S' 
    * find.cmd krp 08/22/83
    STORE 'Y' TO morefind
    DO WHILE !(morefind)= 'Y' 
     STORE ' ' TO clause2,clause3,clause4,clause5,conect
     STORE ' ' TO low1,low2,low3,low4,low5,high1,high2,high3,high4,high5
     STORE ' ' TO FIELD1,FIELD2,FIELD3,FIELD4,FIELD5,QUALTEST
     ERASE
     DISPLAY STRUCTURE
     STORE 1 TO clause
     DO WHILE clause<6 .AND. LEN(QUALTEST)<100
      IF clause>1
       STORE ".and." TO conect
      ENDIF clause>1
      STORE str(clause,1) TO numo
      ACCEPT "Enter field &numo to be searched" TO fieldchs
      IF fieldchs# ' ' 
       IF type(&fieldchs)= 'N' 
        ACCEPT "Enter lower limit of search" TO low&numo
        ACCEPT "Enter upper limit of search" TO high&numo
        STORE " &conect &fieldchs>=&low&numo .and. &fieldchs<=&high&numo" TO ;
        clause&numo
       ELSE
        IF type(&fieldchs)= 'C' 
         ACCEPT "Do you want to do a substring search? (Y)es (N)o" TO yesno
         IF !(yesno)= 'Y' 
          ACCEPT "Enter substring" TO low&numo
          STORE !(low&numo) TO low&numo
          STORE ' ' TO high&numo
          STORE " &conect '&low&numo'$!(&fieldchs)" TO clause&numo
         ELSE
          ACCEPT "Enter lower limit of search" TO low&numo
          ACCEPT "Enter upper limit of search" TO high&numo
          STORE !(low&numo) TO low&numo
          STORE !(high&numo) TO high&numo
          STORE " &conect !(&fieldchs)>='&low&numo'"+;
          " .AND. !(&fieldchs)<='&high&numo' " TO clause&numo
         ENDIF !(yesno)= 'Y' 
        ELSE
         STORE " " TO high&numo
         ACCEPT "Is value to be (T)rue or (F)alse" TO low&numo
         IF !(low&numo)= 'T' 
          STORE " &conect &fieldchs" TO clause&numo
         ELSE
          STORE " &conect .not. &fieldchs " TO clause&numo
         ENDIF !(lowlimit)= 'T' 
        ENDIF type(&fieldchs)= 'C' 
       ENDIF type(&fieldchs)= 'N' 
       STORE $(CLAUSE&NUMO,LEN(CONECT)+2,LEN(CLAUSE&NUMO)) TO TESTQUAL
       IF test(&testQUAL)=1
        STORE clause + 1 TO clause
        STORE fieldchs TO FIELD&numo
        STORE QUALTEST+CLAUSE&NUMO TO QUALTEST
       ELSE
        STORE ' ' TO high&numo,low&numo,clause&numo
       ENDIF test(&testclause)=1
      ELSE
       STORE 6 TO clause
      ENDIF fieldchs= ' ' 
     ENDDO WHILE clause<6
     IF FIELD1# ' ' 
      STORE QUALTEST TO qualifier
      ?
      ACCEPT "Do you want to (L)ist or (C)ount" TO typechs
      STORE "9X3l1" TO totfield
      DO WHILE totfield= '9X3l1' 
       ACCEPT "Enter field to be totaled or return" TO totfield
       IF totfield# ' ' 
        IF type(&totfield)= 'L' .OR. test(type(&totfield))=0 
         STORE '9X3l1' TO totfield
        ENDIF type(&totfield)# 'N' .AND. type(&totfiel
       ENDIF totfield# ' ' 
      ENDDO WHILE totfield= '9X3l1' 
      ACCEPT "Enter title if wanted" TO memotitl
      ACCEPT "Do you want hard copy (Y)es (N)o" TO yesprint
      IF !(yesprint)= 'Y' 
       ? "Set up printer (carriage return when done)" 
       WAIT
       SET PRINT ON
       ? chr(15)
      ENDIF !(yesprint)= 'Y' 
      ERASE
      ?
      ? "Database is &usefile , it has &lastrec records." 
      ? "Index = &indexpr" 
      ? "Date of report is " ,DATE()
      ? memotitl
      ? "Field=" ,!(FIELD1), " Low=" ,low1, " High=" ,high1
      ? "Qualifier 1 =" ,!(FIELD2), " Low=" ,low2, " High=" ,high2
      ? "Qualifier 2 =" ,!(FIELD3), "Low=" ,low3, "High=" ,high3
      ? "Qualifier 3 =" ,!(FIELD4), "Low=" ,low4, "High=" ,high4
      ? "Qualifier 4 =" ,!(FIELD5), "Low=" ,low5, "High=" ,high5
      ? "Field Totaled=" ,!(totfield)
      @ 15,1 SAY "Is the above request correct (Y)es (N)o ?" 
      SET console OFF
      SET PRINT OFF
      WAIT TO getit
      IF !(yesprint)= 'Y' 
       SET PRINT ON
      ENDIF !(yesprint)= 'Y' 
      SET console ON
      IF !(getit)= 'Y' 
       IF totfield> ' ' 
        @ 20,1 SAY "Field is now being totaled. " 
        IF type(&totfield)= 'N' 
         SUM &totfield TO fldtaly FOR &qualifier
        ELSE 
         SUM val(&totfield) TO fldtaly FOR &qualifier
        ENDIF type(&totfield)= 'N' 
        ?? "Total=" ,fldtaly
       ENDIF totfield> ' ' 
       @ 20,1 SAY "Request is being processed" 
       IF !(typechs)= "L" 
        ? "Listing for above qualifications:" 
        IF !(yesprint)= 'Y' 
         LIST FOR &qualifier
         ?
        ELSE
         DISPLAY ALL FOR &qualifier
        ENDIF !(yesprint)= 'Y' 
       ELSE
        COUNT FOR &qualifier TO tally
        ? "Count=" ,tally
        ?
       ENDIF !(typechs)= "L" 
      ENDIF !(getit)= 'Y' 
     ENDIF FIELD1# ' ' 
     SET PRINT OFF
     ?
     ACCEPT "More ? (Y/N)" TO morefind
     RELEASE tally,gofind,fieldcls,qualcls,lowlimit,uprlimit,totfield,conect
     RELEASE FIELD1,low1,high1,clause1,FIELD2,low2,high2,clause2,NUMO,YESPRINT
     RELEASE FIELD3,low3,high3,clause3,FIELD4,low4,high4,clause4,MEMOTITL
     RELEASE FIELD5,low5,high5,clause5,QUALTEST,FIELDCHS,YESNO,TESTQUAL,FLDTALLY
    ENDDO WHILE morefind
    RELEASE morefind,clause,typechs,getit,testclause
    ****************************************************************************
   CASE !(choice)= 'D' 
    * show.cmd krp 083083, all purpose display program
    ERASE
    ACCEPT "(R)eport or (M)ail label? " TO typeshow
    ACCEPT "Do you want hard copy (Y)es (N)o ? " TO printr
    ? qualifier
    ACCEPT "Do you want to use the above qualifier(Y/N)" TO yesqual
    IF !(yesqual)# 'Y' 
     STORE '#>0' TO qualifier
    ENDIF !(yesqual)# 'Y' 
    STORE ' ' TO line1,line2,line3,line4,line5,line6
    STORE 1 TO line
    DISPLAY STRUCTURE
    DO WHILE line<7
     STORE str(line,1) TO linert
     STORE 1 TO coter
     DO WHILE coter<10
      STORE str(coter,1) TO conter
      ACCEPT "Enter field &conter , line &linert,<cr> to change line." TO fieldacc
      IF fieldacc= ' ' 
       STORE 10 TO coter
      ELSE
       IF test(type(&fieldacc))=1
        IF type(&fieldacc)= 'C' .AND. !(typeshow)= 'M' 
         STORE "Trim(&fieldacc)" TO fieldacc
        ENDIF type(&fieldacc)= 'C' .AND. !(typeshow)=
        IF conter= '1' 
         STORE fieldacc TO line&linert
        ELSE
         STORE line&linert+ ',' +fieldacc TO line&linert
        ENDIF conter= '1' 
        STORE coter+1 TO coter
       ENDIF test(type(&testclause))=1
      ENDIF fieldacc= ' ' 
     ENDDO WHILE coter<10
     IF fieldacc= ' ' .AND. conter= '1' 
      STORE 8 TO line
     ENDIF fieldacc= ' ' .AND. conter= '1' 
     STORE line+1 TO line
    ENDDO WHILE line<7
    STORE t TO nogood
    DO WHILE nogood
     IF !(printr)= 'Y' 
      ? "Please load labels or paper at this time." 
      ? "Labels are standard 1 inch high by 1 across." 
      WAIT
      SET PRINT ON
      ?? chr(15) 
     ENDIF !(printr)= 'Y' 
     ? line1
     ? line2
     ? line3
     ? line4
     ? line5
     ? line6
     GOTO TOP
     ? &line1
     ? &line2
     ? &line3
     ? &line4
     ? &line5
     ? &line6
     SET PRINT OFF
     ? "Check the above example to be certain of" 
     ? "proper label alignment on your printer." 
     ? "and/or that these are the proper fields" 
     ACCEPT "and order. Answer (Y)es (N)o. " TO answer
     IF !(answer)= 'N' 
      ? "Realign print labels if necessary." 
      ? "If it looks really botched on the screen or" 
      ? "printer you may want to kill the request." 
      ACCEPT "Do you want to stop entire request (Y)es (N)o. " TO ans2
      IF !(ans2)= 'Y' 
       STORE f TO nogood
       STORE f TO dispshow
      ENDIF !(ans2)= 'Y' 
     ELSE
      STORE f TO nogood
      STORE t TO dispshow
     ENDIF !(answer)= 'N' 
    ENDDO WHILE nogood
    IF !(printr)= 'Y' 
     SET PRINT ON
    ENDIF !(printr)= 'Y' 
    DO WHILE .not. eof .AND. dispshow
     IF &qualifier
      IF line1# ' ' .OR. !(typeshow)= 'M' 
       ? &line1
      ENDIF line1# ' ' .OR. !(typeshow)= 'M' 
      IF line2# ' ' .OR. !(typeshow)= 'M' 
       ? &line2
      ENDIF line2# ' ' .OR. !(typeshow)= 'M' 
      IF line3# ' ' .OR. !(typeshow)= 'M' 
       ? &line3
      ENDIF line3# ' ' .OR. !(typeshow)= 'M' 
      IF line4# ' ' .OR. !(typeshow)= 'M' 
       ? &line4
      ENDIF line4# ' ' .OR. !(typeshow)= 'M' 
      IF line5# ' ' .OR. !(typeshow)= 'M' 
       ? &line5
      ENDIF line5# ' ' .OR. !(typeshow)= 'M' 
      IF line6# ' ' .OR. !(typeshow)= 'M' 
       ? &line6
      ENDIF line6# ' ' .OR. !(typeshow)= 'M' 
      SKIP
     ELSE
      SKIP
     ENDIF &bigqual
    ENDDO WHILE .not. eof .AND. dispshow
    ?
    SET PRINT OFF
    WAIT
    RELEASE line1,line2,line3,line4,line5,line6,YESQUAL
    RELEASE typeshow,fieldacc,coter,conter,line,linert
    RELEASE printr,dispshow,dofind,ans2,answer,nogood
    ****************************************************************************
   CASE !(choice)= 'I' 
    * index.cmd krp 10/24/83
    STORE ' ' TO clause2,clause3,clause4,clause5,conect
    ACCEPT "Do you want to use a previously created index (Y/N)" TO yesindex
    IF !(yesindex)# 'Y' 
     ERASE
     DISPLAY STRUCTURE
     STORE 1 TO clause
     DO WHILE clause<6
      IF clause>1
       STORE "+" TO conect
      ENDIF clause>1
      STORE str(clause,1) TO numo
      ACCEPT "Enter field &numo to be indexed on" TO fieldchs
      IF fieldchs# ' ' 
       IF test(type(&fieldchs))=1
        IF type(&fieldchs)= 'N' 
         STORE " &conect str(&fieldchs,20,10) " TO clause&numo
         store clause+1 to clause
        endif
        IF type(&fieldchs)= 'C' 
         STORE " &conect !(&fieldchs) " TO clause&numo
         store clause+1 to clause
        endif
       ENDIF 
      ELSE
       STORE 6 TO clause
      ENDIF fieldchs= ' ' 
     ENDDO WHILE clause<6
     IF clause1# '         ' 
      STORE 'Y' TO indext
      STORE "&clause1 &clause2 &clause3 &clause4 &clause5" TO indexpr
      INDEX ON &clause1 &clause2 &clause3 &clause4 &clause5 TO a:indexer
      STORE "a:indexer" TO INDEX
     ENDIF clause1# ' ' 
     RELEASE tally,gofind,fieldcls,qualcls,lowlimit,uprlimit,totfield,conect
     RELEASE FIELD1,low1,high1,clause1,FIELD2,low2,high2,clause2
     RELEASE FIELD3,low3,high3,clause3,FIELD4,low4,high4,clause4
     RELEASE FIELD5,low5,high5,clause5
     RELEASE morefind
    ELSE 
     ACCEPT "Enter index to use" TO indexpr 
     IF FILE( "&indexpr" )
      STORE indexpr TO INDEX
     ELSE
      STORE "NONE" TO indexpr
     ENDIF FILE( "&indexpr" ) 
     RELEASE yesindex
    ENDIF !(yesindex)# 'Y' 
    ****************************************************************************
  ENDCASE 
 ENDDO WHILE more 
ENDDO WHILE ever 
SET talk ON
SET escape ON
RELEASE ever,more
***************************
  ENDCASE 
 ENDDO WHILE more 
ENDDO WHILE ever 
SET talk ON
SET escape