hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Quintiq file version 2.0
#parent: #root
StaticMethod CountStrings (const constcontent Strings strings) const as String
{
  Description: 'Create a single string that shows how many times each of the different strings in the input occur.'
  TextBody:
  [*
    value := '';
    
    if( strings.Size() > 0 )
    {
      sorted := selectsortedset( strings, Elements, str, true, str );
      prev := sorted.Element( 0 );
      count := 0;
      
      result := construct( Strings );
      traverse( sorted, Elements, string )
      {
        if( string = prev )
        {
          count++;
        }
        else
        {
          result.Add( Translations::LibOpt_Utility_CountString( prev, count ) );
          count := 1;
          prev := string;
        }
      }
      result.Add( Translations::LibOpt_Utility_CountString( prev, count ) );
      
      value := result.ToString( ', ' );
    }
    
    return value;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}