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
how to remove line jump/break with ruby
4 posts
• Page 1 of 1
how to remove line jump/break with ruby
Hello everyone, I have been a user since 2016 and I need help at this time:
I have the following scheme (attached fsm 3.0.6 file):
Grand piano
Electric Piano 1
Clavinet
and I need to remove the jump / line breaks with ruby so that it looks like this:
Grand piano
Electric Piano 1
Clavinet
I found a module called 'Format String' but I don't know how to use it,
how to achieve it ?
I have the following scheme (attached fsm 3.0.6 file):
Grand piano
Electric Piano 1
Clavinet
and I need to remove the jump / line breaks with ruby so that it looks like this:
Grand piano
Electric Piano 1
Clavinet
I found a module called 'Format String' but I don't know how to use it,
how to achieve it ?
- Attachments
-
- Menu of Favorites.fsm
- It's made with FlowStone 3.0.6
- (12.03 KiB) Downloaded 857 times
-
ErvSoft - Posts: 31
- Joined: Sun Jul 31, 2016 11:59 pm
- Location: Chile
Re: how to remove line jump/break with ruby
This line of Ruby code should do what you want. It removes only the empty lines from a multi-line string...
Yes, I know - it looks like it should be a syntax error in any sensible coding language!
The gsub part is simple enough; it means "Globally SUBstitute" - i.e. search and replace. It takes two arguments - a thing to look for, and a thing to replace it with. The replacement here is easy; an empty string - replace with nothing = delete.
The search term, /^\s*$/ is what's called a regular expression. It's a way of saying that you want to match a pattern rather than a specific string (like the * and ? wild-cards from file-dialogs on steroids). In this case, we don't want to remove all whitespace, and not even every line-ending - a regular expression makes it possible to express "only a blank line and its line ending".
- Code: Select all
output @in.gsub(/^\s*$/, "")
Yes, I know - it looks like it should be a syntax error in any sensible coding language!
The gsub part is simple enough; it means "Globally SUBstitute" - i.e. search and replace. It takes two arguments - a thing to look for, and a thing to replace it with. The replacement here is easy; an empty string - replace with nothing = delete.
The search term, /^\s*$/ is what's called a regular expression. It's a way of saying that you want to match a pattern rather than a specific string (like the * and ? wild-cards from file-dialogs on steroids). In this case, we don't want to remove all whitespace, and not even every line-ending - a regular expression makes it possible to express "only a blank line and its line ending".
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: how to remove line jump/break with ruby
Thanks Trog: D
now it's working wonderfully,
I studied the code library of Ruby's official website and nothing worked for me, ¿ is there a specific book or dictionary for flowstone Ruby?
I had elaborated another method without ruby but it also inserts line breaks in the menu, but I think it can also be useful to someone so I will attach the scheme with the 2 elaborated methods:
There are 2 menus that have the function of inserting an element into the table Strings of favorites,
the first is with Ruby which eliminates the line breaks,
and the second is without ruby, using the logical components of fsm.
I hope this works, thanks again: D
now it's working wonderfully,
I studied the code library of Ruby's official website and nothing worked for me, ¿ is there a specific book or dictionary for flowstone Ruby?
I had elaborated another method without ruby but it also inserts line breaks in the menu, but I think it can also be useful to someone so I will attach the scheme with the 2 elaborated methods:
There are 2 menus that have the function of inserting an element into the table Strings of favorites,
the first is with Ruby which eliminates the line breaks,
and the second is without ruby, using the logical components of fsm.
I hope this works, thanks again: D
-
ErvSoft - Posts: 31
- Joined: Sun Jul 31, 2016 11:59 pm
- Location: Chile
Re: how to remove line jump/break with ruby
ErvSoft wrote:¿ is there a specific book or dictionary for flowstone Ruby?
Sadly not - and this presents a great difficulty for learning Ruby in FlowStone. The official User Guide only teaches the parts which are unique to FlowStone; we are expected to learn the remainder of Ruby elsewhere. However, many internet Ruby tutorials and examples do not work inside FlowStone, because "RubyEdit" primitives are not like typical "stand alone" Ruby programs. IMHO, it is best to learn the basics of Ruby outside of FlowStone, and afterwards to learn what is different about FlowStone. We try our best to help people on the forums, but it is a difficult place to teach and to learn a whole programming language.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 68 guests