Skip to content

Instantly share code, notes, and snippets.

@trycf
Created April 17, 2018 20:28
Show Gist options
  • Save trycf/ff2f662b5031f823f9c1f1b590d9381c to your computer and use it in GitHub Desktop.
Save trycf/ff2f662b5031f823f9c1f1b590d9381c to your computer and use it in GitHub Desktop.
Adobe ColdFusion 2018 Beta - Futures
<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