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
Ruby Syntax not quite right
7 posts
• Page 1 of 1
Ruby Syntax not quite right
I'm trying, i think , i know i haven't got the syntax/formatting correct.
Is there a package of Ruby examples that show basic programming, i.e. if..then , case, for, while & do etc?
Is there a package of Ruby examples that show basic programming, i.e. if..then , case, for, while & do etc?
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
Albert Einstein
Albert Einstein
-
JB_AU - Posts: 171
- Joined: Tue May 21, 2013 11:01 pm
Re: Ruby Syntax not quite right
For learning ruby I would recommend this:
http://www.codecademy.com/tracks/ruby
And of course the Flowstone UserGuide for the FS-specific stuff.
I hope I understood correctly what you wanted to achieve. I took a different approach without a case statement.
Please ask, if you need explanations on specific things in the code.
http://www.codecademy.com/tracks/ruby
And of course the Flowstone UserGuide for the FS-specific stuff.
I hope I understood correctly what you wanted to achieve. I took a different approach without a case statement.
Please ask, if you need explanations on specific things in the code.
- Attachments
-
- fix.fsm
- (25.8 KiB) Downloaded 840 times
- TheOm
- Posts: 103
- Joined: Tue Jan 28, 2014 7:35 pm
- Location: Germany
Re: Ruby Syntax not quite right
I am reading "Programming Ruby 1.9.2" Chris Pine, my problem is i want to find 'case' statements , but this book does not cover them actually not many books do o.O
So some examples of the syntax is more important as it will show how to format ruby in flowstone.
I am unsure if variables need to be defined/declared as my understanding so far is, that they are object until they hold a value.
I see what you have done , it is what i need the component to do & thankyou, but it evades how to do it with a 'case' statement & where the syntax is wrong.
So some examples of the syntax is more important as it will show how to format ruby in flowstone.
I am unsure if variables need to be defined/declared as my understanding so far is, that they are object until they hold a value.
I see what you have done , it is what i need the component to do & thankyou, but it evades how to do it with a 'case' statement & where the syntax is wrong.
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
Albert Einstein
Albert Einstein
-
JB_AU - Posts: 171
- Joined: Tue May 21, 2013 11:01 pm
Re: Ruby Syntax not quite right
Here's a small basic example I started with ...
Hope this helps a bit
Hope this helps a bit
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Ruby Syntax not quite right
Rj that confirms my understanding of 'case' statements in ruby/fs to be correct i am only now missing how i have laid it out to be correct.
I see from Om's example i need to declare the variable.
Om's example is really good , much shorter than using a 'case' & more fluid.
Yet i do not understand how the variable @counter can take the input from @Count when there is no reference in the code for @Count, where does the magic connection exist ?
I see from Om's example i need to declare the variable.
Om's example is really good , much shorter than using a 'case' & more fluid.
Yet i do not understand how the variable @counter can take the input from @Count when there is no reference in the code for @Count, where does the magic connection exist ?
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
Albert Einstein
Albert Einstein
-
JB_AU - Posts: 171
- Joined: Tue May 21, 2013 11:01 pm
Re: Ruby Syntax not quite right
JB_AU wrote:I see from Om's example i need to declare the variable.
It just has to be declared outside of the event function, otherwise it would be reset everytime there's a trigger.
JB_AU wrote:Yet i do not understand how the variable @counter can take the input from @Count when there is no reference in the code for @Count, where does the magic connection exist ?
I am not referencing @Count because there is no value to read out from a Trigger connector.
I used to think that the triggers are just booleans that turn on and off very quick too, but they aren't.
But what you can do is get the index of the triggered input, via the first argument of the event function(i in this case).
So in this line:
- Code: Select all
@counter += 1 if i==1
I'm incrementing @counter when the second input to the ruby component was triggered(@Count).
- TheOm
- Posts: 103
- Joined: Tue Jan 28, 2014 7:35 pm
- Location: Germany
Re: Ruby Syntax not quite right
Ohhhh!
That explains a lot , i too was living the fantasy that High=True / Low=False , you have rudely woken me up
Ohhh! I have to go salvage my pride.
That explains a lot , i too was living the fantasy that High=True / Low=False , you have rudely woken me up
Ohhh! I have to go salvage my pride.
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
Albert Einstein
Albert Einstein
-
JB_AU - Posts: 171
- Joined: Tue May 21, 2013 11:01 pm
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 47 guests