
/*
Objective(s) -
-	This code introduces the concept of User Defined Functions with a basic Simple
	Interest Calculation code
*/
[#Menu: Gateway of Tally]

	Add	: Item	: Before : @@locQuit	: Simple Interest Calculator		: Alter	: Simple Interest Calculator
    	  
[Report: Simple Interest Calculator]

	Form	: Interest Calc
	Auto	: Yes

[Form: Interest Calc]

	Parts	: Form SubTitle, Interest Calc
	Local	: Field	: Form SubTitle		: Info		: "Simple Interest Calculator"   ;; locally set report title
	Width	: 30% Page                ;;; Setting form width to 30% page

[Part: Interest Calc]

	Lines	: Interest Principal, Interest Rate, Interest NoOfYrs, Interest Result

	[Line: Interest Principal]

		Fields	: Medium Prompt, Interest Principal
		Local	: Field	: Medium Prompt	: Info		: "Principal Amount :"

		[Field: Interest Principal]

			Use			: Amount Field

	[Line: Interest Rate]

		Fields	: Medium Prompt, Interest Rate
		Local	: Field	: Medium Prompt	: Info		: "Rate :"

		[Field: Interest Rate]

			Use		: Number Field
			Format		: "No Zero, Percentage"
			Align		: Right
		    	Width 	        : @@AmountWidth

	[Line: Interest NoOfYrs]

		Fields	: Medium Prompt, Interest NoOfYrs
		Local	: Field	: Medium Prompt	: Info		: "Tenure :"

		[Field: Interest NoOfYrs]

			Use		: Number Field
			Format		: "NoZero"
			Align		: Right
		    	Width 	        : @@AmountWidth

	[Line: Interest Result]

		Fields	: Medium Prompt, Interest Result
		Local	: Field	: Medium Prompt		: Info		: "Simple Interest Amount :"
		Local	: Field	: Default			: Inactive	: $$IsEmpty:#InterestPrincipal OR $$IsEmpty:#InterestRate OR $$IsEmpty:#InterestNoOfYrs
		SpaceTop: 1

		[Field: Interest Result]

			Use		: Amount Field
			Set Always	: Yes
			Set As		: $$SICalc:#InterestPrincipal:#InterestRate:#InterestNoOfYrs    ;;;User defined function is called with three parameter

;; Function to calculate Simple Interest

[Function: SI Calc]

;; Definition Block

	Parameter	: P			: Amount
	Parameter	: R			: Number
	Parameter	: T			: Number
    
;;Return type of the function is amount

	Returns		: Amount

;;Defining variable

	Variable	: Interest	: Amount

;; Procedural Block

	01 : SET	: Interest	: (##P * ##R * ##T) / 100
	02 : RETURN	: ##Interest

;; End-of-File
