User Tools

Site Tools


modding:function:enumwhile

Discuss this page on this page's Talk Page

enumWhile

See enumWhile at Xelerus

Syntax (enumWhile list condition itemVar exp) → value
Arguments list: A list of elements you want to walk through.
condition: Stops enum if condition is Nil.
itemVar: Name of the variable that will be used to hold the current element you are at in the enum. Does not need to be defined beforehand.
exp: The expression you want to evaluate for each element in the list. The element will be available inside the expression under the name you used in `itemVar'.
Returns value: Whatever the last expression evaluated inside returns.
Category iteration, list
Description A function allowing you to evaluate an expression using the variable to store the element you are at for every element in a list unless condition is Nil.

Basically a enum with an if inside of it.

Example

(block (condition)
	(setq condition True)
	(enumwhile '(a b c d) condition theElement
		(block Nil
			(if (eq theElement 'b) (setq condition Nil))
			(dbgOutput theElement)
			)
		)
	)

This will display on the debug console.

a
b
True

Return to Functions list

modding/function/enumwhile.txt · Last modified: 2014/12/27 04:40 by 127.0.0.1