[OpenBIOS] Help with some code

Programmingkid programmingkidx at gmail.com
Fri Sep 24 12:00:01 CEST 2010


I'm trying to implement the -> word for setting variables, but it is not working as I hoped. Everything seems find until I reach the first eval word. At that point the evaluated string should make a new word. For some reason, the eval word says that the word can't be found. Here is the code:

\ compile time: 4 -> cat
\ run time:	  4 set-cat
\ : set-cat cat ! ;


\ sets values for local variables
: ->	( x - )
parse-word

\ creates a copy of the variable's name
2dup
strdup
2dup
strdup
2dup
strdup

\ creates the new variable setting word
" : set-"
2swap
$cat2

2swap
"  ! ;"
$cat2

"  "
2swap
$cat2

$cat2
eval

\ sets up the new word to be called in place of ->
" set-"
2swap
$cat2

" postpone "
2swap
$cat2
eval
; immediate


\ combines two strings together
: $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>
;


Anybody know what I could be doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openbios.org/pipermail/openbios/attachments/20100924/aa106fc4/attachment.html>


More information about the OpenBIOS mailing list