Type in a command, or "ls dictionary" to search all commands for "dictionary", etc.
|
NAME foreach - Loop through an 'array' and runs a YubNub command EXAMPLES foreach {explode 1,2,3,4} echos each array item 1, 2, 3, and 4 (as produced by explode) foreach {explode 1,2,3,4} -cmd sum 1 echos each array item increased by one foreach {explode 1,2,3,4} -cmd var tmp -set [|sum 1 %s|] sets var tmp to one greater than each array item, in order foreach {explode 1,2,3,4} -as array gives back an XML-type 'array' with the elements 1, 2, 3, and 4 foreach {explode 1,2,3,4} -as array -type xoxo gives back an XOXO-type 'array' with the elements 1, 2, 3, and 4 foreach {explode 1,2,3,4} -as array -type json gives back an JSON-type 'array' with the elements 1, 2, 3, and 4 foreach {explode 1,2,3,4} -as array -type json -callback x gives back an JSON-type 'array' with the elements 1, 2, 3, and 4 and callback x DESCRIPTION Loops through and 'array' in XML, XOXO, or JSON form (data wrapped in a JSONP callback will not work) and runs a YubNub command on it. NOTES If the YubNub command has a '%s' specified in it then the array items are substituted in there, otherwise they are simply passed at the end of the command. If you want to use pipes in what you pass the -cmd parameter you must use the syntax [|cmd|] instead of {cmd} because otherwise YubNub would evaluate the piping before foreach was run. AUTHOR Stephen Paul Weber http://singpolyma-tech.blogspot.com/