extractFieldName function

String extractFieldName(
  1. String fields,
  2. TIntRef pos
)

Implementation

String extractFieldName(String fields, TIntRef pos) {
  // The original source is a 1-based string index; the semantics are kept but converted to 0-based:
  // the caller starts with TIntRef(0) (corresponding to Pascal's Pos=1).
  var i = pos.value;
  final fieldsLength = fields.length;
  while (i < fieldsLength && fields[i] != ';') {
    i++;
  }
  final result = fields.substring(pos.value, i).trim();
  if (i < fieldsLength && fields[i] == ';') i++;
  pos.value = i;
  return result;
}