expressions: Implement the REPLACE string function.
[pspp] / doc / expressions.texi
index 1570d0dfb437ce72072a677b52898484534395cd..b7e23a5f96c3d0721a4614832a09292a47bd67e9 100644 (file)
@@ -264,7 +264,7 @@ The sections below describe each function in detail.
 * Set Membership::              ANY RANGE
 * Statistical Functions::       CFVAR MAX MEAN MIN SD SUM VARIANCE
 * String Functions::            CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER 
-                                RINDEX RPAD RTRIM STRING SUBSTR UPCASE
+                                REPLACE RINDEX RPAD RTRIM STRING SUBSTR UPCASE
 * Time and Date::               CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
                                 DATEDIFF DATESUM
 * Miscellaneous Functions::     LAG YRMODA VALUELABEL
@@ -331,9 +331,13 @@ Returns the remainder when @var{number} is divided by 10.  If
 @end deftypefn
 
 @cindex rounding
-@deftypefn {Function} {} RND (@var{number})
-Takes the absolute value of @var{number} and rounds it to an integer.
-Then, if @var{number} was negative originally, negates the result.
+@deftypefn {Function} {} RND (@var{number} [, @var{mult}[, @var{fuzzbits}]])
+Rounds @var{number} and rounds it to a multiple of @var{mult} (by
+default 1).  Halves are rounded away from zero, as are values that
+fall short of halves by less than @var{fuzzbits} of errors in the
+least-significant bits of @var{number}.  If @var{fuzzbits} is not
+specified then the default is taken from SET FUZZBITS (@pxref{SET
+FUZZBITS}), which is 6 unless overridden.
 @end deftypefn
 
 @cindex truncation
@@ -616,8 +620,17 @@ right-padded with spaces.  If @var{string} is not in the correct
 format for @var{format}, system-missing is returned.
 @end deftypefn
 
+@cindex strings, replacing substrings
+@cindex replacing substrings
+@deftypefn {Function} {} REPLACE (@var{haystack}, @var{needle}, @var{replacement}[, @var{n}])
+Returns string @var{haystack} with instances of @var{needle} replaced
+by @var{replacement}.  If nonnegative integer @var{n} is specified, it
+limits the maximum number of replacements; otherwise, all instances of
+@var{needle} are replaced.
+@end deftypefn
+
 @cindex strings, searching backwards
-@deftypefn {Function} {} RINDEX (@var{string}, @var{format})
+@deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle})
 Returns a positive integer indicating the position of the last
 occurrence of @var{needle} in @var{haystack}.  Returns 0 if
 @var{haystack} does not contain @var{needle}.  Returns system-missing if
@@ -630,7 +643,7 @@ Searches @var{haystack} for the last occurrence of each part, and
 returns the largest value.  Returns 0 if @var{haystack} does not contain
 any part in @var{needle}.  It is an error if @var{needle_len} does not
 evenly divide the length of @var{needle}.  Returns system-missing
-if @var{needle} is an empty string.
+if @var{needle} is an empty string or if needle_len is less than 1.
 @end deftypefn
 
 @cindex padding strings