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

how to remove line jump/break with ruby

For general discussion related FlowStone

how to remove line jump/break with ruby

Postby ErvSoft » Mon Jan 04, 2021 3:20 am

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):
Image


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 78 times
User avatar
ErvSoft
 
Posts: 30
Joined: Sun Jul 31, 2016 11:59 pm
Location: Chile

Re: how to remove line jump/break with ruby

Postby trogluddite » Mon Jan 04, 2021 5:03 am

This line of Ruby code should do what you want. It removes only the empty lines from a multi-line string...
Code: Select all
output @in.gsub(/^\s*$/, "")

Yes, I know - it looks like it should be a syntax error in any sensible coding language! :lol:

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!
User avatar
trogluddite
 
Posts: 1706
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: how to remove line jump/break with ruby

Postby ErvSoft » Fri Jan 15, 2021 5:00 pm

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:

ErvSoft - Favorites Menu (Other method).fsm
Favorites Menus with Ruby and without Ruby
(32.55 KiB) Downloaded 58 times


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
User avatar
ErvSoft
 
Posts: 30
Joined: Sun Jul 31, 2016 11:59 pm
Location: Chile

Re: how to remove line jump/break with ruby

Postby trogluddite » Fri Jan 15, 2021 9:55 pm

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!
User avatar
trogluddite
 
Posts: 1706
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK


Return to General

Who is online

Users browsing this forum: No registered users and 18 guests