yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
StaticMethod ChompText (
  String text_i
) const declarative remote as String
{
  Description: 'Limits feedback by fixed number of characters'
  TextBody:
  [*
    output := text_i;
    maxLength := SCK_FeedbackBuilder::GetMaxFeedbackLength();
    maxLines := SCK_FeedbackBuilder::GetMaxFeedbackLines();
    
    // Chomp by number of characters
    if( text_i.Length() > SCK_FeedbackBuilder::GetMaxFeedbackLength() )
    {
      output := text_i.SubString( 0, maxLength ) + SCK_FeedbackBuilder::FeedbackOverflowTerminator();
    }
    
    // In the case that there are a lot of short sentences, also chomp by lines
    lines := text_i.Tokenize( String::NewLine() );
    if( lines.Size() > maxLines )
    {
      keepLines := construct( Strings );
      for( i := 0; i < maxLines - 1; i++ ) 
      {
        keepLines.Add( lines.Element( i ) );
      }
      keepLines.Add( SCK_FeedbackBuilder::FeedbackOverflowTerminator() );
      
      output := keepLines.ToString( String::NewLine() );
    }
    
    return output;
  *]
}