fe
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | fe [2007/07/10 21:12] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Synopsis: | ||
+ | __fe__ (< | ||
+ | __fe__ < | ||
+ | |||
+ | ======Description: | ||
+ | Form 1: | ||
+ | |||
+ | __FE__ is one of several loop types available in ircII-EPIC. | ||
+ | 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. | ||
+ | and other control structures, the braces surrounding the action may | ||
+ | appear anywhere. | ||
+ | (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. | ||
+ | can do this as well, but __FE__ offers a more elegant solution. | ||
+ | |||
+ | Form 2: | ||
+ | |||
+ | The second form of [[fe]] allows you to rewrite a control variable that | ||
+ | contains a word list. The initial value of the control variable is used | ||
+ | as the word list (as in the first form) and after each iteration of the | ||
+ | loop, all of the loop variables are appended together to build up a new | ||
+ | value for the variable. | ||
+ | the conclusion of the final iteration of the loop. | ||
+ | |||
+ | This form might have been named __MAP__ after perls map function but the | ||
+ | [[MAP command|MAP]] is already used for something else. | ||
+ | It is functionally equivalent to this snippet of code: | ||
+ | |||
+ | fe ($targetvar) foo { | ||
+ | ... | ||
+ | push tempvar $foo | ||
+ | } | ||
+ | @ targetvar = tempvar | ||
+ | @ tempvar = [] | ||
+ | |||
+ | [[BREAK]]ing out of a loop will cause the original list to be truncated | ||
+ | _after_ the current set of variables have been written. That is, the | ||
+ | break occurs after the push in the above code. | ||
+ | |||
+ | ======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 | ||
+ | |||
+ | A script to square all numbers (words) in the $list variable: | ||
+ | fe list foo { | ||
+ | @ foo = foo * foo | ||
+ | } | ||
+ | |||
+ | ======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. | ||
+ | parenthesis, | ||
+ | |||
+ | ======Other Notes: | ||
+ | The loop doesn' | ||
+ | It doesn' | ||
+ | [[local]] variables instead of global. | ||
+ | |||
fe.txt · Last modified: 2007/07/10 21:12 by 127.0.0.1