DataBasic Reference > Programming in DataBasic > Programming Examples > Profits Program Example

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

RealityV15.1Online Documentation (MoTW) Revision 7

Profits Program Example (DataBasic) (m618705+profits.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

Profits Program Example

This program prints a profits report.  A SELECT must be performed before running this program.

EQU AM TO CHAR(254), VM TO CHAR(253)
BUDGET = 0; REV.BUDGET = 
!
* Input from file
* Total attributes 5, 7, and 23 
!
OPEN 'PROJ' ELSE
    PRINT "CANT OPEN PROJ"; STOP
END
!
READ TOT.PRC FROM 'TOT.PRC' ELSE
    PRINT "CANT READ TOT.PRC"; STOP
END
!
READ REV.TOT.PRC FROM "REV.TOT.PRC" ELSE
    PRINT "CANT READ REV.TOT.PRC"
    STOP
END
!
READ NUM.UNITS FROM 'NUM.UNITS' ELSE
    PRINT "CANT READ NUM.UNITS"; STOP
END
!
LOOP WHILE READNEXT ID DO
    IF LEN(ID) # 7 THEN PRINT
       "I.D. NOT 7 CHARACTERS"; STOP
    END
    READ ITEM FROM ID ELSE
       PRINT "CANT READ ":ID; STOP
    END
    BUDGET = BUDGET + ITEM<5>
    IF ITEM<7> > 0 THEN
       REV.BUDGET = REV.BUDGET + ITEM<7>
    END
    REV.BUDGET = REV.BUDGET + : SUMMATION(ITEM<23>)
REPEAT
!
* Convert to dollars and compute budget
* totals
!
BUDGET = BUDGET/100
REV.BUDGET = REV.BUDGET/100
TOT.PRC = TOT.PRC/100
REV.TOT.PRC=REV.TOT.PRC/100
OVER.UNDER = BUDGET - REV.BUDGET
TOT.PRC.O.U = TOT.PRC-REV.TOT.PRC
!
* Compute profits 
!
PROJ.PROF = TOT.PRC-BUDGET
REV.PROJ.PROF = REV.TOT.PRC-REV.BUDGET
PROJ.PROF.O.U.= PROJ.PROF-REV.PROJ.PROF
!
* Compute per/unit profits and percentages 
!
PU1 = PROJ.PROF/NUM.UNITS
PU2 = REV.PROJ.PROF/NUM.UNITS
PU3 = PROJ.PROF.O.U./NUM.UNITS
P1 = PROJ.PROF/(TOT.PRC/100)
P2 = REV.PROJ.PROF/(REV.TOT.PRC/100)
!
* Print
!
FMT = 'R2,#14'
PRINT
PRINT "                           BUDGET REV-BUDGET":
PRINT " OVER/UNDER"
PRINT " TOTAL SALES PRICE ":TOT.PRC FMT:... 
     REV.TOT.PRC FMT:TOT.PRC.O.U FMT
PRINT " TOTAL COST ":BUDGET FMT:REV.BUDGET FMT:O.U FMT
PRINT " PROJECTED PROFIT ":PROJ.PROF FMT:...
     REV.PROJ.PROF FMT:PROJ.PROF.O.U FMT
PRINT " PER UNIT ":PU1 FMT:PU2 FMT:PU2 FMT
PRINT " AS % OF SALES ":P1 FMT:P2 FMT
END

RealityV15.1 (MoTW) Revision 7Comment on this topic