if (NON_EMPTY_SELECTION)
{
	count = Columns (SELECTED_CHART_DATA);

	colMin  = SELECTED_CHART_DATA [0];
	colMax  = SELECTED_CHART_DATA [0];

	for (counter=0; counter < count; counter = counter+1)
	{
		term = SELECTED_CHART_DATA [counter];
		if (term<colMin)
		{
			colMin = term;
		}
		else
		{
			if (term>colMax)
			{
				colMax = term;
			}
		}
	}

	fprintf (stdout, "\nMin Value (data min = ", colMin,") = ");
	fscanf  (stdin, "Number", colMin);

	term = colMin-1;
	while (term<=colMin)
	{
		fprintf (stdout, "\nMax Value (data max = ", colMax,") = ");
		fscanf  (stdin, "Number", term);
	}
	colMax = term;

	numberOfBins = 0;

	if (colMin==colMax)
	{
		numberOfBins = 1;
	}
	else
	{
		while (numberOfBins<1)
		{
			fprintf (stdout, "\nNumber of bins = ");
			fscanf	(stdin, "Number", numberOfBins);
		}
	}

	matrixOfCounts = {numberOfBins, 5};

	colMax = (colMax-colMin)/numberOfBins;

	if (colMax==0)
	{
		colMax = 0;
	}

	for (counter=0; counter < count; counter = counter+1)
	{
		term = Min(((SELECTED_CHART_DATA [counter]-colMin)/colMax)$1,numberOfBins-1);
		matrixOfCounts [term][2] = matrixOfCounts [term][2]+1;
	}
	
	term = 0;

	for (counter=0; counter < numberOfBins; counter = counter+1)
	{
		matrixOfCounts [counter][0] = colMin;
		term2 = matrixOfCounts [counter][2]/count;
		matrixOfCounts [counter][3] = term2;
		term = term+term2;
		matrixOfCounts [counter][4] = term;
		colMin = colMin + colMax;
		matrixOfCounts [counter][1] = colMin;
	}

	labelMatrix = {{"Bin Left Bound","Bin Right Bound", "Raw Count", "Bin Weight", "Cumulative Weight"}};
	promptString = "Data Histogram";
	OpenWindow (CHARTWINDOW,{{promptString}
							   {"labelMatrix"},
							   {"matrixOfCounts"},
							   {"Bar Chart"},
							   {labelMatrix[0]},
							   {labelMatrix[3]},
							   {"Value"},
							   {""},
							   {"Weight"},
								{"0"}
								{""}
								{"-1;-1"}
								{"10;1.309;0.785398"}
								{"Times:12:0;Times:10:0;Times:12:2"}
								{"0;0;16777215;1644825;0;0;6579300;11842740;13158600;14474460;0;3947580;16777215;5000268;6845928;16771158;2984993;9199669;7018159;1460610;16748822;11184810;14173291"}
								{"16,0,0"}
								},
							   "(SCREEN_WIDTH-60)/2;(SCREEN_HEIGHT-50)/2;(SCREEN_WIDTH-60)/2;50");
}
else
{
	NON_EMPTY_SELECTION = -1;
}

