private void FormatRecord(int recordIndex, RecordIdentifier theRecId) { LayoutDataset.FieldRow[] fields; FormattedDataDataset.RecordRow fmtRec = ds.Record.NewRecordRow(); fmtRec.Name = theRecId.RecordName; fmtRec.Index = recordIndex; fmtRec.Hidden = theRecId.HideInFormattedView; ds.Record.AddRecordRow(fmtRec); // b. process this record and move position accordingly fields = (LayoutDataset.FieldRow[])layout.DataSet.Field.Select("RecordName = '" + theRecId.RecordName + "'", "Index"); logger.Log(Logger.MessageType.DEBUG, "Parsing " + fields.Length + " fields ..."); int fieldIndex = 0; for (; fieldIndex < fields.Length; fieldIndex++) { bool indexMoved = false; LayoutDataset.FieldRow fieldRow = fields[fieldIndex]; LayoutDataset.FieldRow eor = GetNextEorField(theRecId, fieldRow, recordIndex); string dataValue = null; if (fieldRow.Length < 0) { dataValue = GetVariableLengthValue(fields, fieldIndex, fieldRow); indexMoved = true; } else { dataValue = GetString(0, fieldRow.Length); } if (dataValue != null) { bool processField = CheckValueForProcessing(recordIndex, theRecId, fmtRec, fieldRow, eor, dataValue); if (processField) { FormattedDataDataset.FieldRow fmtField = ds.Field.NewFieldRow(); fmtField.Name = fieldRow.Name; fmtField.RecordName = fmtRec.Name; fmtField.RecordIndex = recordIndex; fmtField.Description = fieldRow.IsDescriptionNull() ? "" : fieldRow.Description; fmtField.Value = dataValue; fmtField.Index = fieldRow.Index; fmtField.Length = fieldRow.Length; ds.Field.AddFieldRow(fmtField); if (!indexMoved) { this.idx += dataValue.Length; } } } else if (!indexMoved && !fieldRow.IsLengthNull()) { // if data field was not set, still move index this.idx += fieldRow.Length; } } }