Print Page | Close Window

how to bring and at the end of the series

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=12596
Printed Date: 28 Apr 2024 at 12:03am


Topic: how to bring and at the end of the series
Posted By: jason stratom
Subject: how to bring and at the end of the series
Date Posted: 13 Mar 2011 at 7:17pm
Hi all,

How to bring an "and" at the end of a series.

Ex.1,2,3,4,5,6 and 7

Actually i brought comma between the numbers in a series .output 1,2,3,4,5,6,7



Replies:
Posted By: Keikoku
Date Posted: 14 Mar 2011 at 3:44am
What is your input? An array of numbers? A string of numbers separated by a common delimiter?

Whatever the case is, let us suppose you manage to get an array of numbers represented by strings

ie: ["1", "2", "3"] (if they're not strings, you will have to convert them to string when you're concatenating them)


local stringvar array myList := {whatever input};
local stringvar outList := '';
local numbervar tempLen := count(myList)
local numbervar i;
for i := 1 to tempLen - 1 Do
   outList := outList & myList & ","
outList := outList & "and " & myList[tempLen]


So given n numbers, you would concatenate your first n - 1 numbers together each followed by a comma + space, and you would treat your last number differently with a preceding "and"



Print Page | Close Window