A lot of the things that you need to make this work are quite conveniently similar to what you have already.
You need a different version of define
if you want to store two values in the things that you create with it;
: 2define create 0 , 0 , ;
Putting two at the start of a word is a convention that indicates it does the same thing as that word without the two but instead does it on double-cell things.
To use this you would write:
2define 2x
//Write something to 2x
s" Hello world!" 2x 2!
//Retrieve it and print
2x 2@ type
It is worth noting that the address that s"
returns is not guaranteed to last the duration of the program and may be overwritten by a later use of s"
, to see a way to make a string variable that is guaranteed to last have a look at this answer https://stackoverflow.com/a/8748192/547299 (it is a bit long winded but there is a definition of a word called string
which might be illustrative).