#title=""
#tooltip="Sum (Click OK to copy)",1033,"合計 (OK をクリックしてコピー)",1041,"Součet",1029,"Summe",1031,"Somme",1036,"Suma",3082,"Suma",2058,"Somma",1040,"합계",1042,"Som",1043,"Сумма (Нажмите OK чтобы скопировать)",1049,"合计（单击“确定”复制）",2052,"加總（單擊「確定」複製）",1028
#icon="sum.ico"
// Do not edit this file.  If you want to edit the file, please copy it into another folder.
// This file will be replaced with a newer version every time EmEditor is upgraded.
var sum = 0;
if( document.CellMode || document.Csv.Delimiter.length != 0 ) {
	x1 = document.selection.GetTopPointX( eePosCell );
	y1 = document.selection.GetTopPointY( eePosCell );
	x2 = document.selection.GetBottomPointX( eePosCell );
	y2 = document.selection.GetBottomPointY( eePosCell );
	for( var x = x1; x <= x2; ++x ) {
		for( var y = y1; y <= y2; ++y ) {
			var s = document.GetCell( y, x, eeCellIncludeNone );
			sum += Number( s );
		}
	}
}
else if( !document.selection.IsEmpty ) {
	var a = document.selection.Text.split("\n");
	for( var i = 0; i < a.length; i++ ){
		sum += Number(a[i]);
	}
	bOrgCombine = CombineHistory;
}

if( confirm( sum ) ) {
	clipboardData.setData("Text", sum);  // copy sum to the Clipboard if 'OK' is clicked
}
