private void doOutputCommand(Command command) throws ControllerException, VariableException {
        if (output == null)
            throw new ControllerException("No output file specified");

        StringBuffer line = new StringBuffer("|");

        for (int i = 0; i < varList.length; i++) {
            // find value string (convert to require format if necessary)
            String value = simulator.getValue(varList[i].varName);
            if (varList[i].format != VariableFormat.STRING_FORMAT) {
                int numValue;
                try {
                    numValue = Integer.parseInt(value);
                } catch (NumberFormatException nfe) {
                    throw new VariableException("Variable is not numeric", varList[i].varName);
                }
                if (varList[i].format == VariableFormat.HEX_FORMAT)
                    value = Conversions.decimalToHex(numValue, 4);
                else if (varList[i].format == VariableFormat.BINARY_FORMAT)
                    value = Conversions.decimalToBinary(numValue, 16);
            }

            if (value.length() > varList[i].len)
                value = value.substring(value.length() - varList[i].len);

            int leftSpace = varList[i].padL +
                            (varList[i].format == VariableFormat.STRING_FORMAT ?
                             0 : (varList[i].len - value.length()));
            int rightSpace = varList[i].padR +
                            (varList[i].format == VariableFormat.STRING_FORMAT ?
                             (varList[i].len - value.length()) : 0);
            line.append(SPACES.substring(0, leftSpace) + value +
                        SPACES.substring(0, rightSpace) + '|');
        }

        outputAndCompare(line.toString());
    }