So, today's words are ". and the humble Quote command:
" someTextEndingIn"
Quote works in immediate mode to provide constant strings such as:
create msg " Quoted String"
Here, the string is just added to the end of the program. Typing:
msg
Returns the address of the string.
But Quote also works in compiled mode to provide constant inline strings that return an address. For example:
: dummyMsg " FIGnition Strings!" ;
Puts on the top of the stack the address of that string " FIGnition Strings!"
The handy thing about Quote is that it can be used with ". or other string functions in FIGnition Forth to do useful operations, such as:
: appendExclaim ( str --) " !" swap "+ ;
Will append an exclamation mark to a string.
FIGnition Forth exclusively uses zero-terminated strings. Thus:
find dup lfa>nfa
Will provide the address of the name string for the dup command. As with other strings you could print it out with ". or copy it to a string buffer with "! or append it to a string buffer with "+ .
The natural command to go with " is ". which displays zero-terminated strings (type is also available for a little conventional Forth string support). In fact in FIGnition Forth ." some string" really compiles a zero-terminated string and upon execution uses the underlying (".) to display it.
Why does FIGnition Forth support strings in this way? Because it means I can provide a core set of string functions in under 256b of compiled Forth (including the headers). Secondly, it means that I can sort-of leverage 'C' style string handling, which is a common, though fairly crude, way to think about strings.
It's possible you might not like FIGnition Forth's strings! If so, why not take up Mark Willis's invitation to convert his Turbo Forth string library to FIGnition :-) ?
-cheers from Julz