Using Script functions on aggregate functions

Hi,

I need help on the following issue :

I have a data band with 3 elements such as : a GroupHeader, a MasterData and a GroupFooter.

The MasterData uses a dataset containing multiple entries. One of the fields is a duration in seconds. As this this duration is unreadable, I made a small function in the script (made in Pascalscript). This function takes the duration as a parameter and does a series of calculations to return a more readable string.

Using this function in a memo in the MasterData, the duration is converted on the fly and works as expected.

About the GroupFooter, it is used to display aggregated data of these multiple durations.

However, I cannot use this function in the GroupFooter as one of the memos contains the sum of the fields (duration) mentionned above. So I have something looking like this : [secondsToFormatedDuration([SUM(<groupOfData."duration", MasterData1)])]. As the SUM() function returns an Array Variant object, I am unable to convert it to an integer in order to use it as a parameter for the secondsToFormatedDuration() function. In the pascalscript code, nothing has succeeded to either convert it by using a cast, or using methods of the variant. Maybe this is not the way to do it? How can I still format the duration amount to a human readable format for the entries and the aggregate?


What am I missing on?

example of the script :

function secondsToFormatedDuration( sec : integer ) : String;
var
      h,m,s : integer;
      str : String;
begin
      h := sec div 3600;
      m := (sec mod 3600) div 60;
      s := sec mod 60;
      str := Format('%.2d:%.2d:%.2d', [h,m,s]);
      result := str;
end;

Main page structure :

The value that works : (third column of the MasterData)

[secondsToFormatedDuration(<getAllStateTopsBetweenDates."topdurationfield">)]

The value that doesnt work : (third column of the GroupFooter)

[secondsToFormatedDuration([SUM(<getAllStateTopsBetweenDates."topdurationfield">,MasterData1)])]

Comments

  • Found the issue, as I wrote above, for whatever reason the SUM function returns a Array of variant instead of a variant. Using the first element of the array (duration[0]) returns the integer.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.