rounding

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
paranova9
Newbie
Posts: 17
Joined: Wed Jul 29, 2009 9:19 pm

rounding

Post by paranova9 » Sun Oct 17, 2010 10:36 am

sorry if this is right in front of my nose, but how do I round numbers? or maybe specify to cut off decimals?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sun Oct 17, 2010 12:02 pm

Try this.

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

VBStart
VBEND


//Round(expression[,numdecimalplaces])
//Parameter              Description
//------------------------------------------------------------------------------
//expression              Required. The numeric expression to be rounded
//numdecimalplaces  Optional. Specifies how many places to the right
//                             of the decimal are included in the rounding.
//                             Default is 0

Let>mynum=5.06
VBEval>Round("%mynum%","1"),result
MessageModal>%result%


paranova9
Newbie
Posts: 17
Joined: Wed Jul 29, 2009 9:19 pm

Post by paranova9 » Mon Oct 18, 2010 4:35 am

thanks, I made this too for cutting off decimals, it can be modified to round too. I just don't understand why common math functions are so difficult to get to in macrosheduler; I've also had to build my own factorial script too; so frustrating to do that when one ! is all I want

teach a man to fish: I know nothing of vb, is there an easy way to get an explanation and list of common formulas ... or something?

Code: Select all

Position>.,d,1,StartPos
sub>StartPos,1
MidStr>d,1,StartPos,somevalue

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Mon Oct 18, 2010 1:00 pm

VBScript Functions
http://www.w3schools.com/VBscript/vbscr ... ctions.asp



Google can probably dig up quite a few more good references as well.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Oct 18, 2010 1:02 pm

Rounding made easy.

One line, no VBScript, using built in Macro Scheduler functionality

Code: Select all

Let>number=123.12345
Let>roundednumber={round (%number%)}

One line, no VBScript, using built in Macro Scheduler functionality to round to three decimal places.

Code: Select all

Let>number=123.12345
Let>rounded3number={(round (1000*%number%))/1000}
See http://www.mjtnet.com/OnlineHelp/arithm ... ctions.htm for more built in math functions.

paranova9
Newbie
Posts: 17
Joined: Wed Jul 29, 2009 9:19 pm

Post by paranova9 » Mon Oct 18, 2010 1:39 pm

wow JRL how did you figure that one out?

thanks again adroege :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts