Author Topic: Value formatting  (Read 3371 times)

Nikk

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Value formatting
« on: March 24, 2014, 05:35:59 pm »
Hi,

How can i get clean formatted value in last value window (or better as event parameter)? What I want to do is format or round disk space value.
The value shows up like 12.410000 , but it should be like 12.41 (as it shows in history table)  because transformation script is: format($1,1,2) or round($1,2).

And event parameter %4 is also taking those zeros. How can I get rid of those zeros?

Nikk

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 7015
    • View Profile
Re: Value formatting
« Reply #1 on: March 25, 2014, 07:32:10 pm »
Hi!

You can format event parameter using script, like this:

1. use %[formatted_p4] instead of %4

2. Create script named formatted_p4 in library like this:

return format($event->parameters[4], 1, 2);

Best regards,
Victor

Nikk

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Value formatting
« Reply #2 on: March 31, 2014, 10:09:41 am »
Thank you, Victor! Works great :)

Shebarn

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Value formatting
« Reply #3 on: December 10, 2019, 09:42:54 am »
I have the same problem with voltage return as float.

My Transformation looks like this normally:

return $1/10;

(since the value returned is always 10x the actual voltage value)

But this always gives me a value of i.e. 23.500000

return format($1/10, 1, 1) gives the right value when I test it at transformation but not when the alarm is raised.

I tried Victor's solution of script:

Script Name: retvolt
Script Content: return format($event->parameters[1]/10, 1, 1);

At transformation I then put: return $[retvolt];

I get error: Error 34 in line 1: Function or operation argument is not a container

I assume I am calling the script the wrong way, but can't find examples of how to do it otherwise?
Please help.
« Last Edit: December 10, 2019, 09:46:47 am by Shebarn »

Shebarn

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Value formatting
« Reply #4 on: December 10, 2019, 10:46:10 am »
Ok, figured it out.

Used the script in the message of the event's event configuration and it worked perfect...