Constants (" " and >> <<) for DS expressions

Follow

In "Expressions", you can choose from the drop-down list, expressions to use in the general formula. In that list, you can find the two following types of constant:
・Constant: " "
・Constant (if contains a value): >> <<
1.png

 

#

Special characters

Description

Constant

" "

You can describe a fixed text that contains special characters (e.g. \n or <<).

Constant (that contains a value)

>> <<

You can describe a fixed text that does not contain special characters (e.g. \n or <<).
If surrounded with >> <<, special characters can however be interpreted as any normal string of characters (as a value).

With the information of the above table in mind, we will explain you output of strings of characters that include special characters.


■Constant
(Example) Creating an expression as below using fixed texts and the newline character \n.
    "Hello" + "\n" + "I am Tanaka"

In this example, \n is interpreted as a special character and a new line is created:
 <Output> Hello
        I am Tanaka
2.png

 

■Constant (that contains a value)
(Example) Creating an expression as below using fixed texts and the newline character \n.
    >>Hello<< + >>\n<< + >>I am Tanaka<<

In this example, \n is interpreted as a normal string of characters (\ and n):
 <Output> Hello\nI am Tanaka
3.png

There are 2 ways to interpret constants you can use in "Expressions". If you want a string of characters that includes a backlash \ (e.g. \n) to be interpreted as a special character, surround it with " ". However, if you want it to be interpreted as a string of normal characters, surround it with >> <<.

You cannot surround the special character << (end symbol) with >> <<.
4.png

 

For normal strings of characters that do not include special characters (e.g. Hello), the output will be the same whether you surround them with " " or with >> <<.

5.png
There will of course be no major issue whichever the symbol you surround your characters with, but because normal strings of characters are "fixed texts (values) that do not include special characters", they fit the "constant (that contains a value)" type and shall be surrounded with >> <<.

 

For more details about descriptive methods for expressions, please refer to "How to formulate statements when using strings of characters, variables or the newline character \n in expressions in DS?".

4 out of 4 found this helpful

Comments

0 comments

Please sign in to leave a comment.