|
|
|
|
- Using variables in a multiline string
- Advantages of multiline strings that use the [ and ] symbols or quotation marks
- Limits
Multiline strings In french: Chaînes multi-lignes
WINDEV, WINDEV Mobile and WEBDEV include several tools that allow you to write strings over several lines: - the [ and ] symbols.
- quotation marks.
- three dots (...).
// Using square brackets to type a multiline character string MyString is string MyString = [ Example of multiline string ]
MyString is string MyString = " Example of multiline string "
// Using triple dots to type a multiline character string MyString is string MyString = "Example of " + ... "multiline string"
Syntax
Multiline string using the [ ] symbols Hide the details
<Variable name> = [ <Content of string> <Content of string 2> ]
<[>: Symbol signaling the beginning of multiline string. This symbol must be followed by a carriage return. This carriage return is ignored in the string. <Content of string>: Multiline string, entered over several lines, without quote signs. The carriage returns found between 2 lines of the string are considered as being carriage returns. The tabulations are ignored. <]>: Symbol signaling the end of multiline string. This symbol must be preceded by a carriage return. This carriage return is ignored in the string.
Multiline string with quotation marks Hide the details
<Variable name> = " <Content of string> <Content of string 2> "
<">: Symbol signaling the beginning of multiline string. This symbol must be followed by a carriage return. This carriage return is ignored in the string. <Content of string>: Multiline string, entered over several lines, without quote signs. The carriage returns found between 2 lines of the string are considered as being carriage returns. The tabulations are ignored. <">: Symbol signaling the end of multiline string. This symbol must be preceded by a carriage return. This carriage return is ignored in the string.
Multiline string using the triple dots Hide the details
<Variable name> = "<Content of string>"+ ... "<Content of string 2>"
<Content of string>: Multiline string, typed over several lines, with quotes. Each line is separated by "+ ...". Remarks Using variables in a multiline string To use a variable in a multiline string, you can: - interrupt the multiline string to take the variable into account.
Examples:
sCode is string = ... "The string "+ ... sVar + ... " is multiline string"
s is string = [ the string ] + var + [ is multiline ]
s is string = " the string " + var + " is multiline "
This solution is not recommended if the character string must be translated.
- use characters such as %1, %2, %n instead of configurable values and use StringBuild to replace the parameters in the string with their values.
Examples:
sCode is string = "The %1 string is a multiline string" sCode = StringBuild(sCode, MyVariable)
sString is string = [ the %1 string is multiline ] sString = StringBuild(sString, MyVariable)
sString is string = " the %1 string is multiline " sString = StringBuild(sString, MyVariable)
This last solution is recommended.
Advantages of multiline strings that use the [ and ] symbols or quotation marks - Coloring the string: by default, the multiline character string is colored in purple (like any other string enclosed in quotes in WLanguage) and it is highlighted in mauve.
The default colors of WLanguage can be used for the multiline string ("Coloring the string .. WLanguage" from the popup menu of multiline string). This option is used to check the code typed when a multiline string is used for the dynamic compilation (Compile). - Ability to collapse/expand a multiline string
Collapsing the multiline strings is used to free space in the code editor. The code becomes clearer and more readable. When the string is collapsed, its content is displayed in a tooltip. - Additional advantage when using quotation marks
Quotation marks make strings more readable, regardless of whether they are single-line or multiline strings.
- The maximum number of lines in a multiline string is set to 1000.
- TAB in multiline strings:
- Multiline strings defined with "[" cannot contain TAB characters. There is no way to differentiate between tabs "in the string" and tabs used for indentation in the code.
New in version 28Multiline strings defined with quotation marks allow the use of TAB characters. The tabs contained in the string are preserved.
- You cannot use multiline strings within multiline strings. The following code generates a WLanguage error:
sCode is string = [ sMultilineString is string = [ Test on the multiline strings Attempt on the multiline strings ] ]
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|