Graphics

 View Only
  • 1.  Rounding percents from Inception

    Posted 05-08-2014 20:35
    Hey yall,

    I was wondering if anyone had a script that can round the percents I am receiving from Inception to whole numbers. As it is I am getting decimals, which wont fit my graphic.

    Thanks,

    Ross


  • 2.  RE: Rounding percents from Inception

    Posted 05-10-2014 02:22
    Try this in OnSetText (note I haven't tried it myself)..

    Text = CStr(Round(CSng(Text)))

    #XPression


  • 3.  RE: Rounding percents from Inception

    Posted 05-12-2014 23:00
    Thanks for the script Brian,

    Dang, got:

    5,0: BC30451 Name 'Round' is not declared.

    there a way to declare it?

    #XPression


  • 4.  RE: Rounding percents from Inception

    Posted 05-13-2014 01:29
    Sorry use this:

    text = cstr(math.round(csng(text)))

    #XPression


  • 5.  RE: Rounding percents from Inception

    Posted 05-13-2014 01:58
    This works!!!

    You're the man Brian!!

    Thank you so much!!

    #XPression


  • 6.  RE: Rounding percents from Inception

    Posted 12-10-2015 15:04
    I'm trying to do something similar to this.

    I've got a Datalinq source that is returning stock changes as a percentage, but the percentage will sometimes be returned to a 3rd or 4th decimal place. I only ever want the first two decimals (without rounding preferably) as I have no room for so many decimals. I've gotten this to work with numbers that aren't percentages before using FormatNumber. Percentages seem to, understandably, act differently.
    #XPression


  • 7.  RE: Rounding percents from Inception

    Posted 12-10-2015 15:36
    You probably need to strip off the percent sign before passing it to FormatNumber, then just append the percent sign back on at the end.

    You could do something like text=Replace(text,"%","") to replace the % sign with nothing.. Then format the number as you normally do, then do text=text & "%" to add the percent sign back on.

    #XPression


  • 8.  RE: Rounding percents from Inception

    Posted 12-10-2015 16:05

    Yep was just about to add that a little more tooling around and I arrived in the same place. Thanks for the help Brian.

     

    text = Replace(text, "%", "")
    
    if cDbl(text) >= "0" then
    text = "{ChangePos}" & "+" & FormatNumber(Text, 2) & "%"
      else
    text = "{ChangeNeg}" & FormatNumber(Text, 2) & "%"
      end if

    #XPression