The sample solution is very bad Forth considering the problem statement. The code converts numbers into characters and stores them in a buffer. This is both untypical and unnecessary. Forth is a stack language and it is customary to take values directly from the data stack and for a function to consume them immediately.
The problem asks for a brute force solution and by implication to keep things simple.
\ A program to output integers until 42
: printLastNumber . ;
: cleanUp ( x! – ) depth 0 do drop loop ;
: test ( n – n bool ) dup 42 <> ;
: doIt ( – ) Begin test While printLastNumber cr Repeat ;
: Top ( – ) page doIt cr cleanUp ;
8 9 32 42 7 54 2 7 9 0 Top
As you can see the code is very simple to read. The test is factored out and called in the function doIt that takes the numbers from the stack and loops until 42 is encountered. Top just calls the whole thing. You have to remember to put numbers on the stack in reverse order though.
Anyway I can’t see any reason why the program is failing but succeeds on IDEON