home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
viscobv6.zip
/
vac22os2
/
ibmcobol
/
samples
/
loan
/
loan.cbv
next >
Wrap
Text File
|
1998-03-02
|
8KB
|
184 lines
* Feature source code generation begins here...
* METHOD
IDENTIFICATION DIVISION.
METHOD-ID. "figureLoan".
DATA DIVISION.
WORKING-STORAGE SECTION.
* --------------------------------------------
* Data declarations for the message box
* --------------------------------------------
01 MessageTitle.
03 MessageTitle-Length PIC 9(9) COMP-5.
03 MessageTitle-String.
05 MessageTitle-Chars PIC X
OCCURS 1 TO 255 TIMES
DEPENDING ON MessageTitle-Length.
01 MsgText.
03 MsgText-Length PIC 9(9) COMP-5.
03 MsgText-String.
05 MsgText-Chars PIC X
OCCURS 1 TO 255 TIMES
DEPENDING ON MsgText-Length.
01 MsgSeverityIcon PIC 9(9) COMP-5 VALUE 2.
88 MsgSeverityIcon-None VALUE 1.
88 MsgSeverityIcon-Information VALUE 2.
88 MsgSeverityIcon-Query VALUE 3.
88 MsgSeverityIcon-Warning VALUE 4.
88 MsgSeverityIcon-Error VALUE 5.
01 MsgButtons PIC 9(9) COMP-5 VALUE 1.
88 MsgButtons-Ok VALUE 1.
88 MsgButtons-OkCancel VALUE 2.
88 MsgButtons-Cancel VALUE 3.
88 MsgButtons-Enter VALUE 4.
88 MsgButtons-EnterCancel VALUE 5.
88 MsgButtons-RetryCancel VALUE 6.
88 MsgButtons-AbortRetryIgnore VALUE 7.
88 MsgButtons-YesNo VALUE 8.
88 MsgButtons-YesNoCancel VALUE 9.
01 MsgDefaultButton PIC 9(9) COMP-5 VALUE 1.
88 MsgDefaultButton-Button1 VALUE 1.
88 MsgDefaultButton-Button2 VALUE 2.
88 MsgDefaultButton-Button3 VALUE 3.
01 MsgModality PIC 9(9) COMP-5 VALUE 1.
88 MsgModality-Application VALUE 1.
88 MsgModality-System VALUE 2.
01 MsgMoveable PIC 9(9) COMP-5 VALUE 0.
88 MsgMoveable-False VALUE 0.
88 MsgMoveable-True VALUE 1.
01 MsgHelpId PIC 9(9) COMP-5 VALUE 0.
01 MsgResponse PIC 9(9) COMP-5.
88 MsgResponse-OK VALUE 1.
88 MsgResponse-Cancel VALUE 2.
88 MsgResponse-Retry VALUE 4.
88 MsgResponse-Abort VALUE 8.
88 MsgResponse-Ignore VALUE 16.
88 MsgResponse-Yes VALUE 32.
88 MsgResponse-No VALUE 64.
88 MsgResponse-Enter VALUE 128.
01 errorCodeRc PIC 9(9) COMP-5.
LOCAL-STORAGE SECTION.
* --------------------------------------------
* Data declarations
* Note that the year data has the DATE FORMAT.
* A temporaty 4-digit date is used to accept
* the two-digit year; Year-Due is a numeric
* used to hold the date for use by the user-
* interface. A numeric is needed to display
* in the window.
* --------------------------------------------
01 The-Date DATE FORMAT YYXXXX.
05 Year-Part PIC 99 DATE FORMAT YY.
05 Month-Part PIC 99.
05 Day-Part PIC 99.
01 Temp-Year PIC 9(4) DATE FORMAT YYYY.
01 Year-Due PIC 9(4).
01 Rate pic 9(9)V99.
01 Month-Rate pic 9(9)V9999.
01 LPayment pic 9(9)V99.
01 num-of-payments pic 9(3).
01 Total-Interest Pic 9(9)V99.
* --------------------------------------------
* A reference to the visual part.
01 aLoan USAGE OBJECT REFERENCE loan.
* --------------------------------------------
LINKAGE SECTION.
01 lsLoanAmt PIC 9(9) COMP-5.
01 lsRate PIC 9(9) COMP-5.
01 lsTerm PIC 9(9) COMP-5.
PROCEDURE DIVISION USING lsLoanAmt lsRate lsTerm.
* Enter your code here..........
* --------------------------------------------
* Initiaze the error return code.
* --------------------------------------------
Initialize errorCodeRc.
* --------------------------------------------
* Check the values and catch a potential problem.
* If a value is not valid, set the return
* code; in the Composition edito, connect the
* errorOccured event to a message window part
* to display an error message for this condition.
* --------------------------------------------
If lsLoanAmt is < 0 or
lsRate is < 1 or
lsRate is > 25 or
lsTerm is < 1 or
lsTerm is > 30
Then
Move 37 to errorCodeRc
Move 0 to LPayment
Total-Interest
Year-Due
Move 22 to MessageTitle-Length
Move "Oh, no ... an Error !!" to MessageTitle-String
* inserted by code assistant
INVOKE InterfaceManager "setMessageTitle"
USING CMessageBox2
MessageTitle
* end of inserted code
Move 82 TO MsgText-Length
Move "An error occurred in figuring the loan. Check that
- "the loan information is valid."
To MsgText-String
Move 4 to MsgSeverityIcon
Move 130 TO MsgHelpId
Invoke InterfaceManager "showMessage"
Using CMessageBox2
MsgText
MsgSeverityIcon
MsgButtons
MsgDefaultButton
MsgModality
MsgMoveable
MsgHelpId
Returning MsgResponse
End-If.
* --------------------------------------------
* Check the return code and if it is zero, compute
* the loan data.
* --------------------------------------------
If errorCodeRc is = 0
Move lsRate to Rate
Compute Rate = Rate / 100
Compute num-of-payments = 12 * lsTerm
Compute LPayment =
lsLoanAmt *
function Annuity ((Rate / 12) Num-of-payments)
Compute Total-Interest = LPayment * Num-of-payments
Subtract lsLoanAmt from Total-Interest
*----------------------------------------------
* Compute the year the loan is due using a two-digit
* year; a temporary date data item hold the four-digit
* value and is used to set the four-digit numeric for
* use in the data part. The MLE Undate function converts
* the data item to a numeric.
*----------------------------------------------
Accept The-Date from Date
Add lsTerm to Year-Part
Move Year-Part to Temp-Year
Compute Year-Due = Function Undate(Temp-Year)
End-If.
* --------------------------------------------
* Set the computed values in the data part.
* --------------------------------------------
Invoke Loandata2 "setPayment"
Using LPayment
Invoke Loandata2 "setTotalInterest"
UsinG Total-Interest
Invoke Loandata2 "setDueYear"
Using Year-Due.
* --------------------------------------------
GOBACK.
END METHOD "figureLoan".
* Feature source code generation ends here.