ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / Operators
  • Using variables in a multiline string
  • Advantages of multiline strings that use the [ and ] symbols or quotation marks
  • Limitations
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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 (...).
Example
// 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

  • Syntax highlighting: 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.
    You can use the default WLanguage syntax highlighting ("Syntax highlighting .. WLanguage" in the context menu of the 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.

Limitations

  • 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.
    • Multiline 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
     ]
    ]
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/05/2023

Send a report | Local help