Here's an updated version.  That I fixed awhile back.  I wish someone had 
caught that before I had to fix it ;)


var _init = false
var _count = 0

function (__number Count) main (__boolean Increasing, __boolean Decreasing, 
__number initialValue, __boolean isLimited, __boolean wrapLimits, __number Min, 
__number Max, __boolean Reset, __number Time) {
        var result = new Object();
        
        if (!_testMode && !_init) {
                _init = true
                _count = initialValue
        }
        if (isLimited) {
                if (wrapLimits) {
                        if (Increasing) {
                                _count = (_count+1) % (Max+1);
                        }
                        if (Decreasing) {
                                _count = _count == Min ? Max : _count-1; 
                        }
                } else {
                        if (Increasing) _count>=Max?Max:_count++;
                        if (Decreasing) _count<=Min?Min:_count--;
                }
        } else {
                if (Increasing) _count++;
                if (Decreasing) _count--;
        }
        
        if (Reset) _count = 0;
        
        result.Count = _count;  
        return result;
}

.xX

On May 27, 2010, at 12:01 PM, Achim Breidenbach wrote:

> Hello,
> 
> I think this is a syntax error, because you (or who ever) doesn't put the 
> result of {(_count++) % Max} into any variable, it is just a statement which 
> doesn't go anywhere.
> 
> I guess you wanted something like this:
> 
> if (Increasing) _count = (_count+1) % Max;
> 
> best,
> 
> Achim Breidenbach
> Boinx Software
> 
> On 27.05.2010, at 20:49, Roger Jones wrote:
> 
>> 
>> On Sep 19, 2009, at 11:27 AM, Alessandro Sabatelli wrote:
>> 
>>> You can use Javascript to roll your own counter:
>>> 
>>> var _count = 0;
>>> function (__number Count) main (__boolean Increasing, __boolean Decreasing, 
>>>  __boolean isLimited, __boolean wrapLimits, __number Min, __number Max, 
>>> __boolean Reset) {
>>>     var result = new Object();
>>>     
>>>     if (isLimited) {
>>>             if (wrapLimits) {
>>>                     if (Increasing) (_count++)%Max;
>>>                     if (Decreasing) _count==Min?Max:_count--;
>>>             } else {
>>>                     if (Increasing) _count==Max?_count:_count++;
>>>                     if (Decreasing) _count==Min?_count:_count--;
>>>             }
>>>     } else {
>>>             if (Increasing) _count++;
>>>             if (Decreasing) _count--;
>>>     }
>>>     
>>>     if (Reset) _count = 0;
>>>     
>>>     result.Count = _count;  
>>>     return result;
>>> }
>> 
>> This looks correct but if wrapLimits is enabled the counter doesn't wrap or 
>> clip, it continues to increment.
>> "if (Increasing) (_count++)%Max;"  should return the remainder of count/max 
>> but instead I just get _count.  Is this a bug or a syntax error? 
>> 
>> Roger Jones
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Quartzcomposer-dev mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/quartzcomposer-dev/achim%40boinx.com
>> 
>> This email sent to [email protected]
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Quartzcomposer-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/quartzcomposer-dev/asabatelli%40apple.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to