Item11807: Add lastseparator to FORMATLIST.

pencil
Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: FilterPlugin
Branches: trunk
Reported By: OliverKrueger
Waiting For:
Last Change By: MichaelDaum
Request permission to checkin. smile

Index: Core.pm
===================================================================
--- Core.pm   (Revision 15047)
+++ Core.pm   (Arbeitskopie)
@@ -518,6 +518,7 @@
   my $theFooter = $params->{footer} || '';
   my $theSplit = $params->{split};
   my $theSeparator = $params->{separator};
+  my $theLastSeparator = $params->{lastseparator};
   my $theLimit = $params->{limit};
   my $theSkip = $params->{skip} || 0; 
   my $theSort = $params->{sort} || 'off';
@@ -547,6 +548,7 @@
   #writeDebug("theFormat='$theFormat'");
   #writeDebug("theSplit='$theSplit'");
   #writeDebug("theSeparator='$theSeparator'");
+  #writeDebug("theLastSeparator='$theLastSeparator'");
   #writeDebug("theLimit='$theLimit'");
   #writeDebug("theSkip='$theSkip'");
   #writeDebug("theSort='$theSort'");
@@ -680,7 +682,14 @@
     return '' unless $theNullFormat;
     $result = $theNullFormat;
   } else {
-    $result = join($theSeparator, @result);
+    if (defined( $theLastSeparator ) && ($count > 1)) {
+      my @tempResult = @result;
+      my $lastElement = pop( @tempResult );
+      $result = join($theSeparator, @tempResult);
+      $result .= $theLastSeparator . $lastElement;
+    } else {
+      $result = join($theSeparator, @result);
+    }
   }
 
   $result = $theHeader.$result.$theFooter;

Usecase

FORMATLIST{"Peter,Paul,Mary" separator=", " lastseparator=" and "}
expands to Peter, Paul and Mary.

-- OliverKrueger - 30 Apr 2012

works for most languages

-- ArthurClemens - 19 Jun 2012

I know, Klingon is different. wink

-- OliverKrueger - 19 Jun 2012
 
Topic revision: r6 - 19 Jun 2012, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy