<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cogniza &#187; Functions</title>
	<atom:link href="http://cogniza.com/wordpress/tag/functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://cogniza.com/wordpress</link>
	<description>Business-Intelligence Specialists</description>
	<lastBuildDate>Sat, 30 Apr 2011 13:22:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Crystal Reports: FractionToDecimal() Function</title>
		<link>http://cogniza.com/wordpress/2009/09/08/crystal-reports-fractiontodecimal-function/</link>
		<comments>http://cogniza.com/wordpress/2009/09/08/crystal-reports-fractiontodecimal-function/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 18:26:11 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=109</guid>
		<description><![CDATA[Converts a fractional value in the format of Numerator/Denominator or Whole + Numerator/Denominator to a decimal value.


//Assumes values in the following formats:
//99 - integer value
//99.9 - decimal value
//N/D - numerator/denominator
//M N/D - whole + numerator/denominator
Function (Stringvar value)
Local Numbervar whole := 0;
Local Stringvar fraction;
//
value := trim(value);
//integer or decimal format
If IsNumeric(value) Then
    ToNumber(value)
Else (
 [...]]]></description>
			<content:encoded><![CDATA[<p>Converts a fractional value in the format of Numerator/Denominator or Whole + Numerator/Denominator to a decimal value.<br />
<span id="more-109"></span><br />
<code><br />
//Assumes values in the following formats:<br />
//99 - integer value<br />
//99.9 - decimal value<br />
//N/D - numerator/denominator<br />
//M N/D - whole + numerator/denominator<br />
Function (Stringvar value)</p>
<p>Local Numbervar whole := 0;<br />
Local Stringvar fraction;</p>
<p>//<br />
value := trim(value);</p>
<p>//integer or decimal format<br />
If IsNumeric(value) Then<br />
    ToNumber(value)</p>
<p>Else (</p>
<p>    //whole + numerator/denominator<br />
    If InStr(value, " ")>0 Then (</p>
<p>        whole := ToNumber(Split(value, " ")[1]);<br />
        fraction := Split(value, " ")[2];</p>
<p>    )</p>
<p>    //numerator/denominator<br />
    Else (</p>
<p>        fraction := value;</p>
<p>    );</p>
<p>    Local Numbervar numerator := ToNumber(Split(fraction, "/")[1]);<br />
    Local Numbervar denominator := ToNumber(Split(fraction, "/")[2]);</p>
<p>    whole + (numerator / denominator);<br />
)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2009/09/08/crystal-reports-fractiontodecimal-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Array_PushEx() Function</title>
		<link>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_pushex-function/</link>
		<comments>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_pushex-function/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 20:26:20 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=105</guid>
		<description><![CDATA[Add a unique string value to an array of string values. Uses the delimiter to convert the value into an array.

Function (Stringvar Array Items, Stringvar Values, Stringvar Delimiter)
    Stringvar Array Temp:=Split(Values,Delimiter);
    Numbervar i;
    For i := 1 To Ubound(Temp) Do (
        If Array_Contains (Items, Temp[i]) = False Then (
            Redim Preserve Items[Ubound(Items)+1];
            Items[Ubound(Items)]:=Temp[i];
        );
    );
    [...]]]></description>
			<content:encoded><![CDATA[<p>Add a unique string value to an array of string values. Uses the delimiter to convert the value into an array.<span id="more-105"></span><br />
<code><br />
Function (Stringvar Array Items, Stringvar Values, Stringvar Delimiter)<br />
    Stringvar Array Temp:=Split(Values,Delimiter);<br />
    Numbervar i;<br />
    For i := 1 To Ubound(Temp) Do (<br />
        If Array_Contains (Items, Temp[i]) = False Then (<br />
            Redim Preserve Items[Ubound(Items)+1];<br />
            Items[Ubound(Items)]:=Temp[i];<br />
        );<br />
    );<br />
    Items;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_pushex-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Array_Contains() Function</title>
		<link>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_contains-function/</link>
		<comments>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_contains-function/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 20:16:34 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=103</guid>
		<description><![CDATA[Determines if a string value is contained in an array of strings.

Function (Stringvar Array Items, Stringvar Value)
     Numbervar i;
  Booleanvar flag:=False;
     If Ubound(Items)&#62;0 Then
      For i := 1 To Ubound(Items) Do (
            If Items[i]=Value Then (
                flag:=True;
                Exit For
            )
        )
    //End If
    ;
//return result
flag;

]]></description>
			<content:encoded><![CDATA[<p>Determines if a string value is contained in an array of strings.<br />
<span id="more-103"></span><code><br />
Function (Stringvar Array Items, Stringvar Value)<br />
     Numbervar i;<br />
  Booleanvar flag:=False;<br />
     If Ubound(Items)&gt;0 Then<br />
      For i := 1 To Ubound(Items) Do (<br />
            If Items[i]=Value Then (<br />
                flag:=True;<br />
                Exit For<br />
            )<br />
        )<br />
    //End If<br />
    ;<br />
//return result<br />
flag;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2008/01/09/crystal-reports-array_contains-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: CDateRange() Function</title>
		<link>http://cogniza.com/wordpress/2006/05/25/crystal-reports-cdaterange-function/</link>
		<comments>http://cogniza.com/wordpress/2006/05/25/crystal-reports-cdaterange-function/#comments</comments>
		<pubDate>Thu, 25 May 2006 12:55:17 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Crystal Reports]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=77</guid>
		<description><![CDATA[A Crystal Reports Custom Function to convert a string value into its equivalent Date Range.]]></description>
			<content:encoded><![CDATA[<p>Convert a string value into its equivalent Date Range.</p>
<p><span id="more-77"></span><code>Function (Stringvar dateRange)<br />
Select dateRange<br />
Case "Aged0To30Days" : Aged0To30Days<br />
Case "Aged31To60Days" : Aged31To60Days<br />
Case "Aged61To90Days" : Aged61To90Days<br />
Case "AllDatesFromToday" : AllDatesFromToday<br />
Case "AllDatesFromTomorrow" : AllDatesFromTomorrow<br />
Case "AllDatesToToday" : AllDatesToToday<br />
Case "AllDatesToYesterday" : AllDatesToYesterday<br />
Case "Calendar1stHalf" : Calendar1stHalf<br />
Case "Calendar1stQtr" : Calendar1stQtr<br />
Case "Calendar2ndHalf" : Calendar2ndHalf<br />
Case "Calendar2ndQtr" : Calendar2ndQtr<br />
Case "Calendar3rdQtr" : Calendar3rdQtr<br />
Case "Calendar4thQtr" : Calendar4thQtr<br />
Case "Last4WeeksToSun" : Last4WeeksToSun<br />
Case "Last7Days" : Last7Days<br />
Case "LastFullMonth" : LastFullMonth<br />
Case "LastFullWeek" : LastFullWeek<br />
Case "LastYearMTD" : LastYearMTD<br />
Case "LastYearYTD" : LastYearYTD<br />
Case "MonthToDate" : MonthToDate<br />
Case "Next30Days" : Next30Days<br />
Case "Next31To60Days" : Next31To60Days<br />
Case "Next61To90Days" : Next61To90Days<br />
Case "Next91To365Days" : Next91To365Days<br />
Case "Over90Days" : Over90Days<br />
Case "WeekToDateFromSun" : WeekToDateFromSun<br />
Case "YearToDate" : YearToDate<br />
Case "Yesterday" : CurrentDate-1 To CurrentDate-1<br />
Default: YearToDate </code></p>
<h3>Parameters</h3>
<dl>
<dt><em>dateRange</em></dt>
<dd>string equivalent of a Crystal Reports&#8217; Date Range.</dd>
</dl>
<h3>Return Value</h3>
<p>Date Range</p>
<h3>Remarks</h3>
<p>This function is useful when a report needs to provide a means to prompt on named date ranges, rather than a starting and ending date.  See <a href="http://www.cogniza.com/blog/?p=61" target="_new">Business Objects Enterprise: Create a dynamic list of date ranges</a> for an example.</p>
<h3>Example</h3>
<p><code>'converts the 'Date Range' parameter (a list of strings) to an actual Date Range.<br />
{Orders.OrderDate} IN CDateRange({?Date Range})<br />
</code></p>
<h3>Requirements</h3>
<p>This function requires the use of Crystal Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2006/05/25/crystal-reports-cdaterange-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: getLocalizedString() Function</title>
		<link>http://cogniza.com/wordpress/2006/05/14/crystal-reports-getlocalizedstring-function/</link>
		<comments>http://cogniza.com/wordpress/2006/05/14/crystal-reports-getlocalizedstring-function/#comments</comments>
		<pubDate>Mon, 15 May 2006 00:20:01 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Localization]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=54</guid>
		<description><![CDATA[getLocalizedString is a Crystal Reports Custom Function to used convert a constant to a localized string.]]></description>
			<content:encoded><![CDATA[<p>getLocalizedString is a Crystal Reports Custom Function to used convert a constant to a localized string.</p>
<p><span id="more-54"></span><code> //--------------------------------------------------------------------------------<br />
//Author:	Cogniza.com<br />
//Purpose:	Convert a constant value to a localized string<br />
//Parameters:	Key -<br />
//		Lang - ISO language string<br />
//Returns:	localized string<br />
//--------------------------------------------------------------------------------<br />
Function (Stringvar Key, Stringvar Lang)<br />
//define array of keys that are used by Formula fields<br />
Stringvar Array Keys:=["COUNTRY","REGION","CITY"];<br />
//define arrays of localized strings for each required language in the same position as the Key array<br />
Stringvar Array Values;<br />
Select Lang<br />
Case "en_US":	Values:=["Country","State","City"]<br />
Case "it_IT":	Values:=["Paese","Dichiari","Città"]<br />
Case "fr_FR":	Values:=["Pays","état","Ville"]<br />
Default:	    Values:=["Country","State","City"]<br />
//End Select<br />
;<br />
//iterate through Key array...<br />
Numbervar i;<br />
Stringvar value;<br />
for i := 1 To Ubound(Keys) do (<br />
//if value in array matches the specified value, return the value from the localized array<br />
if Keys[i] = Key then<br />
value:=Values[i];<br />
exit for<br />
//end if<br />
);<br />
//return result<br />
value;</code></p>
<h3>Parameters</h3>
<dl>
<dt><em>Key</em></dt>
<dd>The abstract value.</dd>
<dt><em>Lan</em></dt>
<dd>The ISO language string</dd>
</dl>
<h3>Return Value</h3>
<p>A string</p>
<h4>Remarks</h4>
<p>Crystal Reports XI introduces a new keyword named &#8216;ContentLocale&#8217;.  This property returns the  machine&#8217;s locale setting, usually found in the Control Panel&#8217;s Regional Settings (e.g. en_US for English (US)).  However, this keyword can only be used in formulae that are excuted during the report&#8217;s &#8216;Second Pass&#8217; (see <a href="http://www.cogniza.com/blog/?p=52">Crystal Reports: Report Processing Model</a>).  The following Record Selection Formuala, for example, will generate an error:</p>
<p><code> {my_table.localeName}=ContentLocale </code></p>
<p>ContentLocale can be used in combination with a Report Custom Function to dynamically and transparently apply localization settings when a report is viewed, even reports that have been saved with data or have been scheduled using Business Objects Enterprise.</p>
<h4>Example</h4>
<p><code> //if the workstation's ContentLocal is Italian (Italy), then the following will return 'Paese'<br />
getLocalizedString ("COUNTRY",ContentLocale)<br />
</code></p>
<h3>Requirements</h3>
<p>This function requires the use of Crytal Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2006/05/14/crystal-reports-getlocalizedstring-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: FirstMonday() Function</title>
		<link>http://cogniza.com/wordpress/2006/05/08/crystal-reports-firstmonday-function/</link>
		<comments>http://cogniza.com/wordpress/2006/05/08/crystal-reports-firstmonday-function/#comments</comments>
		<pubDate>Mon, 08 May 2006 16:30:15 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Date/Time]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=51</guid>
		<description><![CDATA[Finds the the first Monday in the current month.
Function FirstMonday (Value As Date) As Date
'first day of the specified month
Dim FirstOfMonth As Date
FirstOfMonth= DateValue(Year(Value), Month(Value), 1)
'Convert the first day to the Monday of the same week
Dim Monday As Date
Monday = FirstOfMonth + (2-DayOfWeek(FirstOfMonth))
'make sure Monday is still in the same month as the first day [...]]]></description>
			<content:encoded><![CDATA[<p>Finds the the first Monday in the current month.</p>
<p><span id="more-51"></span><code>Function FirstMonday (Value As Date) As Date<br />
'first day of the specified month<br />
Dim FirstOfMonth As Date<br />
FirstOfMonth= DateValue(Year(Value), Month(Value), 1)<br />
'Convert the first day to the Monday of the same week<br />
Dim Monday As Date<br />
Monday = FirstOfMonth + (2-DayOfWeek(FirstOfMonth))<br />
'make sure Monday is still in the same month as the first day of the month.  If not, adjust.<br />
If Month(Monday) &lt;&gt; Month(FirstOfMonth) Then Monday=Monday+7<br />
'return date<br />
FirstMonday=Monday<br />
End Function<br />
</code></p>
<h3>Parameters</h3>
<dl>
<dt><em>Value</em></dt>
<dd>The specified month.</dd>
</dl>
<h3>Return Value</h3>
<p>A date</p>
<h3>Remarks</h3>
<p>none</p>
<h3>Example</h3>
<p><code>'finds the first monday of the current month<br />
FirstMonday(CurrentDate)<br />
</code></p>
<h3>Requirements</h3>
<p>This function requires the use of Basic Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2006/05/08/crystal-reports-firstmonday-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: Pad() Function</title>
		<link>http://cogniza.com/wordpress/2006/05/08/crystal-reports-pad-function/</link>
		<comments>http://cogniza.com/wordpress/2006/05/08/crystal-reports-pad-function/#comments</comments>
		<pubDate>Mon, 08 May 2006 15:11:25 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=50</guid>
		<description><![CDATA[Adds the specific character to the left side of a value when the value is less than a comparison. Useful when converting a single-digit month or day to a string.]]></description>
			<content:encoded><![CDATA[<p>Adds the specific character to the left side of a value when the value is less  than a comparison. Useful when converting a single-digit month or day to a  string.</p>
<p><span id="more-50"></span><code>  Function Pad (Value As Number, Comparison As Number, Padding As String) As String</code></p>
<p>dim SPACE_CHARACTER: SPACE_CHARACTER=ChrW(32)</p>
<p>If Value<br />
Pad=Replace(Space(Len(CStr(Comparison,0))-Len(CStr(Value,0))), SPACE_CHARACTER, Padding) &amp; CStr(Value,0)<br />
Else<br />
Pad=CStr(Value,0)<br />
End If</p>
<p>End Function</p>
<h3>Parameters</h3>
<dl>
<dt><em>Value</em></dt>
<dd>value to be padded.</dd>
<dt><em>Comparison</em></dt>
<dd>value compared to this number.</dd>
<dt><em>Padding</em></dt>
<dd>character used to pad the value.</dd>
</dl>
<h3>Return Value</h3>
<p>A string.</p>
<h3>Remarks</h3>
<p>none</p>
<h3>Example</h3>
<p><code> 'returns "09"<br />
Pad (9, 10, "0")</code></p>
<p>&#8216;returns &#8220;11&#8243;<br />
Pad (11, 10, &#8220;0&#8243;)</p>
<h3>Requirements</h3>
<p>This function requires the use of Basic Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2006/05/08/crystal-reports-pad-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: ElapsedTime() Function</title>
		<link>http://cogniza.com/wordpress/2005/11/29/crystal-reports-elapsedtime-function/</link>
		<comments>http://cogniza.com/wordpress/2005/11/29/crystal-reports-elapsedtime-function/#comments</comments>
		<pubDate>Tue, 29 Nov 2005 19:52:18 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Date/Time]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=31</guid>
		<description><![CDATA[Converts a number of seconds into a string in the format of days.hours:minutes:seconds.]]></description>
			<content:encoded><![CDATA[<p>Converts a number of seconds into a string in the format of days.hours:minutes:seconds.</p>
<p><span id="more-31"></span> <code> Function (NumberVar interval)<br />
NumberVar Days := Truncate(interval / 86400);<br />
NumberVar Hours := Truncate(Remainder(interval, 86400) / 3600);<br />
NumberVar Minutes := Truncate(Remainder(interval, 3600) / 60);<br />
NumberVar Seconds := Remainder(interval, 60);<br />
Totext(Days,'##') +'.'+ Totext(Hours,'00') +':'+ Totext(Minutes,'00') +':'+ Totext(Seconds,'00')<br />
</code></p>
<h3>Parameters</h3>
<dl>
<dt><em>interval</em></dt>
<dd>The number of seconds to be converted.</dd>
</dl>
<h3>Return Value</h3>
<p>A string in the format of days.hours:minutes:seconds</p>
<h3>Remarks</h3>
<p>none</p>
<h3>Example</h3>
<p><code> //returns 0.00:02:12<br />
ElapsedTime(132)</code></p>
<p><code>//formats the difference between two datetime values.<br />
ElapsedTime ((CurrentDateTime-DateTime(2006,1,1,0,0,0))*86400)</code></p>
<p><code>//formats the difference between two datetime values.<br />
ElapsedTime (DateDiff("s", {TABLE.FIELD}, CurrentDateTime))</code></p>
<h3>Requirements</h3>
<p>This function requires the use of Crystal Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2005/11/29/crystal-reports-elapsedtime-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crystal Reports: ShellSort() Function</title>
		<link>http://cogniza.com/wordpress/2005/11/07/crystal-reports-shellsort/</link>
		<comments>http://cogniza.com/wordpress/2005/11/07/crystal-reports-shellsort/#comments</comments>
		<pubDate>Mon, 07 Nov 2005 14:57:12 +0000</pubDate>
		<dc:creator>Craig Buchanan</dc:creator>
				<category><![CDATA[Business Objects Enterprise]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Business Objects]]></category>

		<guid isPermaLink="false">http://www.cogniza.com/blog/?p=27</guid>
		<description><![CDATA[Sort an array of numbers using the Shell sort algorythm.]]></description>
			<content:encoded><![CDATA[<p>Sort an array of numbers using the Shell sort algorythm.  This sorting algorythm will quickly sort arrays in Crystal Reports.</p>
<p><span id="more-27"></span>  <code> Function ShellSort(Values() As Number)<br />
</code></p>
<blockquote><p>&#8216;exit if array has no elements<br />
If Ubound(Values)=0 Then Exit Function</p>
<p>&#8216;account for optional arguments<br />
Dim LastElement As number<br />
LastElement = UBound(Values)</p>
<p>&#8216;Crystal Reports&#8217; arrays are 1-based.<br />
Dim FirstElement As Number<br />
FirstElement = 1</p>
<p>Dim Elements As Number<br />
Elements = LastElement &#8211; FirstElement + 1</p>
<p>&#8216;find the best value for distance<br />
Dim distance As Number<br />
Do</p></blockquote>
<blockquote><p>distance = distance * 3 + 1</p></blockquote>
<p>Loop Until distance &gt; Elements</p>
<p>Dim temp as number<br />
Dim index As Number, index2 As Number</p>
<p>Do</p>
<blockquote><p>distance = distance \ 3<br />
For index = distance + FirstElement To LastElement</p></blockquote>
<blockquote><p>temp = Values(index)<br />
index2 = index</p>
<p>Do While (Values(index2 &#8211; distance) &gt; temp)</p></blockquote>
<blockquote><p>Values(index2) = Values(index2 &#8211; distance)<br />
index2 = index2 &#8211; distance<br />
If index2 &#8211; distance &lt; FirstElement Then Exit Do</p></blockquote>
<p>Loop</p>
<p>Values(index2) = temp</p>
<p>Next<br />
Loop Until distance = 1</p>
<p>ShellSort=Values<br />
End Function</p>
<h2>Parameters</h2>
<dl>
<dt><em>Values</em></dt>
<dd>An array of numbers.</dd>
</dl>
<h2>Return Value</h2>
<p>A sorted array of numbers</p>
<h2>Remarks</h2>
<p>Arrays in Crystal Reports are limit to 1000 elements.</p>
<h2>Example</h2>
<p>//create an array of numbers<br />
Numbervar Array numbers:=[44,2,77,4,9,1,0,55,3];</p>
<p>//sort the array<br />
numbers:=ShellSort(numbers);</p>
<p>//returns 0,1,2,3,4,9,44,55,77,<br />
numbervar i;</p>
<p>stringvar t;<br />
for i := 1 to ubound(numbers) do</p>
<blockquote><p>t:=t &amp; cstr(numbers[i],0) &amp; &#8220;,&#8221;;</p></blockquote>
<p>t;</p>
<h2>Requirements</h2>
<p>This function requires the use of Basic Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://cogniza.com/wordpress/2005/11/07/crystal-reports-shellsort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

