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

Encloses a value in single quotation marks.
Synopsis
SQUOTE(string)
Arguments
string An expression that resolves to a string or a number. string may be a dynamic array.
Description
The SQUOTE function returns string enclosed in single quotation marks. The quotation marks are part of the resulting string. Therefore, using SQUOTE increases the length of string by 2 characters. If string is the null string, SQUOTE returns a string consisting of two single quotation mark characters, a string with a length of 2. This should not be confused with the null string, which has a length of 0.
The SQUOTE function converts a numeric to canonical form before enclosing it in quotation marks. SQUOTE does not convert a numeric string to canonical form.
The SQUOTE function encloses string with single quotation marks. The similar QUOTE and DQUOTE functions enclose string with double quotation marks.
Note:
Some MultiValue Basic implementations (D3, for example) use SQUOTE and DQUOTE to extract quoted substrings from within a string. The Caché MVBasic quote functions do not support this functionality. Use the FIELD function or the [ ] operator to extract quoted substrings.
Examples
The following example uses the SQUOTE function to convert a numeric to a string enclosed in single quotation marks:
quoted = SQUOTE(+007.000)
PRINT quoted;            ! Returns '7'
PRINT LEN(quoted);       ! Returns 3
The following example uses the SQUOTE function to enclose a string in single quotation marks:
str1 = "Hello"
str2 = 'Hello'
str3 = \Hello\
PRINT str1:str2:str3;  ! Returns HelloHelloHello
PRINT LEN(str1),LEN(str2),LEN(str3);  ! Returns 5   5   5
q1 = SQUOTE(str1)
q2 = SQUOTE(str2)
q3 = SQUOTE(str3)
PRINT q1:q2:q3;       ! Returns 'Hello''Hello''Hello'
PRINT LEN(q1),LEN(q2),LEN(q3);    ! Returns 7    7    7
See Also