Here are 2 examples of literal strings:
"This is a literal string." 'This is another literal string.'
If you need to use an apostrophe (single quotation mark) or double quotation mark within the text itself, use the other quotation mark around the whole string. For example, here we need to use an apostrophe within the word Here's, so we use double quotes to enclose the entire string:
"Here's a REXX Literal String."Here we need to use double quotation marks within the text, so we use single quotes to enclose the entire string:
'He replied "I understand now" as he read this online book.'You also can use a pair of quotation marks (to represent one mark) when you need to utilize the same quotation mark as was used to mark the entire string. For example, here we use double quotes to mark the entire string, but we also want to use double quotes within the string. So, we need to use a pair of double quotes within the string wherever we'd normally place only one.
"He replied ""I understand now"" as he read this online book."
Literal strings can be concatenated (ie, placed one after the next) with the concatenation operator, || (ie, two | characters). For example, here we place the string Jeff after the string My name is. Note that I leave an extra blank space at the end of My name is, so that there will be a blank space between the My name is and Jeff after they are combined.
"My name is " || "Jeff"So if we use the above literal string as an argument for the SAY instruction, as so:
SAY "My name is " || "Jeff"...then My name is Jeff is displayed upon the screen.
It's also possible to concatenate strings by merely leaving a space inbetween each string. For example:
SAY "My name is" "Jeff"...will achieve the same result as using the concatenation operator above.
The space inbetween the two strings is retained by REXX. So, the end result is that when you append strings by leaving a blank space inbetween them, you always end up with a combined string that has that extra blank space there. (But, even if you put more than one space character inbetween the strings, REXX will retain only 1 space character). On the other hand, the concatenation operator allows you to combine two strings without that extra blank space inbetween them. If you wanted to append the string .exe to the string program without any blank space inbetween the two strings, then you'd need to use the concatenation operator as so:
"program" || ".exe"Of course, you're wondering, "Why not just specify one literal string consisting of "program.exe"? Well, as you'll see later in the discussion of variables, when you wish to combine the value of a variable and a literal string (or the values of two variables) into a single string without spaces inbetween the two pieces, then the concatenation operator is essential.
Note: When using the concatenation operator, you can eliminate all blank space around the ||. For example, the following two instructions are really the same thing:
SAY "program" || ".exe" SAY "program"||".exe"But, the first one is easier for a human to read.
All the text within a literal string must appear on one line in your script. For example, the following is not legal:
"This is a literal string."If you need to span a single literal string across more than one line, you can break it apart into several literal strings each on its own line, and use concatenation operators, along with an unquoted comma at the end of each REXX line to be continued, to tell REXX to join these literal strings together, as so:
"This is " || , "a literal string."An unquoted comma at the end of a line is how you tell REXX that you're continuing an instruction upon the next line.
An empty string is one that contains no characters between the quotes. In other words, there are no characters in the literal string at all. For example. here is an empty string:
""As you'll see later on, you may encounter empty strings (since some built-in functions may return such).
If a literal string is followed immediately by an unquoted (, REXX instead regards it as the name of a function (discussed later).