private String evaluateCountFunction(final String clause) {
		if (clause == null || clause.equals(""))
			return null;
		int i = clause.indexOf("(");
		int j = clause.lastIndexOf(")");
		if (i == -1 || j == -1) {
			out(ScriptEvent.FAILED, "function must be enclosed within parenthesis: " + clause);
			return null;
		}
		String s = clause.substring(i + 1, j);
		String[] t = s.split(",");
		int n = t.length;
		switch (n) {
		case 1:
			try {
				i = Integer.parseInt(t[0]);
			} catch (NumberFormatException e) {
				out(ScriptEvent.FAILED, t[0] + " cannot be parsed as an integer.");
				return null;
			}
			return "" + model.getParticleCount((byte) i, null);
		case 2:
			float[] x = parseArray(2, t);
			if (x != null) {
				x[1] *= IR_CONVERTER;
				return "" + model.getParticleCountWithin((int) x[0], x[1]);
			}
			break;
		case 5:
			x = parseArray(5, t);
			if (x != null) {
				for (int k = 1; k < 5; k++)
					x[k] *= IR_CONVERTER;
				Shape shape = new Rectangle2D.Float(x[1], x[2], x[3], x[4]);
				return "" + model.getParticleCount((byte) x[0], shape);
			}
			break;
		case 7:
			x = parseArray(7, t);
			if (x != null) {
				for (int k = 1; k < 7; k++)
					x[k] *= IR_CONVERTER;
				Shape shape = new Triangle(x[1], x[2], x[3], x[4], x[5], x[6]).getShape();
				return "" + model.getParticleCount((byte) x[0], shape);
			}
			break;
		case 4:
			x = parseArray(4, t);
			if (x != null) {
				for (int k = 1; k < 4; k++)
					x[k] *= IR_CONVERTER;
				Shape shape = new Ellipse2D.Float(x[1] - x[3], x[2] - x[3], x[3] * 2, x[3] * 2);
				return "" + model.getParticleCount((byte) x[0], shape);
			}
			break;
		default:
			out(ScriptEvent.FAILED, "argument error: " + clause);
			return null;
		}
		return null;
	}