Eyeon:Script/Reference/Libraries/table/foreachi

From VFXPedia

< Eyeon:Script | Reference | Libraries | table
Revision as of 14:01, 9 December 2006 by Peter (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

table : table.foreachi

Arguments

table.foreachi( table, command )

  • table (required, table)

A table containing the values to be processed.

  • command (required, string)

command (required, string)

  • index (optional, number)

A function which will receive the index and value for each element in the table.

Returns

Returns any non-nil value returned by the command function.

Remarks

The foreachi function takes two arguments, a table, and a command which is the name of a valid function. The foreachi function loops through the numerical indices of the table, passing the index and value for each entry as arguments to the command function. If the command function returns a value which is not nil than the loop is broken, and the foreachi command with the return value of the command function.

This function is almost identical to its sister function foreach(), except that it operates on numerical indices of the table only. Entries in the table indexed with alphanumeric identifiers are ignored. The elements of the table are passed to the function in numerical order, from 1 to n where n is the value of table.getn.

Requirements

  • eyeonScript 5.0
  • Fusion 5.0

Examples

--- simple example x = {x = 1001, 104, 1000, 105, name = "Hello"} print("Using the foreach function ") print("---------------------------") table.foreach(x, print)

print("Using the foreachi function") print("---------------------------") table.foreachi(x, print)


Tips for foreachi (edit)

EyeonTips:Script/Reference/Libraries/table/foreachi