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

Any use for this?

Post any examples or modules that you want to share here

Any use for this?

Postby MyCo » Mon Nov 12, 2012 12:50 am

Hi,

I've been playing around with ruby, and found a cool new (hidden) feature :twisted:
Attachments
Crazy.fsm
(1.83 KiB) Downloaded 1607 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Any use for this?

Postby trogluddite » Mon Nov 12, 2012 1:21 am

...but not as well hidden as the purple highlighted keyword "caption", maybe?. ;) :ugeek:

Here's one for you...
Code: Select all
primitive_name = caption.gsub(" ","_")  #remove whitespace
eval ("@@#{primitive_name}=self")  # builds a class variable with that name pointing at this Ruby instance


Because class variable are visible in all Ruby windows, you can now go into a completely different Ruby primitive and type this...
@@name.output 0,"Hello"
...and this output will appear on the output of the first Ruby block.
Of course, this kind of monkeying with the name space could get out of hand and confusing very easily - but I think there are some very interesting tricks to be learned.
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: Any use for this?

Postby MyCo » Mon Nov 12, 2012 1:49 am

hehehe... weird... but with global variables you could do this the other way around, too (polling a global variable and then change the output)
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Any use for this?

Postby trogluddite » Mon Nov 12, 2012 2:27 am

By writing to inputs you can even send triggered events....
@@Over_there.input 0,value - send the value to another module's input as if a link were there - though you don't get auto-summing, so multiple inputs through the Ruby ether will fight.
The only fly in the ointment is that the order that Rubies get parsed at start-up is confusing - if modules don't get parsed in the order you expect, you can easily make calls to methods that haven't been created yet. I think the rules for it are nor so complex, but hard to keep track of if you're in the middle of a hot cutting and pasting session.
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: Any use for this?

Postby MyCo » Mon Nov 12, 2012 2:38 am

What, I don't like is: The inputs/outputs are not updated, when you disconnect them. They keep their value for ever. Even copy & paste of the ruby module or changing the connector type, doesn't update the value.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Any use for this?

Postby trogluddite » Mon Nov 12, 2012 3:19 am

Hmm, can't quite work out if that is a 'feature' or not either - after so long using green, it seems does strange the inputs not polling when you read them.
Maybe interfacing different Ruby and Green threads made it tricky. That kind of persistence is all around in Ruby though - if you type out a big Class with lots of juicy methods - and then CTRL-A, DEL - all of those definitions are still active for the rest of the session. Everything you type gets interpreted, including the typo's that you rub out!
Mostly really enjoying it though - it really is very nice to be able to get some decent data structures together, the old one-dimensional green arrays just weren't really up to the job for big filtering and sorting jobs.
Should make a lot of ball-scratching about triggers a thing of the past too. I really like the way that you can define your own trigger behaviour for each and every input, that and the clear program flow make it much easier to keep track of what's going on.
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: Any use for this?

Postby Tronic » Mon Nov 12, 2012 10:31 am

You can inspect all Method, Costants and Class loaded in ruby instance with this.
Attachments
Methods_.fsm
(321 Bytes) Downloaded 1525 times
Last edited by Tronic on Mon Nov 12, 2012 6:53 pm, edited 1 time in total.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Any use for this?

Postby MyCo » Mon Nov 12, 2012 6:07 pm

what is 'libimprov-2.2.7' ?

actually I used x.class.instance_methods(false) to inspect. And found "parent" and "caption"... :twisted:
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Any use for this?

Postby trogluddite » Mon Nov 12, 2012 6:52 pm

Rather close to Xmas to be finding so many easter eggs! ;)
Here another I just found...
The MIDI object type has attribute accessors for status,channel,data1,data2,sysex. So you can write stuff like...
Code: Select all
@myMIDI = Midi.new(176,2,10,150)
@myMIDI.channel = 5
ccNumber = @myMIDI.data1 if myMIDI.status = 176

Many of the FS classes also seem to have the Marshal class methods _dump and _load defined - so it should also be quite easy to store pretty much any object or collection of objects to file.
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: Any use for this?

Postby Tronic » Mon Nov 12, 2012 6:58 pm

MyCo wrote:what is 'libimprov-2.2.7' ?


sorry :D my experiment to integrate other library
i have uploaded the correct file now.

I'm trying to create a wrapper for the midi,
because there is not yet a full implementation of all the messages,
and I regret to to know that is not a priority for developers :x
but until the support does not tell us how to run the callback with the current Win32API,
I do not think it is possible to do something shared with other users.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Next

Return to User Examples

Who is online

Users browsing this forum: Google [Bot] and 42 guests