// 使用方法:首先在一个空文本文件总写上需要做和的数字,每个数一行,选中所有数字,然后运行本脚本 var lineTerminator = "\r\n"; var str = UltraEdit.activeDocument.selection; var resultArr = new Array(); resultArr = str.split(lineTerminator); var itemCnt = resultArr.length; var total = 0; for (var i = 0; i < itemCnt; i++) { total = total+parseFloat(resultArr[i]); } UltraEdit.activeDocument.bottom(); UltraEdit.activeDocument.write("\r\n======================\r\n"); UltraEdit.activeDocument.write("Total value is: " + total + " Yuan.\r\n"); UltraEdit.activeDocument.write("Totally "+itemCnt+" items in the list."); //UltraEdit.outputWindow.write("Total value is: " + total + " Yuan."); //UltraEdit.outputWindow.write("Totally "+itemCnt+" items in the list.");