Created
April 17, 2018 20:28
-
-
Save trycf/ff2f662b5031f823f9c1f1b590d9381c to your computer and use it in GitHub Desktop.
Adobe ColdFusion 2018 Beta - Futures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
getAccountBalance = function(){ | |
var balance = 120000; | |
return balance; | |
} | |
function payCreditCardBill(accountBalance){ | |
var ccBill = 1890; | |
return accountBalance-ccBill; | |
} | |
payEMIs = function(accountBalance){ | |
var mortgageEMI = 1000; | |
var carLeaseEMI = 750; | |
var healthInsuranceEMI = 250; | |
return accountBalance-(mortgageEMI+carLeaseEMI+healthInsuranceEMI); | |
} | |
miscellenousExpenses = function(accountBalance){ | |
var shopping = 1500; | |
var clubExpense =1000; | |
var casinoExpense = 2000; | |
return accountBalance-(shopping+clubExpense+casinoExpense); | |
} | |
checkBalance = function(accountBalance){ | |
while(accountBalance > 5000){ | |
accountBalance = miscellenousExpenses(accountBalance); | |
writeOutput("checkBalance = " & accountBalance & "<br/>"); | |
} | |
if(accountBalance < 5000) | |
throw (message="Account balance below threshold!!!", | |
type="info"); | |
} | |
errorHandler = function(error){ | |
if(error.message contains "Account balance below threshold!"){ | |
return "You have reached your spending limit!"; | |
} | |
} | |
future = runAsync(getAccountBalance) | |
.then(payCreditCardBill) | |
.then(payEMIs) | |
.then(miscellenousExpenses) | |
.then(checkBalance) | |
.error(errorHandler); | |
writeOutput(future.get()); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment