<!-- PDF page 51 -->

<table>
<tbody>
<tr><td><code>"abcdefg"*2</code></td><td>returns <strong>abcdefgabcdefg</strong> (two times the string)</td></tr>
<tr><td><code>"abcdefg"*-1</code></td><td>returns <strong>gfedcba</strong> (the string is inversed)</td></tr>
<tr><td><code>"abcdefg"*1.5</code></td><td>returns <strong>abcdefgabc</strong></td></tr>
</tbody>
</table>

### Transforming a string with trailing modifers

If you follow a string expression a$ by brackets containing a modifier list in the format:

*a$* [*modifierlist*]

you can transform the string in several useful ways. The *modifierlist* can be any of the following characters:

<table>
<tbody>
<tr><td>+</td><td>convert lower case letters to upper case</td></tr>
<tr><td>-</td><td>convert upper case letters to lower case</td></tr>
<tr><td>&lt;</td><td>strip leading spaces (and control characters)</td></tr>
<tr><td>&gt;</td><td>strip trailing spaces (and control characters)</td></tr>
<tr><td>~</td><td>strip bit 7 (More about bit 7 in <em>Chapter 23</em>) terminator from last character of string</td></tr>
<tr><td>^</td><td>add bit 7 terminator to last character of string</td></tr>
<tr><td><strong>(f$,r$)</strong></td><td>replace any occurrences of characters present in <strong>f$</strong> with the corresponding character from <strong>r$</strong> (or delete if there is no corresponding character)</td></tr>
</tbody>
</table>

The order of the modifiers is unimportant, except for **(f$,r$)** which, if present, must be the final modifier.

The following examples demonstrate what can ne achieved:

```
"   Hello There!   "[<+->]"
```

gives: **hELLO tHERE!**

as trailing and leading spaces are stripped via < and >and all lower case letters are converted to upper case with the + and upper case to lower case with the -.

```
"My typewriter is broken"[("nore","dro")]
```

returns **My typwoito is borkd** as *r$* doesn't have a corresponding letter for the **e** of *f$* so all of them are deleted, all **o** are replaced by **r** and all **r** are replaced by **o**

Note that it is possible to slice a modified string, or modify a sliced string, since both **()** and **[]** continue to be evaluated following a string argument until there are no further opening parentheses or brackets. For example:

```
a$(5)[-](3 TO 7)[<]
```

is perfectly valid.

### Tokenisation of strings

If need be, (for example to easily prepare strings to be passed to *functions* **VAL** or **VAL$** – See next *Chapter*) we can tokenise, that is to convert *NextBASIC* reserved words to their single code equivalents (tokens) – without syntax checking– the contents of a string expression *a$* by enclosing it in *braces* **{}** like so:

**{a$}**

For example:

<table>
<tbody>
<tr><td><code>{"sin (pi/4)"}</code></td><td>returns a string "<strong>SIN (PI/4)</strong>", including<br>the tokens <strong>SIN</strong> (code <strong>178</strong>) and <strong>PI</strong> (code <strong>167</strong>)</td></tr>
<tr><td><code>VAL{"sin (pi/4)"}</code></td><td>gives <strong>0.7071</strong></td></tr>
</tbody>
</table>

