WrapOperator

Typeoperator
DictionaryLCB
LibraryLiveCode Builder
Syntax
<Left> wrap <Right>
Associationscom.livecode.arithmetic
Summary

Wrap operator.

Parameters
NameTypeDescription
Left

An expression that evaluates to a number.

Right

An expression that evaluates to a number.

Example
variable tVar as Number
put 5 wrap 3 into tVar -- tVar contains 2
variable tVar as Number
put -3 wrap 3 into tVar -- tVar contains -3
Values
NameTypeDescription
return

If x = 0, then x wrap y returns ((x-1) mod abs(y)) + 1. If x  0, then x wrap y returns -((x-1) mod abs(y)) + 1.

Description

Use wrap to ensure the value of a variable stays within a specified range. For x,y  0, successive values of x wrap y cycle through the sequence 1, 2, ..., y.