private String useAtomVariables(String s, int frame) {
		if (frame >= model.getTapePointer()) {
			out(ScriptEvent.FAILED, "There is no such frame: " + frame + ". (Total frames: " + model.getTapePointer()
					+ ".)");
			return null;
		}
		int n = model.getAtomCount();
		int lb = s.indexOf("%atom[");
		int rb = s.indexOf("].", lb);
		int lb0 = -1;
		String v;
		int i;
		while (lb != -1 && rb != -1) {
			v = s.substring(lb + 6, rb);
			double x = parseMathExpression(v);
			if (Double.isNaN(x))
				break;
			i = (int) Math.round(x);
			if (i < 0 || i >= n) {
				out(ScriptEvent.FAILED, i + " is an invalid index: must be between 0 and " + (n - 1) + " (inclusive).");
				break;
			}
			v = escapeMetaCharacters(v);
			Atom a = model.atom[i];
			s = replaceAll(s, "%atom\\[" + v + "\\]\\.id", a.getElementNumber());
			s = replaceAll(s, "%atom\\[" + v + "\\]\\.mass", a.mass);
			s = replaceAll(s, "%atom\\[" + v + "\\]\\.charge", a.charge);
			s = replaceAll(s, "%atom\\[" + v + "\\]\\.sigma", a.sigma * 0.1);
			s = replaceAll(s, "%atom\\[" + v + "\\]\\.epsilon", a.epsilon);
			s = replaceAll(s, "%atom\\[" + v + "\\]\\.friction", a.damp);
			// s = replaceAll(s, "%atom\\[" + v + "\\]\\.hx", a.hx);
			// s = replaceAll(s, "%atom\\[" + v + "\\]\\.hy", a.hy);
			if (frame < 0) {
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.rx", a.rx);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.ry", a.ry);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.rz", a.rz);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.vx", a.vx * V_CONVERTER);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.vy", a.vy * V_CONVERTER);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.vz", a.vz * V_CONVERTER);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.ax", a.ax);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.ay", a.ay);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.az", a.az);
			}
			else {
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.rx", a.rQ.getQueue1().getData(frame));
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.ry", a.rQ.getQueue2().getData(frame));
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.rz", a.rQ.getQueue3().getData(frame));
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.vx", a.vQ.getQueue1().getData(frame) * V_CONVERTER);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.vy", a.vQ.getQueue2().getData(frame) * V_CONVERTER);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.vz", a.vQ.getQueue3().getData(frame) * V_CONVERTER);
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.ax", a.aQ.getQueue1().getData(frame));
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.ay", a.aQ.getQueue2().getData(frame));
				s = replaceAll(s, "%atom\\[" + v + "\\]\\.az", a.aQ.getQueue3().getData(frame));
			}
			lb0 = lb;
			lb = s.indexOf("%atom[");
			if (lb0 == lb) // infinite loop
				break;
			rb = s.indexOf("].", lb);
		}
		return s;
	}