fe, fec
Synopsis:
fe (<list>) <variable>
fec (<list>) <variable>
Description:
fe is one of several loop types available in TekNap. This loop takes
a list of items, and for each one, it performs the specified action.
It may act on more than one item at a time. The list may be a plain text list,
a variable, a function, or any combination. As with aliases and other control
structures, the braces surrounding the action may appear anywhere. List items
are whitespace-delimited. Extended words (those with spaces in them) are honored
when they are surrounded in double quotes (").
For instance, fe might be used to loop through a list of nicknames that
the user wishes to invite to a channel (or kick from it!).
Any looping mechanism can run through a list one by one. The real power of fe
is its ability to act on multiple list items at once. One could perform
an action on 3 at a time, for instance, such as setting a +o channel mode on
other users. Other loops, such as for, can do this as well, but fe
offers a more elegant solution.
Examples:
A simple mode +o script to cluster mode changes 3 at a time:
fe ($friends) xx yy zz {
..if (zz) {
....mode #blah +ooo $xx $yy $zz
..} {
....if (yy) {
......mode #blah +oo $xx $yy
....} {
......mode +o $xx
....}
..}
}
A script to check for upper-case
letters in a line of input:
@ caps = 0
fec ($*) xx {
..if (ascii($xx) >= 65 || ascii($xx) <= 90) {
....@ caps++
..}
}
echo *** Found $caps upper-case letters
Aliases:
fec works the same as fe, except it loops through each character
in the list, not each word. Whitespace is only valid if it is between two other
non-whitespace characters. Whitespace that follows the opening parenthesis,
and that leads up to the closing one, is ignored.
See Also:
for
foreach
while, until
Other Notes:
The loop doesn't necessarily have to have an action inside the curly braces.
It doesn't make much sense to omit it, though.