Skip to main content

RemoveListItem

RemoveListItem (index, listStr [, listSepStr [, offset]])

The RemoveListItem function returns listStr after removing the item specified by the list index index.

Use RemoveListItem to remove an item from a string containing a list of items separated by a separator, such as strings returned by functions like TraceNameList and AnnotationList.

Parameters

index is the zero-based index of the list item that you want to remove.

listStr contains a series of text items separated by listSepStr . The trailing separator is optional though recommended.

listSepStr is optional. If omitted it defaults to ";". Prior to Igor Pro 7.00, only the first byte of listSepStr was used. Now all bytes are used.

offset is optional and requires Igor Pro 7.00 or later. If omitted it defaults to 0. The search begins offset bytes into listStr. When iterating through lists containing large numbers of items, using the offset parameter provides dramatically faster execution. For an example using the offset parameter, see StringFromList.

Details

RemoveListItem differs from RemoveFromList in that it specifies the item to be removed by index and removes only that item, while RemoveFromList specifies the item to be removed by value, and removes all items that match it.

If index less than 0 or greater than ItemsInList(listStr) - 1, or if listSepStr is "" then listStr is returned unchanged (unless listStr contains only list separators, in which case an empty string ("") is returned).

If the resulting string contains only listSepStr characters, then an empty string ("") is returned.

Examples

Print RemoveListItem(1, "wave0;wave1;w2;")      // Prints "wave0;w2;"

See Also

AddListItem, RemoveFromList, WhichListItem, StringFromList, FindListItem, ItemsInList, RemoveByKey, AddListItem, WaveList, TraceNameList, StringList, VariableList, FunctionList