| 12345678910111213141516171819202122232425 |
- { t52_strcat_nest: nested concatenations, a concatenation compared, and a
- string ELEMENT as an operand.
- `+' associates to the left, so `a + b + '!'' is two occurrences and gets two
- scratch strings, and the first result is still alive when the second consumes
- it. A concatenation result is an ordinary string variable, so it can be an
- operand of `=' (ParseCmp), and `+' can take an `s[i]' element as its left
- operand, in which case an element ADDRESS is what reaches the runtime rather
- than a whole-string address.
- a[2] is 'e' - subscripts are 1-based, the length byte is at s[0]. }
- program t52_strcat_nest (input, output);
- var
- a, b : string[12];
- begin
- a := 'hello';
- b := 'world';
- writeln (a + b + '!'); { (a + b) + '!' }
- writeln ('<' + a + '>'); { ('<' + a) + '>' }
- if (a + b) = 'helloworld' then
- writeln ('concat-eq')
- else
- writeln ('concat-ne');
- writeln (a[2] + b) { a string element + a string }
- end.
|