String Constants

 

String constants are comprised of displayable characters bounded by quote marks. You can use double quotes ("), single quotes ('), or back quotes (`) to enclose a string constant, as long as the same type of quote is used to both start and end it.

 

If you need to embed a quote mark inside the string then use a different type of quote mark to delimit the string. For example:

 

'This constant has embedded "quote" marks'

'This constant has embedded `quote` marks'

"This constant has embedded 'quote' marks"

 

If you need to embed the delimiting quote mark inside the string constant, use the delimiting quote mark twice. For example:

 

"This constant has an embedded ""quote"" mark"

 

Multiline text string constants are text string constants that occupy more than one line in the body of a script. Only the dollar-sign + double-quote character combination($") can be used to enclose a multiline string constant. With the few exceptions noted below all text appearing between the beginning '$"' delimiter and ending '$"' delimiter are included in the resulting constant's text.  This includes the ASNI new line (line-feed) character that delimits each line in scripts and any white-space characters.  Note that when a script line is delimited by the carriage-return + line-feed combination, the carriage-return is converted to a space and the line-feed character is retained.

 

In order to maintain preprocessor performance the colon(:) and number-sign(#) characters must be escaped in multiline text string constants. To place a single colon or number-sign in a multiline text string, specify a double colon(::) or number-sign(##). The failure to escape these characters results in an error.

As is the case with single line text string constants, to place a single percent-sign (%) in a multiline text string constant specify a double percent-sign(%%).

To include a single multiline text string constant delimiter($") in a constant's text use a double combination($"$").

 

To use multiline text string constants in the 'then' or 'else' clause of the single statement form of the 'if' statement syntax, each line of the constant after the first line must begin with either a 'then' or an 'else'.  Any white-space characters before the 'then' or 'else' and one white-space character after the 'then' or 'else' are not included in the text constant. Note that multiline text string constants are used as is without special syntax requirements in structure 'if' syntax code blocks.

 

As part of the WIL preprocessor's optimization strategy carriage-return + line-feed line terminators for each line of script are converted to space + line-feed terminators. This conversion includes the lines that constitute a multiline string. Many editors including WinBatch Studio have an option to set the line terminator type when files are saved. If you wish to avoid the extra space at then end of each line in a multiline strings, make sure to set your script editor to use line-feeds instead of carriage-return + line-feeds line terminators..  

 

Substitution is permitted in multiline text string constants.

 

Examples of string constants:

 

"a"

'Betty Boop'

`Look at these backquotes`

'This constant has an embedded "" mark'

 

$" This is an

example of a multiline

string constant$"

 

String Concatenation

String concatenation is the operation of joining two character strings. The StrCat function can be used to concatenate strings together. The colon ( ':' ) string concatenation operator can also concatenate two strings (or values which can be converted to strings).

For example:

 

Message("Windows version", WinVersion(1) : "." : WinVersion(0))

 

String Types

Unicode string : a string that contains UTF16-LE encoded Unicode characters, and is terminated by a corresponding UTF16-LE NULL character, which is represented by 2 NULL bytes.

ANSI string:  any string that consists of either a single byte or variable multi-byte encoding with a corresponding code page that dictates what characters are associated with which values, and a single NULL byte terminator at the end of the string.

 

 

 

§         Floating Point Constants

§         Integer Constants

§         Predefined Constants

§         Reference

§         Step by step guide to learning WIL

§         Notes