1.13 String constants and string variables

Most computer languages allow you to mix string constants and string variables. Not in 4tH. In 4tH they are two distinct datatypes. To print a string constant you use the word '."'. To print a string variable you use the 'COUNT TYPE' construction.

There are only three different actions you can do with a string constant. First, you can define one using '"' (or its alias 'C"'). Second, you can print one using '."'. Third, you can copy the contents of a string constant to a string variable using 'COPY'.

There are two different ways to represent a string variable in 4tH. First, by using just its address, the so-called ASCIIZ string. 4tH relies on the terminator to find the end of the string. Second, by using its address and its length. This requires two values.

The word 'TYPE' requires the latter form. Therefore, you have to convert an ASCIIZ string in order to print it. You can convert an ASCIIZ string to an "address-count string" with the word 'COUNT'. Since 4tH always terminates strings you can usually convert an "address-count string" to an ASCIIZ string by simply dropping the count. However, if you moved a string (by using 'CMOVE') without taking the terminator into account you have to terminate it yourself.

This may seem a bit mind-boggling to you now, but we'll elaborate a bit further on this subject in the following sections.