It's not "crashing" qc as such, but you're locking it into an infinite
loop. What happens is:

- You start a loop with "while(go)", and go is true so the loop will
run until it is false
- You set a to inputValue[0] + 1. Let's say value[0] is 0, so a=1.
- If a > 100, set go to false and stop the loop.
- a is less than 100, so the loop restarts. Infinitely.

You need to change how it works. You don't need a loop inside the JS
at all, because you're just doing inputValue[0] + 1 once per frame.

Also, "if(a = b)..." doesn't check if a=b at all, it assigns b to a.
Exactly like if you do "var a=10". To compare in javascript (or almost
any other language) use ==, so "if(a == b)..."

The reason why things seem so much faster with feedback inside the
script instead of going through QC is simple. The JS patch will get
executed once per frame, so if your comp is running at 60fps it will
execute 60 times per second, i.e. it will increase by 60 every second.
If you do it internally, the script will increment until it reaches
your limit, then finish - it will do this in 1 frame (this means if
your javascript takes a long time, QC must wait for it and it will run
slowly).

Chris


2009/6/17 Alastair Leith <[email protected]>
>
> Please help a novice with this peculiarity in JS patch.
> In the following script the conditional (a > 100) cause a QC crash. (Q1. 
> Why?) Also a is equal to inputNumber[1] value at end of execution when it 
> should
> be staying the same each loop as in:
> a = inputNumber [0] + 1;
> (Q2 Why isn't a always = 1?)
> function (__number outputNumber) main (__number inputNumber[2])
> {
> if (!_testMode)
> {
> var go = new Boolean;
> go = true;
> while (go)
> {
> a = inputNumber [0] + 1;
> //   offending line
> // if (a > 100) causes a QC crash ?!
> if (a = inputNumber [1])  // this works though
> // the value in inputNumber [1] ends up on screen ?!
> // a is not being incremented, it is being assigned ( 0 + 1 ) each loop??
> go = false;
> }
> var result = new Object();
> result.outputNumber = a;
> return result;
> }
> }
>
> Attached the QC file which also has a JS patch feeding back its output to its 
> input. Takes quite a long time to get to 500 that way...
> (Q3 Why is it taking so long when inside the script it get's to 5000 in a 
> nanosecond)?
>  _______________________________________________
> 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/psonice%40gmail.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