1. That StringField() be renamed to FieldString() for consistency with the names of other string functions.
2. That a new string function FieldStart() be added as it would complement the existing StringField() facility by returning the start position of each field rather than the contents. The high-level code for it would be:
Code: Select all
Procedure.l FieldStart(string$, index, separator$)
; Returns the start position of the string field at the specified index
; Consistent with the usage of StringField()
Protected field, posn = 1
For field = 0 To index-2
posn = FindString(string$, "-", posn)+1
If posn=1
posn=Len(string$)+1 ; Suitable for use with Mid()
Break
EndIf
Next field
ProcedureReturn posn
EndProcedure
; Example:
Define x$, field
x$ = "abc-de-fgh-i--jk-" ; 1 5 8 12 14 15 18
For field = 1 To CountString(x$, "-")+1
Debug Str(FieldStart(x$, field, "-"))+" "+StringField(x$, field, "-")
Next field
End
It would also be useful for analysing strings having a mix of delimiters/separators.