On 2010-8-31 8:06 PM, Programmingkid wrote:
Could someone provide me with a code example on how to combine two strings together in forth please. Here is my attempt. For some reason it doesn't work. Any help would be great.
The below takes two strings of the form (addr len), allocates a chunk of memory for them, and concatenates them into that allocated memory, returning addr len.
: $cat2 ( $1 $2 -- $3 ) 2 pick over + dup >r alloc-mem >r 2swap tuck r@ swap move ( $2 $1-len ) r@ + swap move ( ) r> r> ;