Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Counter with range



You'd probably want to add another variable such as initial value for this case.
.xX


Ian Grant wrote:
Hi All, if you assign the object count to Min, the patch is initialised and starts from the Min count rather than 0.

Sorry if that is obvious!

if (Object.count == undefined) {

Object.count = Min;
}

Regards, Ian
*******************************
Ian Grant
Senior Lecturer in Digital Art
Faculty of the Arts
Thames Valley University
Ealing, UK
W5 5DX
<email@hidden>
*******************************



On 6 Jul 2007, at 21:10, email@hidden wrote:

OK, I figured it out. The code below works. Thanks for your help! Have a nice weekend.

F.

Increasing = inputs[0];
Decreasing = inputs[1];
Reset = inputs[2];
Min = inputs[3];
Max = inputs[4];

if (Object.count == undefined) {
Object.count = 0;
}

if (Increasing) Object.count==Max?_count:Object.count++;
if (Decreasing) Object.count==Min?_count:Object.count--;
if (Reset) Object.count = 0;

outputs[0] = Object.count;



On 7/6/07, email@hidden <email@hidden> wrote:
I tried this, but the result reverts to 0 as soon as the increase signal is set to false. I guess I must "hold" the _count variable somehow? Thanks for your help.


Increasing = inputs[0];
Decreasing = inputs[1];
Reset = inputs[2];
Min = inputs[3];
Max = inputs[4];


var _count = 0; if (Increasing) _count==Max?_count:_count++; if (Decreasing) _count==Min?_count:_count--; if (Reset) _count = 0;

outputs[0] = _count;



On 7/6/07, Alessandro Sabatelli <email@hidden> wrote:
Hey F. You'll need to store an internal variable for the count. Here is some "pseudocode" to get you started...


var _count = 0;
function (__number Count) main (__boolean Increasing, __boolean Decreasing, __boolean Reset, __number Min, __number Max) {
var result = new Object();


    if (Increasing) _count==Max?_count:_count++;
    if (Decreasing) _count==Min?_count:_count--;

    result.Count = _count;
    return result;
}

.xX


email@hidden wrote:
Hi list,

is there a patch that works like the Counter but with a minimum/maximum value? I know I could simply connect the counter to a Range patch or a restricted Input Splitter, but given that the maximum count is 5 and the counter has received 100 increase signals, I don't want to have to send it 95 decrease signals to get to the point where the count starts decreasing again. I figure this is feasible with a Javascript patch, but I'm afraid I don't have any Javascripting skills. The patch also needs a reset signal input (just like the standard counter).

Your help is much appreciated.
F.
_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (email@hidden .com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman /options/quartzcomposer-dev/email@hidden This email sent to email@hidden






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden



This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden



This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden
References: 
 >Counter with range (From: email@hidden)
 >Re: Counter with range (From: Alessandro Sabatelli <email@hidden>)
 >Re: Counter with range (From: email@hidden)
 >Re: Counter with range (From: email@hidden)
 >Re: Counter with range (From: email@hidden)
 >Re: Counter with range (From: Ian Grant <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.