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

I'm ready to kickstart at Ruby!(ruby illiterate)

For anything not directly related to FlowStone

I'm ready to kickstart at Ruby!(ruby illiterate)

Postby NightmareDream » Tue Apr 30, 2013 6:35 am

°Right now, i'm reading a cartoon strip starring a fox and another weirdo that has no legs... And ruby examples... And creative commons rantles x) ... Is this really where i have to start at? :)
°So... Learning Ruby will allow me to build anything web interactive stuff? :o
°Is it worthy to get at every corners of the Ruby universe? Is it Flowstone related or is Flowstone's ruby a paralel variant?
°Does Ruby ease up importing 3d, fast?
i'm Really enthousiastic and need just the necessary guidance to look around autonomously :P
Google doesn't deliver much results incliding both "ruby" and "flowstone" even if i substitute some keywords or specify PDF as the filetype filter
Last edited by NightmareDream on Wed May 01, 2013 1:51 pm, edited 1 time in total.
NightmareDream
 
Posts: 4
Joined: Mon Dec 20, 2010 11:58 pm

Re: I'm ready to kickstart at Ruby!

Postby trogluddite » Tue Apr 30, 2013 9:02 am

If you're learning from non-FS examples, there are a few things to watch out for...

- Lots of beginner's examples use 'puts' and 'gets' to send and receive text from a command-line type interface - this won't work in FS because the interaction is with the input and output connectors instead.
Assuming you have a Ruby editor straight from the toolbox, use these instead...
my_variable = gets => my_variable = @in
puts(<some stuff>) => output 0, <some stuff>

- FS doesn't include the "standard libraries" that can be used to add extra functionality. Not of problem for most beginner's examples, but the libraries get used a lot in examples from other forums etc. The thing to watch for here is if the example code begins with the 'include <name>' statement that's used to load a library.

NightmareDream wrote:°Does Ruby ease up importing 3d, fast?

Sadly not, graphics are still all provided by GDI+ - so no graphics acceleration.
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: 1452
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: I'm ready to kickstart at Ruby!

Postby NightmareDream » Wed May 01, 2013 6:40 am

Howdy good sir :P
My current plan is to convert most maths from my earlier synth to ruby in the simpliest processes while learnin g ruby on rails and server-related ruby questionings that i shall clarify for myself :) :P
So for a while, i'll concentrate on basic maths to replace most simple modules then group incrementally most components in a single sheet or the least and maybe experience tranquility :P
While learning ruby on rails, and more php to cover the lacks, will i be able to expect to interact with flowstone instances?

[Edit] "what a mess" i'm totally lost :) I'm having difficulties with the basic informations from the flowstone manual and am too new to ruby :P Any basics to help me with inputs and outputs? cause if i follow the tutorial, i get NoMethodError: undefined method 'outpput' for [output "result", @in]
NightmareDream
 
Posts: 4
Joined: Mon Dec 20, 2010 11:58 pm

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby trogluddite » Thu May 02, 2013 10:55 pm

NightmareDream wrote:NoMethodError: undefined method 'outpput' for [output "result", @in]

I'm guessing that "outpput" is a typo in your post - not in your Ruby tutorial! ;) :)

As with anything, it all depends on context, and with all this talk of Rails etc., I'm not quite sure where you are using the code, so apologies if I'm missing the jist of the question...

The 'input', 'output' methods are FlowStone specific - so if you are practicing in some other Ruby environment, you won't get any joy with those methods at all and will need to use 'puts', 'gets' or whatever else your examples might be using. '@in' too, is an FS specific pre-defined variable.
"input/output" also assume that they are in the context of a RubyEdit instance, so if they are called within a class or module definition, or with an explicit receiver, e.g. "<something>.output..." they won't work either.
They also might not work if you created a local variable called 'input' or 'output' - though those kind of clashes usually default to the method names when the usage is ambiguous.
If what I just said is meaningless jargon, then I doubt they are the problem - but they seem to be the only cases that would give you a "NoMethod" error.

In the FS context...
Code: Select all
output "result",@in

Means...
Send the value at the first Ruby input to an output called "result". (the @in variable is automatically defined by FS as the value on the first Ruby input).
This would only have any effect if you have tagged one of your Ruby outputs with the label "result" - if an output with that name is not found, nothing happens, but there is no error message.

The 'output' method is a little confusing this way because of how it can take a variable number of arguments...
Code: Select all
output "hello"   # send "hello" to the first (or only) output
output x, "hello"  # send "hello" to an output called (or numbered) 'x'
output x, "hello", t  # send "hello" to output 'x' at time 't'

Note that in each case, the commas always separate arguments - unlike some languages, ommas are not used for 'joining' parts of a string in Ruby (though some methods are defined to use their arguments to give that effect. e.g. 'watch "label", value')

Re: Rails - I really have no idea, as I've never used Rails. As I understand it, it is a platform for web development using Ruby, and is mostly intended as a way to produce fully fledged executable programs.
However, there are couple of factors that could make life tricky - not specific to Rails, but common to integrating any other "3rd party" features into FS...
1) Libraries
Rails relies very heavily on libraries of new classes and methods - and FS Ruby doesn't even come supplied with the "standard" libraries that would be part of a full Ruby installation. This can be overcome to a degree with some nifty file management - but could involve editing some library source code, so that everything looks in the right place for any required files.
2) Compiler compatibility
A great deal of libraries and "gems" consist of very fast code compiled from 'C'. But there are different compilers that can be usde for building the final executable code. The FS code base has all been created with Microsoft tools - but the Ruby community, being very 'open-source' oriented, tends to shun using Microsoft apps. So the majority of 'gems' are compiled using open-source compilers, meaning that their methods/classes etc. cannot always be used within FS.
It may be possible to work around this too - but it would be hard work, as you would need to use the Microsoft tools to re-compile all of the required Ruby 'extras' from their source code.
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: 1452
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby Nowhk » Thu Oct 30, 2014 3:18 pm

So, how can i print (on a new line into a Text string module)? Should I need to "append" the whole result into a string and then ouput it?

In a cycle for example, making the whole string could take lots of resources:

Code: Select all
@outputStr = ""
for j in 0...12000
    @outputStr += "index[" + j.to_s + "] = "+ @myArray[j].to_s + "\n"
end
output @outputStr

Is this the only way on FS? Since puts or print does not work...
Nowhk
 
Posts: 279
Joined: Mon Oct 27, 2014 6:45 pm

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby tulamide » Sat Nov 01, 2014 1:44 am

Nowhk wrote:So, how can i print (on a new line into a Text string module)? Should I need to "append" the whole result into a string and then ouput it?

In a cycle for example, making the whole string could take lots of resources:

Code: Select all
@outputStr = ""
for j in 0...12000
    @outputStr += "index[" + j.to_s + "] = "+ @myArray[j].to_s + "\n"
end
output @outputStr

Is this the only way on FS? Since puts or print does not work...

No, arrays are very versatile. Methods like 'map', 'with_index' or 'join' are very helpful here. Here's the above realized with array's methods alone:
Code: Select all
output @myArray.map.with_index{|cell, i| "index[#{i}] = " + "#{cell}\n"}.join
tulamide
 
Posts: 2107
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby Nowhk » Sat Nov 01, 2014 9:57 am

But what if I want to append to "watch" (i.e. print new line) any iteration inside a cycle? So I can see at every step what was the result. Not just the end of the processing (which is what "puts" does, or println in c++).
Nowhk
 
Posts: 279
Joined: Mon Oct 27, 2014 6:45 pm

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby TheOm » Sat Nov 01, 2014 2:18 pm

Maybe try something like this simple logger that just displays the last few outputs
Attachments
log.fsm
(1.4 KiB) Downloaded 562 times
TheOm
 
Posts: 101
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby tulamide » Sun Nov 02, 2014 7:50 am

Nowhk wrote:But what if I want to append to "watch" (i.e. print new line) any iteration inside a cycle? So I can see at every step what was the result. Not just the end of the processing (which is what "puts" does, or println in c++).

Now I'm confused. What is it exactly, you're looking for? An explicit example description is better than just a vague hint.

For example, I don't see an issue with something that spits out a text line per cycle. But where is the context? What cycle, what iteration, is it automated or does it have to be a manual solution? Where does the data come from? Etc. :)
tulamide
 
Posts: 2107
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: I'm ready to kickstart at Ruby!(ruby illiterate)

Postby Nowhk » Mon Nov 03, 2014 8:44 am

Let say I've the code above:

for j in 0...12000
// somethings like output "index: [" + j.to_s + "]
end

so every time the cycle iterate, I got on a "new line" in the ouput window (or watch window, or wherever I can) see new line at each iteration. Result:

index: [0]
index: [1]
index: [2]
index: [3]
index: [4]
...
index: [11999]

That's typical for debugging iteration on the fly ;)

TheOm's solution seems to show the right solution, but isn't there a native "printer" module? :shock:
Nowhk
 
Posts: 279
Joined: Mon Oct 27, 2014 6:45 pm

Next

Return to Off Topic

Who is online

Users browsing this forum: delialb60 and 9 guests