private String useEllipseVariables(String s) {
		int n = view.getNumberOfInstances(EllipseComponent.class);
		if (n <= 0)
			return s;
		int lb = s.indexOf("%ellipse[");
		int rb = s.indexOf("].", lb);
		int lb0 = -1;
		String v;
		int i;
		EllipseComponent ellipse;
		while (lb != -1 && rb != -1) {
			v = s.substring(lb + 9, rb);
			double x = parseMathExpression(v);
			if (Double.isNaN(x))
				break;
			i = (int) Math.round(x);
			if (i < 0 || i >= n) {
				out(ScriptEvent.FAILED, "Ellipse " + i + " does not exist.");
				break;
			}
			v = escapeMetaCharacters(v);
			ellipse = view.getEllipse(i);
			s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.x", ellipse.getX() * R_CONVERTER);
			s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.y", ellipse.getY() * R_CONVERTER);
			s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.width", ellipse.getWidth() * R_CONVERTER);
			s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.height", ellipse.getHeight() * R_CONVERTER);
			s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.angle", ellipse.getAngle());
			s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.particlecount", ellipse.getParticleCount());
			VectorField vf = ellipse.getVectorField();
			if (vf instanceof ElectricField)
				s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.efield", vf.getIntensity());
			else if (vf instanceof MagneticField)
				s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.bfield", vf.getIntensity());
			else {
				s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.efield", 0);
				s = replaceAll(s, "%ellipse\\[" + v + "\\]\\.bfield", 0);
			}
			lb0 = lb;
			lb = s.indexOf("%ellipse[");
			if (lb0 == lb) // infinite loop
				break;
			rb = s.indexOf("].", lb);
		}
		return s;
	}