public String getValue(String varName) throws VariableException {
        String result = null;

        if (gate == null)
            throw new VariableException("cannot get var's value since no gate is currently loaded", varName);

        if (varName.equals(VAR_TIME))
            result = String.valueOf(time) + (clockUp ? "+" : " ");
        else {
            Node node = gate.getNode(varName);
            if (node != null)
                result = String.valueOf(node.get());
            else {
                String gateName = getVarChipName(varName);
                if (gateName != null) {
                    int index = getVarIndex(varName);

                    // try to find if gateName is an internal part with GUI
                    BuiltInGateWithGUI guiChip = getGUIChip(gateName);
                    if (guiChip != null) {
                        try {
                            result = String.valueOf(guiChip.getValueAt(index));
                        } catch (GateException ge) {
                            throw new VariableException(ge.getMessage(), varName);
                        }
                    } else {
						throw new VariableException("No such built-in chip used",
													gateName);
					}
                }

                if (result == null)
                    throw new VariableException("Unknown variable", varName);
            }
        }

        return result;
    }