Quote:
Originally Posted by Pyjam
I would like to add a column: a duration (format h:mm) that is the number of words (#words) divided by 300 in minutes.
Could you help me. Thank you.
|
What you want to do pushes the template language to its limits. It isn't designed to do complicated floating point arithmetic such as floor and round, and it doesn't have the notion of "duration".
That said, the following
General Program Mode (GPM) template works for me. Since we don't have the duration type we must calculate the parts manually. Since we don't have the "floor" function, the template does the equivalent with string processing to chop off the fractional part from "hours". Fortuitously the number formatter does rounding so we don't need to do that manually when calculating the total minutes as an integer.
Code:
program:
total = format_number(divide(raw_field('#words'), 300), '{0:.0f}');
hours = re(divide(total, 60), '\..*', '');
minutes = subtract(total, multiply(hours, 60));
strcat(hours, ':', format_number(minutes, '{0:02d}'))
For template function documentation see
Reference for all built-in template language functions