1.5 Initializing strings

You can initialize a string with the '"' word. You haven't seen this one yet, but we will discuss it in more depth later on. If you want the string to contain your first name use this construction:

     " Hans" name copy

The word '"' is very much like '."', but instead of printing it to the screen you will just be defining a constant string. The word 'COPY' copies the contents of a constant string into a string-variable.

As a matter of fact, it does even more. It will leave the stack in the same state as if you had just written:


So you can continue to manipulate the string with all the words that we'll introduce to you in the following sections. This value on the stack is the 'string address'. For this moment you can ignore it and simply drop the value.

If you still don't understand it yet, don't worry. As long as you use this construction, you'll get what you want. Just remember that assigning a constant string to a string that is too short will result in an error or even worse, corrupt other strings.