GetField Function


Returns a segment (field) of a string.


sSegment = GetField (sString, sDelim, iField)
Variable Description
sSegment The returned segment. STRING.
sString The string to return a segment from. STRING.
sDelim The characters to use to separate fields in sString. STRING.
iField The field to return. INTEGER.


Use GetField to return segments of strings that have a known, consistent format, like part numbers or telephone numbers. GetField treats a string like a record; it uses the delimiter you specify to logically separate the string into fields. If the string has several segments that are separated by the same delimiter, use iField to get the part you want.

GetField returns an empty string ("") when the field is not found.


STRING sData = "name|rank|serial#"
Print (GetField (sData, "|", 1) ) // prints: name
Print (GetField (sData, "|", 3) ) // prints: serial#
Print (GetField (sData, "|", 4) ) // prints: