remove

action

Syntax
remove  shelf-name indexer?


Purpose

Removes the selected item from the shelf. If no indexer is given, the currently selected item is removed.

When an item is removed from the shelf, the numbers of all items that follow it in the shelf drop by one. However, items with keys keep the same keys. remove can be used to produce a "cleared" shelf, with no items.

If a keyed item is removed from the shelf, that key can be reassigned to a new shelf item.

Unless modified by a repeat over or a using prefix, referring to a shelf item without using an index refers to the last (lastmost) item on the shelf. Modifiable and read-only function arguments inherit the selected items from the caller.

Usage example:

  process
     local stream foo variable initial-size 0
     set new foo{"Mary"} to "Mary had a little lamb.%n"
     set new foo{"fleece"} to "Its fleece was white as snow.%n"
     set new foo{"school"} to "It followed her to school one day%n"
     set new foo{"rule"} to "Which was against the rule.%n"
     
     remove foo[3]
     remove foo{"fleece"}
     
     repeat over foo
        output foo
     again   

remove actions are not permitted on shelves of a fixed size. Also, for shelves indexed by a repeat over action, the remove action is not allowed on original shelf items. However, items explicitly created inside the repeat over block may be deleted from that same block.

Related Concepts