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

Ruby Array Formating

For general discussion related FlowStone

Ruby Array Formating

Postby aronb » Fri Mar 17, 2017 5:24 am

Hi,

I created a Ruby Circle Class that seems to work. I created an array of circles, that seems to work as well... However I don't know how to format the output to an external array in one of two ways. :oops:

1 - With all of the circle data array info in one comma delimited array
2 - With each element in its own array

Here is my schematic, (with notes) any help would be appreciated please :)

Ruby_Circle_Array.fsm
Ruby Circle Array and Class
(1.86 KiB) Downloaded 864 times


Thank You,

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Re: Ruby Array Formating

Postby tulamide » Fri Mar 17, 2017 12:30 pm

Get all data from one type into an array:

Code: Select all
xpos = []
cir.map { |e| xpos << e.xposition }      
output 'data', xpos


You'd do the very same to each of your class' values (e.g. e.yposition, or e.color)

Getting an array of arrays is more tricky, since you don't have an array of arrays output. Instead you would translate it to a string and output a string.

Since I don't know what you expect the exported values to be used for, I can't tell more.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2687
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby Array Formating

Postby aronb » Sat Mar 18, 2017 3:26 am

tulamide,

Thanks - that got me going to the next part! :D !

I almost feel I am FINALLY learning a bit of Ruby :oops: Its a long road when you mind is a bit older :shock:

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA


Return to General

Who is online

Users browsing this forum: No registered users and 41 guests