Page 1 of 1

Simple array handling question

Posted: Tue Jan 15, 2013 5:43 pm
by Quentin
Hi, I have two small arrays of 8, 0 or 1 values and I want to check them against each other item by item. I currently use the "array equals" primative which only tells me if all elements of the array are the same.. Should i do this with a simple Ruby script (I haven't done any array handling in Ruby yet) or is there a Flowstone primative which will do this?.
Thanks
Quentin

Re: Simple array handling question

Posted: Tue Jan 15, 2013 9:41 pm
by TrojakEW
In attached file you can find array comparison. There are three arrays, two eqall and one diferent. There is also selector so you can swith between them and test comparison. If you need test values at specific place in array you need to specify position or section of array you want to compare otherwise it is same. If you need example let me know.

Re: Simple array handling question

Posted: Tue Jan 15, 2013 9:55 pm
by trogluddite
Hi Quentin,
What do your arrays represent, and what would you like to find out about them?

Pretty much most things you could do in either "green" or Ruby - but Ruby does handle arrays much more efficiently, and once you know it, is a lot quicker to make changes than the large number of green parts required to do the same thing.
In particular, Ruby is very good for making loops, and scanning through the items in arrays - for example, if you wanted to make a list of only matching entries, or make a new array of trues/falses for testing each individual pair of items.
Ruby also allows having arrays within arrays very easily, and you can have arrays that mix items of different types, unlike the "all float", "all integer" ones that you get in green.

If any of those ideas sound useful to you, let us know, it would not take long to build a few examples.

Re: Simple array handling question

Posted: Thu Jan 17, 2013 3:10 am
by Quentin
Thanks to both of you for your quick responses and suggestions/examples. The 8 element arrays represent relay conditions so they are boolean on/off 0/1 one array is the flowstone conditions for what the relays are supposed to be the second is parsed from an arduino over a serial connection of what are actual relay states are- essentially to make sure they stay in sync- checks every 2 seconds or so. I have built it in flowstone modules and now am working on a ruby version.. Thanks again for the support.
Quentin