String

Read(3259) Label: string,

Description:

Define a string.

Syntax:

"string"

$[string]

Note:

A string must be double quoted when used in an expression, but defining a string constant directly does not require that.

 

The macro in "string" will not be replaced. When copying/pasting/inserting/deleting the row, the cell referenced by "string" will not change automatically.

 

The macro in $[string] will be replaced. When copying/pasting/inserting/deleting the row, the cell referenced by $[string] will change automatically.

 

The double quotation marks in $[string] do not need an escape character; while the double quotation marks in "string" needs one.

Parameter:

string

Contents of the string, which can be any character. Its value is usually a legal expression when used in $[string].

Return value:

String

Example:

 

The cell referenced by the string enclosed in $[] will change automatically when copying/pasting/inserting/deleting a row, but the one referenced by the string enclosed in "" will not change automatically in the same situation, as shown below.

 

 

A

B

 

1

 

 

 

2

1

2

 

3

="A2"

=$[B2]

Reference A2 and B2 respectively.

Delete the first row in the preceding cellset and B2 becomes B1, thus the original reference of B2 in B3 becomes the reference of B1 in B2, as shown below:

 

A

B

1

1

2

2

="A2"

=$[B1]

 

 
The macro in $[] will be replaced automatically, while macro in "" will not:

 

A

 

1

>s="AAA"

Define value of variable s as string AAA.

2

="${s}aaa"

The macro will not be replaced, so the result returned is ${s}aaa.

3

=$[${s}aaa]

The macro will be automatically replaced, so the result returned is AAAaaa.

 

The double quotation marks in $[] do not need to be escaped; while the escaping of double quotation marks in "" is needed:

 

A

 

1

=$[a"s] 

The quotation mark does not need to be escaped, so the result returned is a"s.

2

="a\"s"

But this quotation mark needs to be escaped, and the result returned is still a"s.

 

Related function:

Escape character

String concatenation