REMOVEF()

REMOVEF()

Top  Previous  Next

 

The REMOVEF() function extracts data from a delimited character string.

 

 

Format

 

REMOVEF(string{, delimiter{, count}})

 

where

 

stringis the string from which data is to be extracted.

 

delimiteris the delimiter character that separates elements of string. If omitted, a field mark is used. If delimiter is more than one character, only the first character is used. If delimiter is a null string, count characters are extracted.

 

countis the number of consecutive delimited elements of string to be extracted. If omitted or less than one, this defaults to one.

 

 

The REMOVEF() function uses the same optimised method as the REMOVE() function to extract items from string sequentially but uses a specified delimiter character instead of terminating on any mark character.

 

Whenever a string is assigned to a variable the remove pointer is set to point one character before the start of the string. Subsequent uses of REMOVEF() advance the point by one character and then extract characters from the position of the remove pointer up to the next delimiter character or the end of the string. Because the remove pointer gives immediate access to the position at which the REMOVEF() should commence, this operation requires no searching and is therefore very fast.

 

Once the end of the string has been reached, the remove pointer remains positioned one character beyond the end of the string and further REMOVEF() operations would return a null string.

 

The REMOVEF() function uses the STATUS() function to return information about its outcome:

0Successful
1Null string
2End of string

 

The remove pointer may be reset to the start of the string by assigning a new value to string. Where it is required to reset the remove pointer without changing the string, the SETREM statement can be used. Alternatively, applications frequently use a statement such as

S = S

which will assign S to itself thus resetting the remove pointer.

 

 

Examples

 

LOOP

  REF = REMOVEF(REF.LIST, ',')

UNTIL STATUS()

  PRINT "Reference number is " : REF

REPEAT

 

This program fragment prints successive elements from the comma delimited REF.LIST variable.

 

 

See also:

GETREM(), REMOVE, SETREM