DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦7c3e03ab2⟧ TextFile

    Length: 48768 (0xbe80)
    Types: TextFile
    Names: »EXAMPLES.DOC«

Derivation

└─⟦ea621760d⟧ Bits:30005267 dBase II - uoriginal diskette
    └─ ⟦this⟧ »EXAMPLES.DOC« 

TextFile

                  CHECKBOOK BALANCING SYSTEM

This  example illustrates how a dBASE system can be designed  for 
checkbook balancing and check register maintenance.   The program 
helps  automate  the procedure we all experience when we  receive 
the monthly statement from the bank.   This system could be  used 
for personal or business applications.

The  system uses an user defined database file and six associated 
command  files.  The six dBASE command files and their  functions 
are:

     1. XMENU       - System controller.
     2. XNEWENTR    - Enters new checks into user database file.
     3. XDEPOSIT    - Enters  new  deposits  into  user  database 
                      file.
     4. XCANCEL     - Enters cancelled checks into user  database 
                      file.
     5. XDEPCANC    - Enters   cancelled   deposits   into   user 
                      database file.
     6. XBALANCE    - Sums   the  total  outstanding  checks  and 
                      deposits.  Ask for ending balance from bank 
                      statement   and   computes   the    current 
                      checkbook balance.


The following conventions are used in the text that follows.  The 
character  > sigifies the system prompt.   (cr) signifies a  user 
keyboard  carriage  return.  Lower case text enclosed  in  square 
brackets  ÆÅ denotes document explanatory text and is not part of 
any file or run stream and should not be entered into the  user's 
runstream.

Prior  to using the system a user specified database file must be 
available  for  the command files to  access.   In  any  database 
project, one must plan the data fields that will be required. For 
this example, the following fields are selected:           

     NO   - The check number, INTEGER
     TO   - The recipient of the check, CHARACTER
     CAN  - The  cancelled/not-cancelled  status of  a  check  or 
            deposit, LOGICAL.
     DATE - Date when the check was written, CHARACTERS
     MEMO - Code for users accounting files:
               A-Advertising            B-Bank Charges
               C-Car + Truck            D-Dues + Publications
               F-Freight                I-Insurance
               L-Legal Expenses         O-Office Supplies
               P-Postage                R-Rent
               T-Telephone              X-Taxes
.PA


Enter  the  following  to  CREATE  the  database  structure.  The 
database file name is CHECKER.

>DBASE(cr)      Æinitiate the dBASE system to begin processingÅ

 ENTER TODAYS DATE AS MM/DD/YY   OR RETURN FOR NONE : (cr)

 ***   dBASE II   VER 2.xx

 .CREATE(cr)  Ætells dBASE you want to create a fileÅ

FILENAME:CHECKER(cr)    Æasks what you want to name fileÅ
ENTER RECORD STRUCTURE AS FOLLOWS:
 FIELD  NAME,TYPE,WIDTH,DECIMAL PLACES

 001    NO,N,4(cr)      Æfield name is NO with 4 Numeric charsÅ
 002    TO,C,30(cr)     Æfield name is TO with 30 CharactersÅ
 003    AMT,N,10,2(cr)  Æsimilar explanations for rest of fileÅ
 004    CAN,L(cr)
 005    DATE,C,8(cr)
 006    MEMO,C,10(cr)
 007    (cr)

INPUT NOW?:N      Æindicates not going to enter data to file nowÅ

 .QUIT(cr)        Æexit the dBASE systemÅ

 ***   END  RUN   dBASE II     *** ÆdBASE message to userÅ
.pa
The  dBASE  command  files  that are used  to  do  the  checkbook 
processing are listed below.  These were built with a text editor 
(a  word  processor can be used).  The CP/M extension  should  be 
specified.  For dBASE command files,  it is ".CMD".  For example, 
the  first  command file is XMENU,  it is entered into  the  text 
processor as "XMENU.CMD".

Things to especially notice in this example are:

1.  How  the  menu  entries  are distinguished  by  the  DO  CASE 
programming structure.

2.  A  "DO  WHILE  T" is used to repeat  the  menu.  DO  WHILE  T 
essentially  says "DO this segment of commands WHILE the value of 
T  is .TRUE.".  Since T is a literal .TRUE.,  its value is always 
TRUE and the loop will never terminate.  Well almost never, there 
is  a CANCEL command inside the DO WHILE that aborts  the  entire 
command  file.  This is called a "DO FOREVER" in some  structured 
languages.

3.  In  general,  command  files should not be written that  make 
explicit  references to specific database files.  This is avoided 
in  this  example.  The database name is supplied by the user  in 
response to the line 'ACCEPT "Enter check database name" to  DBF' 
and  the  subsequent  'USE &DBF' instead of something  like  'USE 
B:CHECKS'.  This permits this system of command files to be  used 
with any number of seperate checkbook databases.

4.  In  general,  command  files should not be written that  make 
explicit references to specific disk drives.  This is avoided  in 
this  example  by the lines 'ACCEPT "Enter disk drive  containing 
command  files  as  'A:' or 'B:'" to DISK' and  'SET  DEFAULT  TO 
&DISK'. 


NOTE - EXAMPLE dBASE CHECK BALANCER COMMAND FILE PROGRAM
*   
*   
*  - turn off display of commands to screen
SET TALK OFF
*  - enter user database file name
ACCEPT "Enter check database name" to DBF
*  - access database file
USE &DBF
*  - specify disk containing command files
ACCEPT "Enter disk drive containing command files as 'A:' or 'B:'" to DISK
SET DEFAULT TO &DISK
*  - this is text that is displayed on the screen
DO WHILE T
* DO WHILE T  means DO WHILE TRUE  I.E. DO FOREVER
*   The DO WHILE will be terminated by a CANCEL command internally
  ? 
  ? 
  ? 
  ? '     CHECK BOOK BALANCER MENU'
  ? 
  ? '        0 - EXIT'
  ? '        1 - ENTER NEW CHECKS'
  ? '        2 - ENTER DEPOSIT'
  ? '        3 - ENTER CANCELLED CHECKS'
  ? '        4 - ENTER CANCELLED DEPOSITS'
  ? '        5 - BALANCE'
  ? 
  ? ' ENTER DESIRED ACTION'
 *  - reading user response
 WAIT TO ACTION
 DO CASE

  *  - testing to exit
    CASE ACTION='0'
       SET TALK ON
       *  - return to dBASE system
       CANCEL

  *  - test for new checks
    CASE ACTION='1'
       *  - enter new check data
       DO XNEWENTR

  *  - test for new deposits
    CASE ACTION='2'
       *  - enter new deposit data
       DO XDEPOSIT

  *  - test for cancelled checks
    CASE ACTION='3'
       *  - enter cancelled check data
       DO XCANCEL

  *  - test for cancelled deposits
    CASE ACTION='4'
       *  - enter cancelled deposit data
       DO XDEPCANC

  *  - test for balancing check book
    CASE ACTION='5'
       *  - compute ending balance
       DO XBALANCE

  * - non-valid entry to the menu
    OTHERWISE
       ? 'Invalid entry, re-enter'

  ENDCASE

ENDDO
RETURN
.pa

The XNEWENTR command file is analogous to recording the name  and 
amount of the check in our checkbook as we write them.

Notice the '@' commands that "paint" a picture on the screen


NOTE - EXTENDED NEWENTR COMMAND FILE TO ENTER NEW CHECKS
*   
*  - clear screen
ERASE
*  - position to bottom of database file
GO BOTTOM
*  - initialize date
STORE '01/01/81' TO CH:DAT
DO WHILE T
  * initialize memory variables so that READ will have a length to mark
  STORE '                              ' TO CH:TO
  STORE 0.00 TO M:AMT
  STORE ' ' TO CH:MEMO
  STORE NO+1 TO M:NO
  *  - this is text to read check data
  @ 5,0  SAY 'CHECK ENTRY    ENTER CHECK NUMBER OF ZERO TO EXIT'
  @ 6,0  SAY 'IF CHECK NUMBER=0, ENTER CARRIAGE RETURNS FOR OTHER ENTRIES'
  @ 7,0  SAY 'CHECK NUMBER        ' GET M:NO
  @ 8,0  SAY 'PAY TO THE ORDER OF ' GET CH:TO
  @ 9,0  SAY 'AMOUNT OF CHECK     ' GET M:AMT
  @ 10,0 SAY 'DATE WRITTEN        ' GET CH:DAT PICTURE '99/99/99'
  @ 11,0 SAY 'PURPOSE OF CHECK'
  @ 13,0 SAY 'A - ADVERTISING           B - BANK CHARGES      C - CAR + TRUCK'
  @ 14,0 SAY 'D - DUES + PUBLICATIONS   F - FREIGHT           I - INSURANCE'
  @ 15,0 SAY 'L - LEGAL EXPENSES        S - OFFICE SUPPLIES   P - POSTAGE'
  @ 16,0 SAY 'R - RENT                  T - TELEPHONE         X - TAXES'
  @ 18,0 SAY 'ENTER PURPOSE LETTER' GET CH:MEMO
  READ
  IF M:NO=0
    RETURN
  ENDIF
  *  - put blank card into database file
  APPEND BLANK
  *  - put check data into database file
  REPLACE NO WITH M:NO,TO WITH CH:TO,AMT WITH M:AMT;
    DATE WITH CH:DAT,CAN WITH F,MEMO WITH !(CH:MEMO)
ENDDO
.pa

The  XDEPOSIT  command file records the date and  amount  of  any 
deposits to the checkbook.


NOTE - DEPOSIT COMMAND FILE TO ENTER NEW DEPOSITS
*   
REMARK ENTER DEPOSIT AMOUNT OF 0 TO EXIT
*  - initialize date value
STORE '01/01/81' TO C:DAT
DO WHILE T
  ? 
  ? 
  *  - reading deposit entries
  INPUT "Amount of Deposit            " TO C:AMT
  *  - if deposit amount equals 0, exit command file
  IF C:AMT=0
     RETURN
  ENDIF
  STORE C:DAT TO OLD:DATE
  *  - read date of deposit
  ACCEPT "Date of Deposit as MM/DD/YY  " TO C:DAT
  *  - if date is blank, use current date
  IF C:DAT=' '
    STORE OLD:DATE TO C:DAT
  ENDIF
  *  - ask if all fields are correct
  INPUT "ARE ALL FIELDS CORRECT ?      " TO GO:NOGO
  *  - test for correct data
  IF .NOT.GO:NOGO
    LOOP
  ENDIF
  *  - put blank card into database file
  APPEND BLANK
  *  - put deposit data into database structure
  REPLACE NO WITH 0,TO WITH 'DEPOSIT',AMT WITH C:AMT
  REPLACE DATE WITH C:DAT,CAN WITH F
ENDDO
.pa

The  XCANCEL  command  file  is analogous  to  checking  off  the 
canceled checks we receive with the bank statement.



NOTE - CANCELS COMMAND FILE TO ENTER CANCELLED CHECKS
*   
*  - message to be displayed on screen
REMARK ENTER CHECK NUMBER OF 0 TO EXIT
*  - loop while check number not equal to zero
DO WHILE T
  ? 
  INPUT "ENTER CANCELLED CHECK NO" TO C:CAN
  *  - testing for zero check number
  IF C:CAN=0
     RETURN
  ENDIF
  *  - position to top of database file
  GO TOP
  *  - search for cancelled check number
  LOCATE FOR C:CAN=NO
  *  - testing to see if at end of database file
  IF .NOT.EOF
     *  - if not at end of file
     ?
    `*  - display check data
     DISP OFF 'Payed to ',TO,' on ',DATE
     DISP OFF 'Amount of check is ',AMT
     *  - ask if this is right check
    INPUT 'Is this the one? (Y/N)' to ANSWER
     IF ANSWER
        *  - change logical flag for cancelled check
        REPLACE CAN WITH T
     ENDIF
  ELSE
     *  - message to tell user his check is not in file.
     DISP OFF 'Check ',C:CAN,' cannot be found'
  ENDIF
ENDDO
RETURN
.pa

The  XDEPCANC  command  file  enters the  cancelled  deposit  data 
furnished on the bank statement.


note  - DEPOSIT CANCELLATION PROGRAM
*
*  - position to top of database file
GO TOP
DO WHILE T
*  - find first uncancelled deposit
  LOCATE FOR NO=0 .AND. .NOT. CAN NEXT 65000
  *  - if not at end of character field
  IF .NOT.EOF
     ?
     *  - display date and amount of deposit
     * MAKE SURE THIS IS THE THE RIGHT ONE
     DISP OFF 'Deposited on ',DATE,' Amount = ',AMT
     INPUT ' Cancel this one? (Y/N)' TO ANSWER
     *  - ask if deposit is to be cancelled
     IF ANSWER
        *  - change logical flag for cancelled deposit
        REPLACE CAN WITH T
     ENDIF
  ELSE  * END OF FILE
     ?
     *  - tell user there are not more deposits
     ? 'No more uncancelled deposits'
     RETURN
  ENDIF * IF NOT EOF
  ?
  INPUT 'Any more deposits to cancel? (Y/N)' to ANSWER
  IF .NOT. ANSWER
     RETURN
  ENDIF
ENDDO
RETURN
.pa

The  XBALANCE  command file does the final reconciliation of  the 
bank statement with the user checkbook.


NOTE - BALANCE COMMAND FILE TO BALANCE CHECKBOOK
*   
SUM AMT TO OUTSTAND FOR .NOT. CAN .AND. NO>0
SUM AMT TO T:OUT FOR .NOT. CAN .AND. NO=0
?   
?   
*  - display total of outstanding checks
DISP OFF ' TOTAL OUTSTANDING CHECKS    = $',OUTSTAND
?   
*  - display total of outstanding deposits
DISP OFF ' TOTAL OUTSTANDING DEPOSITS  = $'T:OUT
?   
*  - request ending balance form check book
INPUT "ENTER ENDING BALANCE FROM BANK STATEMENT" TO BEGIN
DISP OFF 'CURRENT BALANCE = $',BEGIN+T:OUT-OUTSTAND
WAIT
RETURN
.PA

                   CHECKBOOK REPORTING SYSTEM

This  dBASE  sample illustrates the use of the INDEX  and  REPORT 
commands.   This dBASE system uses the database file generated by 
the  XMENU  check  balancing system  discussed  previously.   The 
system   list  the checks by MEMO type and  their  subtotals  and 
totals.   The  system uses a command file,  a database file and a 
report  form  file.   The files associated with this  system  and 
their names are:

     1. CHREPORT    - System controller.
     2. CHREPORT    - Report forms file generated when the user 
                      uses the REPORT dialog.                     
     3. CHECKER     - Database file generated by XMENU system.     



The data base structure is presumed to have already been created 
for using this system.  A listing of the file structure follows.

 FIELD  NAME,TYPE,WIDTH,DECIMAL PLACES

 001    NO,N,4(cr) Æfield name is NO with 4 Numeric charsÅ
 002    TO,C,30(cr) Æfield name is TO with 30 CharactersÅ
 003    AMT,N,10,2(cr)  Æsimilar explanations for rest of fileÅ
 004    CAN,L(cr)
 005    DATE,C,8(cr)
 006    MEMO,C,10(cr)
 007    (cr)
.pa

A  text  editor is then executed and the following  command  file 
sources with the extention ".CMD" are entered:


The CHREPORT command file:   

NOTE - report on the checks in a database
*  - this dBASE II system uses the database file generated by the
*  - check balancing system initiated by XMENU.  This check report
*  - system reads the XMENU data base and report the subtotals for 
*  - each of the various user memos.
*
* note: uses database with structure same as XMENU
*
? 'THIS PROGRAM IS SET TO RUN ON YOUR PRINTER. IF PRINTER IS NOT READY'
? ' THE PROGRAM MAY HANG UP.'
*  - enter name of database file from XMENU
ACCEPT 'Enter check database name' to DBNAME
*  - assign data base file to this command system
*  - database has name of xxxx.DBF
USE &DBNAME
*  - index on variable MEMO in database file
INDEX ON MEMO TO &DBNAME
*  - enter title to be printed at top of each output page
ACCEPT 'Enter report title (up to 60 chars)' to TITLE
*  - set header to title value
SET HEAD TO &TITLE
*  - generate report form using CHREPORT.FRM 
REPORT FORM CHREPORT FOR NO#0 TO PRINT
RETURN
.pa

The  CHREPORT.FRM file is listed here.  The notations  in  square 
brackets indicate the REPORT prompts being answered.



Y  Æpage heading? (y/n)Å
Checks subtotalled by type  Æenter page heading:Å
n  Ædouble space report? (y/n)Å
y  Æare totals required? (y/n)Å
y  Æsubtotals in report? (y/n)Å
MEMO  Æenter subtotals field:Å
N  Æsummary report only? (y/n)Å
N  Æeject page after subtotals? (y/n)Å
Check type :  Æenter subtotals heading:Å
5,NO  Æwidth, contentsÅ
CHECKNO Æenter headingÅ
N  Æare totals required? (y/n)Å
33,TO  Æwidth, contentsÅ
PAY TO THE ORDER OF  Æenter headingÅ
10,$(DATE,3,2)+'/'+$(DATE,5,2)+'/'+$(DATE,1,2) Æwidth,contentsÅ
DATE;WRITTEN  Æenter headingÅ
12,AMT  Æwidth,contentÅ
>AMOUNT  Æenter headingÅ
Y  Æare totals required? (y/n)Å
.pa

A  sample run using these command files follows.   First the user 
is  presumed  to have "CREATEd" a database file  called  CHECKER.  

>DBASE  Æinitiate the dBASE systemÅ
 
 ENTER TODAYS DATE AS MM/DD/YY  OR RETURN FOR NONE: 11/04/81(cr)

  ***  dBASE II     VER 2.xx

 .DO CHREPORT(cr)  Æinitiate the check report systemÅ
THIS PROGRAM IS SET TO RUN ON YOUR PRINTER. IF THE PRINTER IS NOT READY
THE PROGRAM MAY HANG UP.
Enter check databse name:CHECKER(cr) Æenter name of database fileÅ
Enter report title (up to 60 chars): THIS IS A SAMPLE CASE(cr)
.pa


PAGE NO. 00001        THIS IS A SAMPLE CASE

                         Checks subtotalled by type

CHECK       PAY TO THE ORDER OF              DATE          AMOUNT
  NO                                        WRITTEN

* Check type : A
 1008 PRESSURE ADVERTIZING AGENCY           04/05/80       500.00
** SUBTOTAL **
                                                           500.00

* Check`type : B
 1003 FIRST NATIONAL BANK                   05/07/80        55.10
** SUBTOTAL **
                                                            55.10

* Check type : D
 1005 HARVEY MUDD                           01/01/81       169.34
** SUBTOTAL **
                                                           169.34

* Check type : F
 1004 NEWTON PHYSICS LAB                    01/01/81      1000.00
** SUBTOTAL **
                                                          1000.00

* Check type : I
 1007 PIECES OF ROCK INSURANCE              01/05/81        40.00
** SUBTOTAL **
                                                            40.00

* Check type : L
 1006 SHUSTER LEGAL CLINIC                  01/05/81       333.22
** SUBTOTAL **
                                                           333.22

* Check type : P
 1002 POSTMASTER                            05/05/80        22.41
** SUBTOTAL **
                                                            22.41

* Check Type : R
 1009 SMITH OFFICE RENTAL                   01/25/81       239.56
** SUBTOTAL **
                                                           239.56


.pa



PAGE NO. 00002       THIS IS A SAMPLE CASE

                         Checks subtotalled by type

CHECK        PAY TO THE ORDER OF             DATE          AMOUNT
  NO                                        WRITTEN

* Check type : S
 1001 MITCHELL OFFICE SUPPLY                04/05/80        77.34
** SUBTOTAL **
                                                            77.34

* Check type : X
 1010 GOV MEDFLY STATE TAX BOARD            01/25/81         7.76
** SUBTOTAL **
                                                             7.76

** TOTAL **                                               2444.73


 .QUIT Æleaving dBASE systemÅ
 *** END RUN   dBASE II   ***
.PA
                 SIMPLE ACCOUNTS PAYABLE SYSTEM

This is a check printer system.  This example demonstrates direct 
formatting  of  printer  output  and the  usage  of  PRIMARY  and 
SECONDARY  databases.  This system uses the CHECKS data base file 
generated  by the check balancing system discussed  earlier.  The 
system  accesses a database file called ACCNTS and asks the  user 
if he wants to pay any checks to the accounts in the file.   When 
a  check is paid,   a record of the check is made in  the  CHECKS 
database  file.   The system also allows the user to write checks 
to  accounts  not  in the ACCNTS database.   The  system  uses  a 
command file and two database files.   The files associated  with 
this system and their names are:

     1. ACCNTPAY    - System controller.
     2. ACCNTS      - Database file used to display the accounts
                      to be paid.                               
     3. CHECKS      - Database file generated by check balancing   
                      system.


Prior to using the system,  user specified database files must be 
available  for  the  command files to access.   In  any  database 
project, one should consider what data fields will  be  required.  
For the CHECK file, the following fields were selected:     
    
     NO   - The check number, INTEGER
     TO   - The recipient of the check, CHARACTER
     CAN  - The  cancelled/not-cancelled  status of  a  check  or 
            deposit, LOGICAL.
     DATE - Date when the check was written, CHARACTERS
     MEMO - Code for users accounting files:
               A-Advertising            B-Bank Charges
               C-Car + Truck            D-Dues + Publications
               F-Freight                I-Insurance
               L-Legal Expenses         O-Office Supplies
               P-Postage                R-Rent
               T-Telephone              X-Taxes

The data base structure is presumed to have already been created 
for using this system.  A listing of the file structure follows.

 STRUCTURE FOR FILE:  CHECKS.DBF    
 NUMBER OF RECORDS:   00010
 DATE OF LAST UPDATE: 00/00/00
 PRIMARY USE DATABASE
 FLD     NAME        TYPE     WIDTH    DEC
 001    NO             C        004                       
 002    TO             C        030                      
 003    AMT            N        010     002                
 004    CAN            L        001
 005    DATE           C        008
 006    MEMO           C        010
 ** TOTAL **                  00064
.pa

For the ACCNTS file the following fields were selected:
          PNAME   - Payees name
          AMT     - Amount outstanding in account
          DDATE   - Date account was opened
          LDATE   - Last date a payment was made
          LAMT    - Last amount still owed
          TYPE    - Account memo
          PERIOD  - Payment period
          VARIABLE- Logical flag

The structue of the database file is a follows:

STRUCTURE FOR FILE: ACCNTS.DBF
NUMBER OF RECORDS:  00007
DATE OF LAST UPDATE: 00/00/00
PRIMARY USE DATABASE
FLD       NAME      TYPE WIDTH   DEC
001     PNAME        C    030   
002     AMT          N    010    002
003     DDATE        C    006
004     LDATE        C    006
005     LAMT         N    008    002
006     TYPE         C    010
007     PERIOD       N    001
008     VARIABLE     L    001
** TOTAL **             00073
.pa

A  text  editor is then executed and the following  command  file 
source with the extention "CMD" is  entered:

NOTE - THIS IS THE ACCOUNT PAYING COMMAND FILE
*
*
*  - explanatory text               
? 'THIS PROGRAM USES THE PRINTER. IF YOUR PRINTER IS NOT READY IT'
? ' MAY HANG UP AT THIS POINT. FURTHER DOWN IN THIS FILE'
? ' YOU WILL FIND A SECTION OF CODE TO SET UP AN ANADEX PRINTER FOR'
? ' PRINTING CHECKS. USE YOUR TEXT EDITOR TO MODIFY THIS FOR YOUR'
? ' PRINTER. '   
*  - turn off printing commands to screen
SET TALK OFF
*  - send results of @ statements to printer
SET FORMAT TO PRINT
*  - echo output to printer
SET PRINT ON
*  - turn off console
SET CONSOLE OFF
*  - go to top of page on printer
EJECT
*  - this is the ANADEX 9500 text
* SET`FORM LENGTH TO 22 LINES ON ANADEX 9500
* ESC 4 022
*  - create ASCII string of esc4022
? CHR(27)+CHR(52)+CHR(48)+CHR(50)+CHR(50)
*  - turn off echo
SET PRINT OFF
*  - echo output to console
SET CONSOLE ON
*  - set loop variable true
STORE T TO STAY
*  - request current date
ACCEPT "Enter Today's Date  (YYMMDD)" TO TODAY
*  - ask for beginning check number for this run
INPUT  'Enter Beginning Check No.     ' TO NNO
*  - ask for disk drive with database files
ACCEPT 'Enter Data Disk Drive         ' TO DRV
*  - set system default to database disk drive
SET DEFAULT TO &DRV
USE CHECKS
*  - select primary database file
SELE SECO         
USE ACCNTS
*  - set up program loop
DO WHILE STAY
  *  - select seconary file ACCNTS
  SELECT SECONDARY
?   
?   
  *  - list data from ACCNTS
  LIST PNAME,S.AMT,DDATE
?   
?
?
? '       ENTER OPTION YOU WANT'
? '           -1  - EXIT'
? '            0  - WRITE CHECK TO ACCOUNT NOT IN DATABASE'
? '            N  - NUMBER OF ACCOUNT TO WRITE CHECK FOR'
  *  - ask for account number to print check for
  INPUT 'Which Account' TO ACCNT
  *  - check to see if exit
  IF ACCNT<0
     *   -  set loop variable false to exit program
     STORE F TO STAY
     LOOP
  ENDIF
  *  - check to see if writing check not in ACCNTS
  IF ACCNT=0
     *  - request data for check
     ACCEPT 'Enter Payee  ' TO NAME
     INPUT  'Enter Amount ' TO MAMT
  ELSE
     *  - locate account number in ACCNTS file
     GOTO ACCNT
     *  - store payee name to variable NAME
     STORE PNAME TO NAME
     *  - is check hasn't been canceled
     IF .NOT.VARIABLE
        *  - check to get amount still owed
        STORE S.AMT TO MAMT
        IF TODAY>=LDATE
           STORE S.AMT+LAMT TO MAMT
        ENDIF
     ELSE
        *  - user option on amount to pay this time
        INPUT 'Enter Amount To Pay ' TO MAMT
     ENDIF
     IF PERIOD>0
        IF (VAL($(DDATE,3,2))+PERIOD)>12
           STORE VAL(DDATE)+((88+PERIOD)*100) TO NDATE
        ELSE
           STORE VAL(DDATE)+100*PERIOD TO NDATE
        ENDIF
        REPLACE DDATE WITH STR(NDATE,6)
     ENDIF
  ENDIF
  *  - store variables to be printed on check
  STORE STR(NNO,4) TO XNO
  STORE STR(MAMT,10,2) TO XAMT
  *  - show user on screen proposed check values
  DISP OFF 'Check #',XNO,' Pay ',XAMT,' To ',NAME
  *  - ask if you want to print this check
  ? 'OK? (Y/N)'
  WAIT TO X
  *  - see if check is to be written
  IF X=$('Yy',1,1) .OR. X=$('Yy',2,1)
     *   - select primary file
     SELE PRIMARY
     APPEND BLANK
     *   - put check data into primary file
     REPLACE TO WITH NAME,NO WITH NNO,AMT WITH MAMT,CAN WITH F
     REPLACE DATE WITH TODAY,MEMO WITH TYPE
     STORE NNO+1 TO NNO
* NOW PRINT CHECK ON PRINTER
@ 3,67 SAY 'Check No.'
@ 3,77 SAY XNO
@ 5,67 SAY 'Date:'
@ 5,73 SAY $(TODAY,3,2)+'/'+$(TODAY,5,2)+'/'+$(TODAY,1,2)
@ 10,1 SAY 'Pay to the'
@ 11,1 SAY 'Order of'
@ 11,12 SAY NAME
@ 11,68 SAY MAMT USING '$$,$$$,$$$.99'
@ 17,12 SAY INT(MAMT) USING '$$,$$$,$$$'
@ 1wl23 SAY 'D O L L A R S   and  '
@ 17,44 SAY (MAMT-INT(MAMT))*100 USING '99'
@ 17,47 SAY 'C E N T S'
@ 20,12 SAY 'Type: '
@ 20,18 SAY TYPE
@ 20,41 SAY '----------------------------------------'
EJECT
ENDIF
ENDDO
RETURN
.pa

A  sample  run  using these files follows.   First  the  user  is 
presumed  to have "CREATE"d a database file called CHECKS  and  a 
database file call ACCNTS.

>DBASE  Æinitiate the dBASE systemÅ
 
 ENTER TODAYS DATE AS MM/DD/YY  OR RETURN FOR NONE: 11/04/81(cr)

  ***  dBASE II     VER 2.xx

 .DO ACCNTPAY(cr)  Æinitiate the check report systemÅ
THIS PROGRAM USES THE PRINTER.  IF YOUR PRINTER IS NOT READY IT        
MAY HANG UP AT THIS POINT.  5 LINES FURTHER DOWN IN THIS FILE
YOU WILL FIND A SECTION OF CODE TO SET UP AN ANADEX PRINTER FOR
PRINTING CHECKS.  USE YOU TEXT EDITOR TO MODIFY THIS FOR YOUR
PRINTER.
Enter Today's Date  (YYMMDD):811130(cr)
Enter Beginning Check No.  :1025(cr)
Enter Data Disk Drive      :B:(cr)

0001 SMITH OFICE RENTAL          234.56 800901 
0002 HURTZ BUSINESS CAR LEASING  300.00 800620 
0003 PRESSURE ADVERTIZING AGENCY 500.00 800723 
0004 TIDY LAUNDRY                 40.00 800701 
0005 MUNICIPAL WATER DEPARTMENT   10.00 800705 

     ENTER ACCOUNT OPTION
          -1 - EXIT
           0 - WRITE CHECK TO ACCOUNT NOT IN DATABASE
           N - NUMBER OF ACCOUNT TO WRITE CHECK FOR
Which Account: 1(cr)
Check # 1025 Pay           234.56 to SMITH OFFICE RENTAL
OK? (Y/N)
WAITING Y

0001 SMITH OFFICE RENTAL         234.56 801001
0002 HURTZ BUSINESS CAR LEASING  300.00 800620
0003 PRESSURE ADVERTIZING AGENCY 500.00 800723
0004 TIDY LAUNDRY                 40.00 800701
0005 MUNICIPAL WATER DEPARTMENT   10.00 800705

     ENTER ACCONT OPTON
          -1 - EXIT
           0 - WRITE CHECK TO ACCOUNT NOT IN DATABASE
           N - NUMBER OF ACCOUNT TO WRITE CHECK FOR
Which Account: 0(cr)
Enter Payee: CLIPUM MOTORS
Enter Amount: 123.45
Check #  1026   Pay             123.45 to CLIPUM MOTORS
OK? (Y/N)
WAITING Y

0001 SMITH OFFICE RENTAL         234.56 801001 
0002 HURTZ BUSINESS CAR LEASING  300.00 800620 
0003 PRESSURE ADVERTIZING AGENCY 500.00 800723
0004 TIDY LAUNDRY                 40.00 800701
0005 MUNICIPAL WATER DEPARTMENT   10.00 800705
 
     ENTER ACCOUNT OPTION
          -1 - EXIT
           0 - WRITE CHECK TO ACCOUNT NOT IN DATABASE
           N - NUMBER OF ACCOUNT TO WRITE CHECK FOR
Which Account: -1(cr)
 . QUIT  Æexiting dBASE systemÅ
 ***  END RUN   dBASE   ***
.pa
The following is the printed output from the ACCNTPAY system.



-----------------------------------------------------------------
                                                   Check No. 1025

                                                   Date: 11/30/81


Pay to the 
Order of      SMITH OFFICE RENTAL                  $$$$$$$$234.56





               $$$$$$$$$234 D O L L A R S   and 56 C E N T S



                                       --------------------------

                Type: R

-------mm--------------------------------------------------------


                                                   Check No. 1026
             
                                                  Date:  11/30/81




Pay to the 
Order of      CLIPUM MOTORS                       $$$$$$$$$123.45




              $$$$$$123.45 D O L L A R S  AND 56 C E N T S




                                     ----------------------------

              Type: R

-----------------------------------------------------------------
.PA

                         MAILING SYSTEM

This  example  illustrates  a dBASE II system  for  mailing  list 
generation,  mail  label printing or form letter  printing.   The 
system  does not have provisions for modifying the mailing  list.  
The  user can change entries in the mailing list using the  dBASE 
II commands DELETE and/or EDIT.   This system illustrates the use 
of format files, text files and the SET ALTERNATE command.

The  system uses a user defined mailing list database file,  five 
command  files,  a  dBASE II format file and generates  and  text 
file.  The files and their functions are:

     1. MAIL.DBF         - Database file containing mailing list
     2. MAIL.CMD         - System controller.
     3. MAILENTR.CMD     - Enters names and addresses to mailing
                           list file MAIL.DBF
     4. MAILLAB.CMD      - Prints mailing labes from mailing 
                           list file MAIL.DBF
     5. MAILLTTR.CMD     - Generates form letter to be printed.
     6. MAILINFO.CMD     - Contains text of form letter to be 
                           printed.
     7. MAILFMT.FMT      - Format file for reading in name and
                           address data in MAILENTR.CMD
     8. PRINT.TXT        - Output file containing form letters.
                           

Prior  to  using the system a mailing list database file must  be 
available  for  the  command  files  to  access.   The  following 
variable names are accessed by the system presented here.

          TITLE     - Title code of person, Mr, Mrs, etc.
          NAME      - Name of person in mailing list.
          OF        - Name of addressee's company.
          ADDR      - Address of person and/or company.
          CITY      - City of residence.
          STATE     - Postal abbreviation of state.
          ZIP       - Zip code.

.pa
Enter   the  following  to  CREATE  the  mailing  list   database 
structure. The database file name is MAIL.

>DBASE(cr)  Æinitiate the dBASE system to begin processingÅ

 ENTER TODAYS DATE AS MM/DD/YY  OR RETURN  FOR NONE : (cr)

 ***    dBASE II   VER 2.xx

 .CREATE

 FILENAME:MAIL(cr)  Æasks what you want to name the fileÅ
 ENTER RECORD STRUCTURE AS FOLLOWS:
  FIELD   NAME,TYPE,WIDTH,DECIMAL PLACES

  001     TITLE,N,1
  002     NAME,C,30
  003     OF,C,30
  004     ADDR,C,30
  005     CITY,C,20
  006     STATE,C,2
  007     ZIP,C,6
  008     (cr)
 INPUT NOW?:N Æindicates not going to enter data to file nowÅ
 . QUIT  Æleaving dBASE system for now
 ***  END   RUN   dBASE II    ***  ÆdBASE message to userÅ


A  text  editor is then executed and the follwoing  command  file 
sources with the extention "CMD" are entered:

First the MAIL commmand file:


NOTE Example dBASE Command file program
*
*  - this is a sample form letter generator and mailing label 
*  - dBASE II system.  The system allows the user to add new 
*  - entries to a mailing list, print the mailing list on gummed
*  - labels or print a form letter addressed to all the people 
*  - in the mailing list.  No provision is made to modify the 
*  - mailing list.  The user can use the dBASE commands EDIT and/or
*  - DELETE to modify the database file MAIL.DBF to change the 
*  - mailing list.
*
*  - turn off display of commands to screen
SET TALK OFF
*  - assign database file to command stream.
USE MAIL
*  - enter current date to print on form letter
ACCEPT 'Enter date as mm/dd/yy' TO DATE
*  - select system option
DO WHILE T
   ?
   ?
   ?
   ? '          Form Letter Writing System'
   ?
   ?
   ? '          0 - EXIT'
   ? '          1 - Enter new entries'
   ? '          2 - Make Labels'
   ? '          3 - Write Letters'
   ?
   ? ' enter desired action'
   *  - wait for user response
   WAIT TO ACTION
   *  - test for exit 
   IF ACTION='0'
      SET TALK on
      CANCEL
   ENDIF
   *  - test for new entries
   IF ACTION='1' 
      *  - add new names to MAIL.DBF
      DO MAILENTR
   ENDIF
   *  - test to make labels
   IF ACTION='2'
      *  - print mail labels
      DO MAILLAB
   ENDIF
   *   - test to write form letters
   IF ACTION='3'
      *  - print form letter to names in MAIL.DBF
      DO MAILLTTR
   ENDIF
ENDDO
RETURN
.pa  


The  MAILENTR  command file add names to the MAIL.DBF file  using 
the MAILFMT.FMT format file.

NOTE - MAIL SYSTEM NAME AND ADDRESS ENTRY PROGRAM
*
*  - move pointer to bottom of MAIL.DBF
GO BOTTOM
*  - send output of @ commands to MAILFMT.FMT
SET FORMAT TO MAILFMT
*  - read name and address data 
DO WHILE T
  *  - initialize address variables to blank
  STORE ' ' TO MTTL
  STORE '  ' TO MSTATE
  STORE '      ' TO MZIP
  STORE '            ' TO MSNAM,MCITY
  STORE '                    ' TO MGNAME
  STORE '                              ' TO MOF,MADDR
  *  - read format file
  READ
  *  - check to see if ready to exit this command file
  IF MTTL=' '
    RETURN
  ENDIF
  *  - combine first and last name and store 
  STORE MSNAM+MGNAME TO MNAME
  *  - add blank card to MAIL.DBF
  APPEND BLANK
  *  - store name and address data to MAIL.DBF
  *  - substitute input variables for database file variables
  REPLACE TITLE WITH &MTTL,NAME WITH MNAME,OF WITH MOF,ADDR WITH MADDR
  REPLACE CITY WITH MCITY,STATE WITH !(MSTATE),ZIP WITH MZIP
ENDDO
RETURN
.pa
The format file MAILFMT follows:

This file reads the mail list input data
@ 1,1  SAY '    1 = "Mr."'
@ 2,1  SAY '    2 = "Mrs."'
@ 3,1  SAY '    3 = "Ms."'
@ 4,1  SAY '    4 = "Dr."'
@ 5,1  SAY ' BLANK to exit entry program'
@ 6,1  SAY ' After BLANK, enter carriage return for entries'
Æenter title codeÅ
@ 7,1  SAY 'Enter title code     ' GET MTTL
Æenter surnameÅ
@ 8,1  SAY 'Enter Surname        ' GET MSNAM
Æenter given and middle namesÅ
@ 9,1  SAY 'Enter other names    ' GET MGNAME
Æenter company nameÅ
@ 10,1 SAY 'Enter Co. name       ' GET MOF
Æenter street addressÅ
@ 11,1 SAY 'Enter Address        ' GET MADDR
Æenter city nameÅ
@ 12,1 SAY 'Enter City           ' GET MCITY
Æenter two letter postal abbreviation for state nameÅ
@ 13,1 SAY 'Enter State          ' GET MSTATE
Æenter zip code numberÅ
@ 14,1 SAY 'Enter ZIP code       ' GET MZIP
.pa

The  MAILLAB command file print the mailing list onto the  system 
printer.  The text of the file follows:

NOTE - THIS COMMAND FILE PRINTS MAILING LABELS ON THE PRINTER
*
REMARK WHEN LABELS ARE IN PLACE, HIT CARRIAGE RETURN
WAIT
*  - echo printed information to screen
SET PRINT ON
*  - position to top of MAIL.DBF
GO TOP
*  - print labels
DO WHILE .NOT.EOF
   *  - print name
   DISP OFF $(NAME,13,17)-(' '+$(NAME,1,12))
   *  - checking to see if office address
   IF OF#'  '
     *  - print office name   
     DISP OFF OF
     *  - print address
     DISP OFF ADDR
     *  - print city, state, zip
     DISP OFF $(CITY,1,20)-(', '+$(STATE,1,2))-(' '+$(ZIP,1,5))
   ELSE
     *  - print home address
     DISP OFF ADDR
     *  - print city, state, zip
     DISP OFF $(CITY,1,20)-(', '+$(STATE,1,2))-(' '+$(ZIP,1,5))
     ?
   ENDIF
   ?
  SKIP
ENDDO
*  - turn off echo of labels
SET PRINT OFF
REMARK ALL DONE
RETURN
.pa

The  MAILLTTR  command  file generates the form  letter  for  the 
system.  The text of the file follows.

NOTE - THIS COMMAND FILE WRITES THE FORM LETTER
*
*  - position pointer at top of MAIL.DBF
GO TOP
*  - sets up to store everything that appears on the screen into
*  - a file called PRINT.TXT which the user can later list using
*  - his work processor.
SET ALTERNATE TO PRINT
SET ALTERNATE ON
* PUT PRINT FORMATTER SETUP DIRECTIVES HERE, SUCH AS PAGE NUMBERING,
* PRINTER PITCH, PAGE OFFSET, LINE HEIGHT, AND FOOTNOTES 
* EXAMPLE:
* ? '.OFFSET = 8'
* ? '.CHARACTER WIDTH = 12/INCH'
* etc.
*  - print letter
DO WHILE .NOT.EOF
? '                                                      Your Company'
? '                                                      8080 Micro St.'
? '                                                      Silicon, CA 93002'
? '                                                      (213) 555-1234'
? '                                                      '+DATE
*  - print name and address of client
? $(NAME,13,18)-(' '+$(NAME,1,12))
IF OF#'  '
 ? OF
ENDIF
? ADDR
IF VAL(ZIP)=0
  ? CITY-(', '+STATE)
ELSE
  ? CITY-(', '+STATE)-(' '+ZIP)
ENDIF
?
?
*  - print salutation
IF TITLE=1
  ? 'Dear Mr. '+$(NAME,1,12)
ENDIF
IF TITLE=2
  ? 'Dear Mrs. '+$(NAME,1,12)
ENDIF
IF TITLE=3
  ? 'Dear Ms. '+$(NAME,1,12)
ENDIF
IF TITLE=4
` ? 'Dear Dr. '+$(NAME,1,12)
ENDIF
?
*  - print text of letter
DO MAILINFO
*
* PUT A WORD PROCESSOR COMMAND TO SKIP TO THE NEXT PAGE HERE
* EXAMPLE
* ? '.SKIP'
*  - this is a WordStar (tm) page skip
? '.pa'
SKIP 
ENDDO
SET ALTERNATE OFF
RETURN

.pa

The MAILINFO command file accessed by this file contains the text 
of the form letter.  A sample MAILINFO file follows.


NOTE - THIS IS THE TEXT FOR THE USER FORM LETTER
*
*  - the text presented here describes how to generate the 
*  - letter.  The user will put in own text.
? 'This  is  the body of a form letter.  It was first written with  a  word'
? 'processor and then modified to become a command file.  The modifications'
? 'are:  placement  of  question  marks at the beginning of each  line  and' 
? 'enclosing  the text in single quotes or square brackets.  In  this  way,' 
? 'each  line of text is written to the ALTERNATE file by means of the  SET' 
? 'ALTERNATE commands in MAILLTTR.CMD (which calls this command file).'
?
? 'The text of the letter can be altered based on the database data fields.'
? 'For instance,  if the content of the letter should change for  different' 
? 'states,  then  this condition can be checked and the appropriate  action' 
? 'can be taken.'
?
?
? '                                              Yours truly'
?
?
?
?
? '                                              Mike R. O. Chip'
?
? 'Example:'
?
IF STATE='CA'
  ? 'California residents add 6% sales tax'
ENDIF
RETURN
.pa


A  sample run using these command files follows.   First the user 
is  presumed to have "CREATE"d a database file called MAIL  using 
the commands presented in the database discussion.

>DBASE(cr)  Æinitiate the dBASE systemÅ

 ENTER TODAYS DATE AS MM/DD/YY  OR RETURN FOR NONE : (cr)

 ***  dBASE II      VER 2.xx

 .MAIL  Æinitiate mailing list systemÅ
 Enter date as mm/dd/yy:11/29/81(cr)

               Form Letter Writing System


               0 - EXIT
               1 - Enter new entries
               2 - Make Labels
               3 - Write Letters

 enter desired action
WAITING 1  Æentering names to mailing listÅ


     1 = "Mr."
     2 = "Mrs."
     3 = "Ms."
     4 = "Dr."
  BLANK to exit entry program
  After BLANK, enter carriage return for entries
Enter title code         :1:
Enter Surname            :Jones(cr)     :
Enter other names        :John J.(cr)                  :
Enter Co. name           :Micro Enterprises(cr)      :
Enter Address            :1234 Chip Road(cr)           :
Enter City               :Silicon(cr):
Enter State              :CA:
Enter ZIP code           :90002(cr):




     1 = "Mr."
     2 = "Mrs."
     3 = "Ms."
     4 = "Dr."
  BLANK to exit entry program
  After BLANK, enter carriage return for entries
Enter title code         :1:
Enter Surname            :Brown(cr)     :
Enter other names        :Thomas(cr)                  :
Enter Co. name           :(cr)                         :
Enter Address            :1234 West Winchester Dr.(cr) :
Enter City               :Boston(cr):
Enter State              :CA:
Enter ZIP code           :10024(cr):


     1 = "Mr."
     2 = "Mrs."
     3 = "Ms."
     4 = "Dr."
  BLANK to exit entry program
  After BLANK, enter carriage return for entries
Enter title code         :2:
Enter Surname            :Franklin(cr) :
Enter other names        :Josephine(cr)                :
Enter Co. name           :(cr)                         :
Enter Address            :12 Country Club Dr.(cr)     :
Enter City               :Chino(cr):
Enter State              :CA:
Enter ZIP code           :9l710(cr):


     1 = "Mr."
     2 = "Mrs."
     3 = "Ms."
     4 = "Dr."
  BLANK to exit entry program
  After BLANK, enter carriage return for entries
Enter title code         : :Æexiting this command fileÅ
Enter Surname            :(cr)         :
Enter other names        :(cr)                         :
Enter Co. name           :(cr)                         :
Enter Address            :(cr)                         :
Enter City               :(cr)     :
Enter State              :(cr):
Enter ZIP code           :(cr)   :



               Form Letter Writing System


               0 - EXIT
               1 - Enter new entries
               2 - Make Labels
               3 - Write Letters

 enter desired action
WAITING 2  Æprinting mailing labelsÅ
 WHEN LABELS ARE IN PLACE, HIT CARRIAGE RETURN
WAITING (cr)
John J. Jones
Micro Enterprises
1234 Chip Road
Silicon, CA 90002

Thomas Brown
1234 West Winchester Dr.
Boston, MA 10024

Josephine Franklin
12 Country Club Dr.
Chino, CA 9l710

               Form Letter Writing System


               0 - EXIT
               1 - Enter new entries
               2 - Make Labels
               3 - Write Letters

 enter desired action
WAITING 3   Æwriting form lettersÅ

               Form Letter Writing System


               0 - EXIT
               1 - Enter new entries
               2 - Make Labels
               3 - Write Letters

 Enter desired action
WAITING 0  Æexiting MAIL systemÅ
DO CANCELLED
 . QUIT  Æexit from dBASE processorÅ
 ***  END RUN    dBASE II   ***


At  the  end of processing the form letters are in a file  called 
PRINT.TXT.   The  user needs to print this file using his  system 
word processor.  When the printing is completed, he should delete 
the  TXT  file  from his disk.   A sample form  letter  for  this 
version of the MAIL system follows:
.pa


                                             Your Company
                                             8080 Micro St.
                                             Silicon, CA 93002
                                             (213) 555-1234
                                             11/29/81
Josephine Franklin
12 Country Club Dr.     
Chino, CA 9l710 


Dear Mrs. Franklin

This  is the body of a form letter.   It was first written with  a  word 
processor and then modified to become a command file.  The modifications 
are:  placement  of  question  marks at the beginning of each  line  and 
enclosing  the text in single quotes or square brackets.   In this  way, 
each  line of text is written to the ALTERNATE file by means of the  SET 
ALTERNATE commands in MAILLTTR.CMD (which call this command file).

The text of the letter can be altered based on the database data fields. 
For instance,  if the content of the letter should change for  different 
states, then this codition can be checked and the appropriate action can 
be taken.

                                             Yours truly



                                             Mike R. O. Chip

Example:  

California Residents add 6% sales tax

.PA

                     DATE MANAGEMENT SYSTEM

The following example demonstrates the capability to use dBASE to 
perform computations without using a database file.  This program 
allows  the listing of dates that are a specified number of  days 
apart,  such  as treatment dates at a hospital or payroll  dates. 
The  system  consists of three command files.   The  three  dBASE 
command files and their functions are:

     1. DATER       - System controller
     2. CALJUL      - Computes pseudo-Julian date from user input
                      calendar date.
     3. JULCAL      - Computes calendar date from pseudo-Julian
                      date.




First the DATER command file:

NOTE - DRIVER program for date calculation
*
*   - turn off display of commands to screen
SET TALK OFF
*  - ask user for start date
DO CALJUL
INPUT 'Enter interval in days between dates' TO DELTA
?
?
INPUT 'Enter number of times you want interval' TO TOT
* - initialize counter
INPUT 'Do you want output to printer? (Y/N)' TO ANSWER
STORE 1 TO CNT
IF ANSWER
  SET PRINT ON
  ? '   START DATE = '
  ?? DATE
  SET PRINT OFF
ELSE
  ? '   START DATE = '
  ?? DATE
ENDIF
DO WHILE CNT<=TOT
   *  - increment date
   STORE X+DELTA TO X
   DO JULCAL
   STORE 1+CNT TO CNT
LOOP
ENDDO
.pa

The  CALJUL  command file calculates the pseudo-Julian  day  date 
from the user input calendar date.

NOTE - PSEUDO-JULIAN DAY COMMAND FILE PROGRAM
*  - ask user for start date
ACCEPT 'ENTER DATE AS MM/DD/YY' TO DATE
*  - strip off month from date
STORE VAL($(DATE,1,2)) TO M                                          
*  - strip off day from date
STORE VAL($(DATE,4,2)) TO D
*  - strip off year from date
STORE VAL($(DATE,7,2))+1900 TO Y
*  - calculate integer julian date
STORE INT(30.57*M)+INT(365.25*Y-395.25)+D TO X
*  - perform leap year calculation
IF M>2
  IF INT(Y/4)=Y/4
    STORE X-1 TO X
  ELSE
    STORE X-2 TO X
  ENDIF
ENDIF
RETURN
.pa

The  JULCAL  command  file computes the calendar  date  from  the 
pseudo-Julian day date.


NOTE - CALCULATE CALENDAR DATE FROM PSEUDO-JULIAN DATE
*
*  - strip off year
STORE INT(X/365.26)+1 TO Y
*  - strip off day
STORE X+INT(395.25-365.25*Y) TO D
*  - do leap year adjustment
IF INT(Y/4)*4=Y
  STORE 1 TO D1
ELSE
  STORE 2 TO D1
ENDIF
IF D>(91-D1)
  STORE D+D1 TO D
ENDIF
*  - do month computation
STORE INT(D/30.57) TO M
STORE D-INT(30.57*M) TO D
IF M>12
 STORE 1 TO M
 STORE Y+1 TO Y
ENDIF
STORE Y-1900 TO Y
*  - create output format for date
STORE STR(M,2)+'/'+STR(D,2)+'/'+STR(Y,2) TO DATE
IF ANSWER
   SET PRINT ON
ENDIF
? 'CALENDAR DATE ='
?? DATE
IF ANSWER
   SET PRINT OFF
ENDIF
RETURN
.pa

A  sample run using the command files follows.   This case is  to 
compute  the payroll date for a company that pays every two weeks 
starting on New Years day  1981.


>DBASE  Æinitiate the dBASE systemÅ

 ENTER TODAYS DATE AS MM/DD/YY  OR RETURN FOR NONE : (cr)

  ***    dBASE II     VER 2.xx

 .DO DATER(cr)
ENTER DATE AS MM/DD/YY:01/01/81(cr)  Ærequest for start dateÅ
 Enter interval in days between dates:14(cr)  Ætwo weeksÅ



 Enter number of times you want interval:26(cr) Æ# of weeks/yrÅ
 Do you want output to printer? (Y/N):Y(cr)
    START DATE = 01/01/81
 CALENDAR DATE = 1/15/81
 CALENDAR DATE = 1/29/81
 CALENDAR DATE = 2/12/81
 CALENDAR DATE = 2/26/81
 CALENDAR DATE = 3/12/81
 CALENDAR DATE = 3/26/81
 CALENDAR DATE = 4/ 9/81
 CALENDAR DATE = 4/23/81
 CALENDAR DATE = 5/ 7/81
 CALENDAR DATE = 5/21/81
 CALENDAR DATE = 6/ 4/81
 CALENDAR DATE = 6/18/81
 CALENDAR DATE = 7/ 2/81
 CALENDAR DATE = 7/16/81
 CALENDAR DATE = 7/30/81
 CALENDAR DATE = 8/13/81
 CALENDAR DATE = 8/27/81
 CALENDAR DATE = 9/10/81
 CALENDAR DATE = 9/24/81
 CALENDAR DATE =10/ 8/81
 CALENDAR DATE =10/22/81
 CALENDAR DATE =11/ 5/81
 CALENDAR DATE =11/19/81
 CALENDAR DATE =12/ 3/81
 CALENDAR DATE =12/17/81
 CALENDAR DATE =12/31/81
 . QUIT
 *** END RUN   dBASE II   ***
«eof»