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

Reducing floats to cents to display

For general discussion related FlowStone

Reducing floats to cents to display

Postby CoreStylerz » Thu Jun 12, 2014 12:58 am

I want to reduce the output display of knob values.
I tried with string extract but to works also with negative values i have to use logic.
Is possibile to do such things with string format primitive.
Since i want values like 0,00 and -0,00

Any help?
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
User avatar
CoreStylerz
 
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy

Re: Reducing floats to cents to display

Postby KG_is_back » Thu Jun 12, 2014 5:25 am

This is implemented in float label in synthmaker. If you have it copy it from there...

the specification string looks something like this: number for example 5.468464
%.2f - rounds number to two decimal places - example: "5.47"
%8.2f - displays 8 chars (padded with spaces) with two decimal places - example: " 5.47" (notice the 4 spaces before the 5... decimal dot is consider a char too)
%08.2f - displays 8 chars (padded with zeroes) with two decimal places - example: "00005.47"
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Reducing floats to cents to display

Postby CoreStylerz » Thu Jun 12, 2014 10:56 am

Ty, i've downloaded back synthmaker. ;)
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
User avatar
CoreStylerz
 
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy

Re: Reducing floats to cents to display

Postby tester » Thu Jun 12, 2014 1:40 pm

...and you use format string primitive for that (or ruby), connected to label via string connector. Trog wrote here sometime ago how to format values in ruby boxes (format defs can be provided from outside). Search the forum here or via google (since searching isn't/wasn't working correctly) - keywords like format string array.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Reducing floats to cents to display

Postby CoreStylerz » Thu Jun 12, 2014 2:53 pm

With ruby should be easy, i've use the old module it works good. ;)
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
User avatar
CoreStylerz
 
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy

Re: Reducing floats to cents to display

Postby Nubeat7 » Thu Jun 12, 2014 7:34 pm

its about the same in ruby..
Code: Select all
val_string = "%0.2f"%@value.to_s
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Reducing floats to cents to display

Postby CoreStylerz » Fri Jun 13, 2014 12:24 am

Ty nubeat,
The primite works but seems to be buggy and unstable. It's stable but if i put some wrong tags it crashes flowstone... :o
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
User avatar
CoreStylerz
 
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy

Re: Reducing floats to cents to display

Postby tester » Fri Jun 13, 2014 12:59 am

1) Put right tags into string primitive.
2) Connect the string primitive to format prim.
3) Make a module and add to the toolbox.

Usually you will use always the same stuff, maybe different numbers.

Format prim was always crashing (also synthmaker) when connected to bad tags. But if using correct tags - it works fine.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Reducing floats to cents to display

Postby CoreStylerz » Fri Jun 13, 2014 1:55 am

tester wrote:1) Put right tags into string primitive.
2) Connect the string primitive to format prim.
3) Make a module and add to the toolbox.

Usually you will use always the same stuff, maybe different numbers.

Format prim was always crashing (also synthmaker) when connected to bad tags. But if using correct tags - it works fine.

thanks
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
User avatar
CoreStylerz
 
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy

Re: Reducing floats to cents to display

Postby billv » Fri Jun 13, 2014 6:37 am

Would "round" help here...
Code: Select all
1.234567.round(2)  #=> 1.23
1.234567.round(3)  #=> 1.235
1.234567.round(4)  #=> 1.2346
1.234567.round(5)  #=> 1.23457

http://ruby-doc.org/core-2.1.2/Float.html
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia


Return to General

Who is online

Users browsing this forum: No registered users and 94 guests