// globals



function printout () {
	doPrintout (true);
}

function preview () {
	preprocess ();
	calculate ();
	doPrintout (false);
}

function doPrintout (final) {
	x = getValue ("xvarslot");
	y = getValue ("yvarslot");
	if (!(y == "")) {
		y = ", " + y;
	}
	
	plot_adds = getValue ("plotoptions.code.calculate");

	if (final) {

echo ('rk.header ("Generic Plot")\n');
echo ('rk.graph.on ()\n');
	}

echo ('try({\n');
echo ('	plot(' + x + y + getValue ("plotoptions.code.printout") + ');\n');
	if (!empty (plot_adds)) { 
echo ('\n');
		
		printIndented ("\t", plot_adds);
	}

echo ('})\n');
	if (final) {

echo ('rk.graph.off ()\n');
	}
}

