Hi Craig,

> I tried your suggesting but sliteral cannot be compiled into another
> definition for some reason.

sliteral is an immediate word. That means that you will have to use postpone
to compile it. Sorry, I forgot it..

Is the following at least somehow in the direction of what you want 
to achieve? A bit rough, I admit.

(ATmega32)> #include postpone.frt
|D=#include postpone.frt
|I=getting filenames on the host
|I=  Reading .
|I=using postpone.frt from/home/mt/Forth/amforth/amforth/lib/ans94/core
**** /home/mt/Forth/amforth/amforth
|I=getting MCU name..
|I=successfully loaded register definitions for atmega32
|F=/home/mt/Forth/amforth/amforth/lib/ans94/core/postpone.frt
|C|    1|\ always compile the next word
|C|    2|\ Implementation by Ulrich Hoffmann
|W|    3|
|S|    4|: postpone ( -- )
|S|    5|    parse-name find-name dup 0< 
|S|    6|    if \ immediate word found
|S|    7|          drop compile compile , exit 
|S|    8|    then
|S|    9|    if \ normal word found
|S|   10|         , exit 
|S|   11|    then
|S|   12|    drop
|S|   13|    -&13 throw 
|S|   14|; immediate
**** /home/mt/Forth/amforth/amforth/lib/ans94/core
(ATmega32)> : label: create postpone sliteral , does> dup u. ;
 ok
(ATmega32)> 42 s" hello" label: example
 ok
(ATmega32)> words
example label: postpone ...
(ATmega32)> example
3824  ok
(ATmega32)> 1+ icount itype
hello ok
(ATmega32)> example 1+ icount 2/ 1+ + @i .
3824 42 ok
(ATmega32)>

The "icount 2/ 1+ +" sequence calculates the
address of the number compiled after the sliteral. 
It is due to the fact that strings are stored with 
2 characters per flash cell.

The initial 1+ is to skip the execution token of the
runtime of sliteral, which is needed to work for the
s" in compile mode. I'm not sure if that could be 
considered a bug, now that you point your fingers at 
it... I'll think about it...

"dup u." is only a debugging aid.

Matthias



------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to