|
compare a number with a structureHello, A Queue stores values (several numbers between 0 et 99 entering one by one) I want to know if and when this value is repeating (same number comes again) in other words, can I easily compare the last value with each older in the structure generated by the Queue ? I made a macro patch with 30 times : structure index member > conditional set with each index... It's so big... The solution is certainly simpler... Thanks, Alain
|
Hello, I'm working again on this project these days and I'm still wondering how to compare values with structures.
To be more specific : how to compare values with other values within a structure.
For example I want to know :
I'm really stuck and I'm surprised not to find a "search in Structure" patch in QC...
Thanks for any help ! Alain
My suggestion is to use JavaScript (or LUA script with 3rd party plugin) to compute this kind of logic. QC isn't made for this complex logic and so its necessary to use a high level programming language.
Thanks Achim for your answer. I've no experience with Javascript, so have you any advices regarding my needs before I try something ? Links, reading...
Thanks again Alain
Alain,
sorry, I don't have any special links. However this may give you some startingpoint:
How to get the max-value of an structure: (DISCLAIMER: Untested code!)
Here is some more about JavaScript in QC: http://kineme.net/wiki/JavaScriptQuartzComposer
Waou ! Great !
I'll try this today and also try to adapt your code for : - duplicate entries - rank of entries ...
Thanks, Alain
Maybe I was too hopeful, I don't have enough programming skills to succeed in my goals...
I try to combine your code and something I found here : http://stackoverflow.com/questions/840781/easiest-way-to-find-duplicate-...
Without any result. I must stop for today, but will try again tomorrow.
Thanks again, Alain
by the way, QC shows a TypeError line 4 : "nul is not an object (evaluating array.length) But I'm not sure to understand what it means...
My JavaScript is a bit rosty. ;-)
You have to wrap everything with "if (!_testMode)" because the JavaScript is run in a preflight testmode with no input. So there is no array coming in and therefor the .length() fails.
I'll test this as soon as possible.
Thanks again, Alain
Unfortunately I've not enough time to dig in and start learning JS these days. But it's definitively something I'll have to do one day or the other...
For now I found a way to solve my problem with "Mathematical Expressions". It's not really sophisticated, but it works.
Thanks again Achim for your time !
Math Expression Patch is the best. Kineme have a turbo charged version that allows for multiple expressions and results with one set of inputs. No sure which plugin it is, maybe Data Tools?
There are stock sort structure and structure range patches which allow for reasonably good handling of structures too. Nothing like you'll get with a scripting language.
I've added a composition to get you started. It generates a structure of random numbers, sorts them then finds the matches and highlights them in the window. All without Javascript or Lua :-)
There are two user inputs at the top level for flushing the random structure and number of array elements.
Thanks, I'll look at this composition very soon.