Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Simple array handling question

For general discussion related FlowStone

Simple array handling question

Postby Quentin » Tue Jan 15, 2013 5:43 pm

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
Quentin
 
Posts: 37
Joined: Sat Jul 14, 2012 5:35 am

Re: Simple array handling question

Postby TrojakEW » Tue Jan 15, 2013 9:41 pm

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.
Attachments
ruby_array_test.fsm
(401 Bytes) Downloaded 932 times
User avatar
TrojakEW
 
Posts: 111
Joined: Sat Dec 25, 2010 10:12 am
Location: Slovakia

Re: Simple array handling question

Postby trogluddite » Tue Jan 15, 2013 9:55 pm

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.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Simple array handling question

Postby Quentin » Thu Jan 17, 2013 3:10 am

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
Quentin
 
Posts: 37
Joined: Sat Jul 14, 2012 5:35 am


Return to General

Who is online

Users browsing this forum: No registered users and 114 guests