foreach
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | foreach [2006/08/01 03:13] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Synopsis: | ||
+ | __foreach__ [-]< | ||
+ | |||
+ | ======Description: | ||
+ | The __FOREACH__ command is a loop type that iterates through the items in | ||
+ | a variable (or alias, see below) structure. | ||
+ | purging an entire structure, or for searching through it for a certain | ||
+ | piece of data. | ||
+ | |||
+ | Variables in the action field are normally not expanded until actual | ||
+ | execution of the action. | ||
+ | the opening curly brace with a backslash: \{ | ||
+ | |||
+ | If a hyphen (-) is prepended to the structure name, the __FOREACH__ loop | ||
+ | will try to iterate through an alias structure instead of a variable | ||
+ | structure. | ||
+ | |||
+ | ======Examples: | ||
+ | Simple usage of __FOREACH__, | ||
+ | foreach blah xx { | ||
+ | | ||
+ | echo $blah[$xx][$yy] | ||
+ | } | ||
+ | } | ||
+ | |||
+ | To purge an alias structure called booya: | ||
+ | foreach -booya xx { | ||
+ | alias -booya[$xx] | ||
+ | } | ||
+ | |||
+ | ======Restrictions: | ||
+ | Structures may be referenced as either $var.${subvar}.${subvar} or | ||
+ | $var[$subvar][$subvar] (with any number structure levels, of course). | ||
+ | The notation $var.$subvar.$subvar parses as $var[${subvar.$subvar}], | ||
+ | which of course is incorrect, and should not be used. | ||
+ | |||
+ | ======Other Notes: | ||
+ | The action portion does not necessarily need to do anything, though there | ||
+ | isn't much point in using the command without it. | ||
+ | |||
foreach.txt · Last modified: 2006/08/01 03:13 by 127.0.0.1