S_TOOLS-STx does not strictly discern between string constants and numerical constants. Normally each constant is considered a string, there only being exceptions dependent on the context where the constant occurs. If, for example, a constant occurs as part of a numerical expression, S_TOOLS-STx tries to get its numerical value.
Generally, you may, but you need not, put single quotes around constants. With a few exceptions depending on context, this will not change the way S_TOOLS-STx handles the constant. So each of the following strings is a valid S_TOOLS-STx constant:
Regardless of the presence or absence of single quotes, both the first and the second argument will be considered string constants. Also regardless of the presence or absence of single quotes, both the third and the fourth constant will be considered numerical constants when occurring in a numerical context, or string constants when occurring in a string context.
If a string constant contains whitespace characters, it depends on the context whether it is considered one string constant or more than one string constant. If you want to make sure that a string constant is considered one constant, you should always put single quotes around the whole affair:
While the first string is always considered one string constant, the second one may, depending on where it is occurring, be considered one string constant denoting the string "Hello World", or two string constants, denoting the strings "Hello" and "World", respectively.
These issues will be dealt with in more detail below. For the moment, the curious reader may have a look at the following assignment statements:
#a := num '5' * '3' // value of #a will be 15
#b := set 5 * 3 // value of #a will be "5 * 3"
The first statement is a numerical assignment (denoted by the keyword "num"). Both constants, 5 and 3, will be considered numerical constants, even if surrounded by quote characters. On the other hand, the second statement is a string assignment (denoted by the keyword "set"). So the argument will, logically, be interpreted as one string constant, "5 * 3", even though it contains whitespace and lacks any quote character. What happens physically is that all separate words will be concatenated to the one string constant expected, inserting exactly one blank between each pair of words. The following statements show the consequences of this procedure:
#b := set 5 * 3 // value of #b will be "5 * 3"
#b := set 5 * 3 // value of #b will be "5 * 3", too
#b := set '5 * 3' // value of #b will be "5 * 3"
In the second statement, though the words "5", "*", and "3" are separated by more than one whitespace character, the one string that will be built up from them is "5 * 3" when concatenating them, they get separated by exactly one space character.
You may influence the way concatenation works by quoting some, or all, of the words to concatenate. Quoting a word will prevent S_TOOLS-STx from automatically inserting a blank before and after that word. So, compare the above statements with the statements below:
#b := set 5 '*' 3 // #b is "5*3" (no space)
#b := set '5' * 3 // #b is "5* 3" (one space)
#b := set 5 ' * ' 3 // #b is "5 * 3" (three spaces)
With the first statement, the word in the middle, "*", is quoted. This indicates S_TOOLS-STx on concatenation not to insert a space character either before or after this word, resulting in #b being set to "5*3" (no intervening whitespace).
With the second statement, the first word is quoted and will, hence, be concatenated to its right successor (there is no left predecessor) without inserting space. The second and the third word are not quoted and will be concatenated with an additional space in between them. This results in #b being assigned "5* 3" (no whitespace between "5" and "*", one blank between "*" and "3").
With the third statement, concatenation will not add any additional blanks either before or after the word in the middle. The whitespace that is part of the word, i.e. part of the quotation (three blanks before and after the asterisk, each), will be unaltered, though. So what results it #b being assigned the string "5 * 3" (exactly three blanks both before and after the asterisk).
Within a constant, you may alter the meaning of special characters by using the S_TOOLS-STx escape character "`", the backwards single quote, sometimes called back-tick. At the current stage, we can only use this feature for defining a string constant that contains single quote characters themselves:
#a := set 'Rome is a city but `'Rome`' is a four-letter word'
#a := set Rome is a city but `'Rome`' is a four-letter word
Both statements will assign the string "Rome is a city but 'Rome' is a four-letter word" to a variable called #a (although it may not always be easy later to retrieve the value of this variable). We have to leave these issues open for later discussion.