Caché Basic Reference
String
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Returns a repeating character string of the length specified.
Synopsis
String(length,character)
Arguments
length A positive integer specifying the length of the generated string. A zero length returns an empty string; a negative length returns no value. Fractional numbers are truncated.
character Character code specifying the character, or a string expression whose first character is used to build the return string.
Description
The String function returns a string consisting of a single repeated character; length specifies the number of times to repeat the character. Use the Space function to return a string consisting of blank spaces.
A character code value must evaluate to a positive integer in the range 0 to 255 (inclusive). If you specify a character code for character greater than 255, String converts the number to a character code in the range 0 through 255 using the formula:
character Mod 256
For 16-bit characters, you can use the Chr function, as shown in the example below.
Examples
The following example uses the String function to return repeating character strings of the length specified:
Println String(5,"*")       ' Returns "*****".
Println String(5,42)        ' Returns "*****".
Println String(10,"ABC")    ' Returns "AAAAAAAAAA".
 
The following example uses character code values and the Chr function to specify the repeating character. Note that you must use the Chr function for character codes beyond 255.
Println String(10,65)       ' Returns "AAAAAAAAAA"
Println String(10,321)      ' Returns "AAAAAAAAAA"
Println String(10,577)      ' Returns "AAAAAAAAAA"
Println String(5,Chr(960))  ' Returns five pi symbols
 
See Also