Xbasic

\ (Backslash)

Description

The backslash character "\" has several special functions within the Xbasic language. In the context of the Code Editor, it is used as a line continuation character or a backslash character. When used in the creation of an expression, it is used as an escape character or a backslash character.

Example: Continuing Statements on a New Line

When working in the Code Editor, you can use the backslash character in the following manner to continue a line.

ui_msg_box("Sample", "The line continuation character " \
"is a backslash")

Example: Escaping Characters in Strings

When creating an expression that uses quotation marks, the backslash identifies the quotation marks that are part of the expression, as opposed to those that are part of the function using the expression. Note that the argument "State_prov = \"CA\"" is quoted because it is a character string. However, when the outside quotes are removed, and the expression State_prov = \"CA\" is evaluated, the "CA" string must also be quoted. The backslash character distinguishes the two applications.

dim tbl as P
tbl = table.current()
tbl.index_create_begin("CA customers", "LAST_NAME", "State_prov = \"CA\"", "U")

The backslash character must be escaped if it is the last character in a string. This is because the combination \" is interpreted as escaping the double quote. For example:

dim path as C = "C:\A5Webroot\\"

See Also