//@Name:Special Div Count //@Description:Looks at the special dividends paid since the chosen date and returns either the number or the total value. //@Env:Production //@Width:60 // Care has been taken in preparing this code but it is provided without guarantee. // You are welcome to modify and extend it. Please add your name as a modifier if you distribute it. //Coded by: Richard Chiesa, ShareScript Support var fromDate = new Date(2013,0,1); var outputList = ["Number","Total Value"]; var outputType = 0; function init(status) { if (status == Loading || status == Editing) { fromDate = new Date(dateNumGetYear(storage.getAt(0)),dateNumGetMonth(storage.getAt(0)),dateNumGetDay(storage.getAt(0))); outputType = storage.getAt(1); } if (status == Adding || status == Editing) { dlg = new Dialog("Special Dividends", 185, 55); dlg.addOkButton(); dlg.addCancelButton(); dlg.addDatePicker("DP1",30,-1,-1,-1, "Since", "", fromDate); dlg.addDropList("DL1",30,-1,50,-1,outputList,"Output","",outputType); if (dlg.show()==Dialog.Cancel) return false; fromDate = dlg.getValue("DP1"); outputType = dlg.getValue("DL1"); storage.setAt(0, dateNum(fromDate)); storage.setAt(1, outputType); } setTitle("Special Div "+outputList[outputType]+" since "+dateToString(fromDate)); } function getVal(share) { var divType = []; var divDate = []; var divValue = []; var counter = 0; var totValue = 0; for (var i=-20;i<=1;i++) { divType = divType.concat(share.getResultArray(i,Result.Type)) divDate = divDate.concat(share.getResultArray(i,Result.ExDivDate)) divValue = divValue.concat(share.getResultArray(i,Result.Dividend)) } for (var i=0;i