//@Name:Capital Employed //@Description:Returns the Capital Employed figures used in calculating ROCE and Capital Turnover //@Returns:Number //@Width:65 //@Env:Production var list2 = ["Most recent","1 year ago","2 years ago","3 years ago","4 years ago","5 years ago","6 years ago","7 years ago","8 years ago","9 years ago","10 years ago"]; var list2t = ["","1y ago ","2y ago ","3y ago ","4y ago ","5y ago ","6y ago ","7y ago ","8y ago ","9y ago ","10y ago "]; var choice2 = 0; var list1 = ["Value","Growth %","Annualised Growth %","Average Value"]; var list1t = ["","%chg","%chg (ann)","avg"]; var choice1 = 0; var list3 = ["1 year","2 years","3 years","4 years","5 years","6 years","7 years","8 years","9 years","10 years"]; var list3t = ["1y","2y","3y","4y","5y","6y","7y","8y","9y","10y"]; var choice3 = 0; function init(status) { if (status == Loading || status == Editing) { choice1 = storage.getAt(0); choice2 = storage.getAt(1); choice3 = storage.getAt(2); } if (status == Adding || status == Editing) { dlg = new Dialog("Capital Employed...",270,70); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDropList("VAL1",110,15,85,-1,list1,"","",choice1); dlg.addDropList("VAL2",45,15,60,-1,list2,"Return the:","",choice2); dlg.addText(6,40,118,20,"Growth %, Annualised Growth %, or Average calculated over:"); dlg.addDropList("VAL3",125,43,60,-1,list3,"","",choice3); if (dlg.show()==Dialog.Cancel) return false; choice1 = dlg.getValue("VAL1"); choice2 = dlg.getValue("VAL2"); choice3 = dlg.getValue("VAL3"); storage.setAt(0, choice1); storage.setAt(1, choice2); storage.setAt(2, choice3); } if(choice1==0) { setTitle (list2t[choice2]+"Cap. Employed"); } else setTitle (list2t[choice2]+"Cap. Employed "+list3t[choice3]+" "+list1t[choice1]); } function getVal(share) { var capEm = []; var capEmSum = 0; var count = 0-choice3-1-choice2; var ebit = []; var roce = []; for (var i = 0, j = 0; i>-50; i--, j++) { ebit[j] = share.getResult(i, Result.NormEBIT); roce[j] = share.getResult(i, Result.ROCE); if(ebit[j]==null) //stop when there's no more data. remove the last element of the arrays. { ebit.length-- roce.length-- break; } } capEm[0] = ebit[ebit.length-1]/roce[ebit.length-1]; for (var i = 1; i