Xbasic

S_QUOTE Function

Syntax

Quoted_String as C = S_QUOTE(C string[,useLongString as l[,C longStringDelimiter]])

Quoted_String as C = S_QUOTE( Variable as C [, LongStringFormat as L ] )

Quoted_String as C = S_QUOTE( Variable as D [, LongStringFormat as L ] )

Quoted_String as C = S_QUOTE( Variable as L [, LongStringFormat as L ] )

Quoted_String as C = S_QUOTE( Variable as N )

Arguments

Quoted_String

A properly quoted string suitable for use in an expression.

string

A variable of type character, date, logical, or numeric.

useLongString

Logical. Optional. Default = .F. for character strings not containing CR-LF sequences and for logical variables. .T. = Wraps character data in and converts logical values to .T. or .F..

longStringDelimiter

Character

Description

Special quote. Quotes char values, makes logical values into ".T." or ".F.", puts date values in curly braces.

Discussion

The S_QUOTE() function properly quotes variables so they can be used in expressions. Note : Do not use S_QUOTE() in HTML expressions. It escapes quote characters in a manner inconsistent with HTML coding requirements.

Example

d = date()
m = .t.
n = 5
c = "Ed"
? s_quote(d)
= {06/22/2004}
? s_quote(n)
= 5
filter = "date = " + s_quote(d) + " .and. age = " + s_quote(n) + " .and. name = " + s_quote(c) + " .and. married = " + s_quote(m)
? filter
= date = {06/22/2004} .and. age = 5 .and. name = "Ed" .and. married = .t.

If the type of data that you are quoting is a character variable, and it has one or more CR-LFs in it, then S_QUOTE() automatically uses the long string format.

list1 = comma_to_crlf("A,B,C")
? s_quote(list1)
= 
A
B
C%txt%

See Also