Manual:DIL Manual/remove()
Jump to navigation
Jump to search
remove()
Procedure. Takes the entry at a given position out of a stringlist or an intlist.
remove(list : stringlist or intlist, i : integer)
The entries after it move down one place, so no gap is left. Positions count from 0. It works
on a list variable and on the list fields of an extra (ex.names,
ex.vals). To take a string out by its text rather than its position, use
substring().
Parameters
| Name | Type | Meaning |
|---|---|---|
| list | stringlist or intlist | The list to change: a variable or a list field, not a function's result. |
| i | integer | The position of the entry to remove. |
Notes
- A position below 0 or past the end does nothing.
- When
iis a failed value (a field of null), entry 0 is removed. - In an extra's
namesthe first entry is the extra's own name, the one
in finds it by: start removing data at position 1.
- While removing several entries in a loop, go from the end to the start, or each removal
shifts the positions still to come.
Example
dilbegin drop_entry(u : unitptr, cname : string);
var
ex : extraptr;
i : integer;
code
{
ex := "$comp" in u.extra;
if (ex == null)
return;
i := length(ex.names) - 1;
while (i >= 1)
{
if (ex.names.[i] == cname)
{
remove(ex.names, i);
remove(ex.vals, i);
}
i := i - 1;
}
return;
}
dilend
Takes a competition out of the names and values a player's extra keeps side by side, as competition.zon does.