[size=18]My report always need an integer value from a function call.
Thats why I wrote the f_int to make my life easier. ~ patricko [/size]
/tmp/patch-reportit-function.20091218.diff
+++ cc_measurands.php 2009-12-18 19:48:40.000000000 +0800
@@ -435,6 +435,14 @@
desc[13]["description"] = "Sum of NaN's during the reporting period. It's <b>NOT</b> differentiated in data sources!";
desc[13]["example"] = 'nan';
+ desc[14] = new Object();
+ desc[14]["name"] = "f_int";
+ desc[14]["params"] = '$var: float or string value';
+ desc[14]["syntax"] = "<i>integer</i> f_int <i>(int $var)</i>";
+ desc[14]["description"] = "returns any given float, string as integer by patricko.";
+ desc[14]["example"] = '<table><tr><td width="75" align="left">-->decimal:<br>-->returns:</td>'
+ + '<td align="left">f_int(69.69)<br>69</td></tr></table>';
+
function add_to_calc(name) {
fieldId = document.getElementById('measurand_formula');
old = fieldId.value;
--- lib_int/funct_calculate.php.orig.20091216 2009-12-18 12:21:40.000000000 +0800
+++ lib_int/funct_calculate.php 2009-12-18 19:43:55.000000000 +0800
@@ -149,6 +149,19 @@
return $p_cache['f_dot'];
}
+//Rounding to integer value
+function f_int(&$array, &$p_cache, $threshold) {
+
+ if(empty($array)) {
+ $p_cache['f_dot'] = REPORTIT_NAN;
+ return $p_cache['f_int'];
+ }
+
+ $intvalue = round($threshold);
+
+ $p_cache['f_int'] = $intvalue;
+ return $p_cache['f_int'];
+}
/* ----- Main function for calculating ----- */
@@ -275,4 +288,4 @@
return $result;
}
-?>
\ No newline at end of file
+?>
--- lib_int/const_measurands.php.orig.20091218 2009-12-18 12:32:44.000000000 +0800
+++ lib_int/const_measurands.php 2009-12-18 18:55:17.000000000 +0800
@@ -38,7 +38,8 @@
'Example: f_dot(10000000)',
'f_sot' => 'Returns the sum of values over a defined threshold.
'.
'Description: float f_sot(float $variable)
'.
- 'Example: f_sot(750000)');
+ 'Example: f_sot(750000)',
+ 'f_int' => 'Returns float as integer');
$calc_fct_names_params = array_keys($calc_functions_params);
$calc_operators = array('+' => 'Addition',
@@ -61,4 +62,4 @@
$rounding = array('off', 'Binary SI-Prefixes (Base 1024)', 'Decimal SI-Prefixes (Base 1000)');
//-----------------------------------------
-?>
\ No newline at end of file
+?>
reportit plugin - added new function, (int) f_int (float)
Moderators: Developers, Moderators
reportit plugin - added new function, (int) f_int (float)
- Attachments
-
- patch-reportit-function.20091218.txt
- the diff file
- (2.32 KiB) Downloaded 339 times
- browniebraun
- Developer
- Posts: 791
- Joined: Tue Jun 13, 2006 1:17 am
- Location: Cologne, Germany
Great! I will definitely add this to main. Well done!
Best regards
-Andreas-
PS: Happy Holidays!!! My ADSL account is working again since 10 minutes .... after a long time of waiting.
Best regards
-Andreas-
PS: Happy Holidays!!! My ADSL account is working again since 10 minutes .... after a long time of waiting.
Hat das Blümchen einen Knick, war der Schmetterling zu dick!
reportit v0.7.5a
SNMPAgent v0.2.3
Download ReportIt | Download SNMPAgent | ReportIt SVN | ReportIt Templates | Wish list
reportit v0.7.5a
SNMPAgent v0.2.3
Download ReportIt | Download SNMPAgent | ReportIt SVN | ReportIt Templates | Wish list
Who is online
Users browsing this forum: No registered users and 4 guests