wrap | ||||||||||
Type | operator | |||||||||
Dictionary | LCS | |||||||||
Library | LiveCode Script | |||||||||
Syntax |
| |||||||||
Summary | Wrap allows the user to ensure the value of a variable stays within a specified range. | |||||||||
Introduced | 2.9 | |||||||||
OS | mac, windows, linux, ios, android | |||||||||
Platforms | desktop, server, mobile | |||||||||
Parameters |
| |||||||||
Example |
| |||||||||
Related | Operator: / Glossary: math operation | |||||||||
Description | The wrap function makes it easy to loop successively over a fixed number of items in a list. When cycling through the items of a list, the divisor parameter specifies which item will cause the cycle to loop back to the beginning of the list. This means that any number outside this range is mapped to a number within it. For example, if we had 5 wrap 3, the number 5 would be mapped to the number 2 as this is where the iterator would be pointing on the 5th iteration ie. 1, 2, 3, 1, 2 . Therefore 5 wrap 3 is 2. The mathematical formula implemented by the wrap operator is:
If a math operation on finite inputs produces a non-finite output, an execution error is thrown. See math operations for more information. |