// globals



function printout () {
	doPrintout (true);
}

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

function doPrintout (final) {
	x = getValue ("x");
	g = getValue ("g");
	method = '"' + getValue ("method") + '"';
	if (method == "\"jitter\"") {
		opts += ", jitter = " + getValue ("jitter");
		params += ", \"Jitter\" = " + getValue ("jitter");
	} else if (method == "\"stack\"") {
		opts += ", offset = " + getValue ("offset");
		params += ", \"Offset\" = " + getValue ("offset");
	}
	orientation = getValue ("orientation");
	if (orientation == "Vertical") opts += ", vertical = TRUE";
	plot_adds = getValue ("plotoptions.code.calculate"); 

	if (final) { 
echo ('rk.header ("Stripchart", list ("Variable"=rk.get.description (' + x + '), "Group"=rk.get.description (' + g + '), "Method"=' + method + params + ', "Orientation"="' + orientation + '"))\n');
echo ('\n');
echo ('rk.graph.on ()\n');
	} 
echo ('try (stripchart (' + x + ' ~ (' + g + '), method = ' + method + opts + getValue ("plotoptions.code.printout") + '))\n');
	if (!empty (plot_adds)) { 
echo ('\n');
		
		printIndented ("\t", plot_adds);
	}

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

