![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

PRUNE and REMEMBER are difficult if not impossible to use in a Windows
environment (callbacks etc). MARKER updates both mechanisms, so
(using a big hammer) they were disabled. There are many "Magic
Stones" in this area and I'm not certain how to arrange them all.
Mike
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of Bob Nash
Sent: Thursday, June 19, 2003 7:18 AM
To: sftalk_at_forth.com
Subject: [sftalk] Re: EVALUATE in Callback Revisited
Thanks to both you and Rick for the code: very educational. =20
I haven't had time to play with your code yet, but I have
tried Rick's (it works, of course).
Note that the =3D in the definition was added because of the=20
line length in the message was too long (don't know why,
probably a MIME thing). It was not part of my code. =20
I used this test definition primarily because=20
I already had a dubug word to show the stack in my test
turnkey app. =20
I like your phrase: ['] DROP IS >XREF -- cool
Also, the new dictionary stuff. I don't quite understand
the PRUNE/REMEMBER code, but it looks like you are
disabling dictionary pointer tracking in order to do your
own "extend, execute and forget." Evidently no need
to restore because you are the only one extending it. Right?
-----Original Message-----
From: Mike Ghan [mailto:mikeghan_at_logix-controls.com]
Sent: Wednesday, June 18, 2003 5:14 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: EVALUATE in Callback Revisited
Bob,
> : test-word 5 5 + =3D ;
It appears you are attempting to compile a definition which opens up a
whole can of worms. I tackled this problem while developing a Forth
Script engine for our Forth Web Server. I modified it (below) for
EVALUATE (untested - sorry).
Good luck,
Mike
50000 VALUE /SCRIPT-DICT \ How much code space to ALLOCATE
: INIT-FORTH-SCRIPT ( -- )
DECIMAL /FORTH POSTPONE [
0 ( =3Dkeybrd ) 'SOURCE-ID !
CASE-INSENSITIVE BLK OFF WARNING OFF
['] (COMPILE,) IS COMPILE,
['] (SOURCE) IS SOURCE
['] DROP IS >XREF ;
: EVAL-SCRIPT ( addr len -- )
SAVE-INPUT N>R
INIT-FORTH-SCRIPT
'REMEMBER OFF 'PRUNE OFF ( Initialize Prune/Remember )
H @ >R HLIM @ >R
/SCRIPT-DICT ALLOCATE THROW
DUP >R DUP H ! /SCRIPT-DICT + HLIM ! ( create "new" dictionary
space )
S" MARKER FORGET-SCRIPT" ['] EVALUATE CATCH ?DUP
IF >R ( Stash ior )
ELSE INIT-FORTH-SCRIPT
( addr len ) ['] EVALUATE CATCH ( ior ) DUP >R
IF 2DROP ( addr & len ) THEN
INIT-FORTH-SCRIPT
S" FORGET-SCRIPT" ['] EVALUATE CATCH
IF 2DROP ( eval string+len ) THEN
THEN R> ( ior ) ( cleanup )
R> FREE THROW
R> HLIM ! R> H ! ( restore dictionary )
NR> RESTORE-INPUT DROP
( ior ) THROW ;
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of Bob Nash
Sent: Wednesday, June 18, 2003 2:13 PM
To: sftalk
Subject: [sftalk] EVALUATE in Callback Revisited
Some time ago (September 2001 and June 2002) there were discussions
=3D
about using EVALUATE in a callback as part of a turnkeyed app.
According to Rick, the problem is that internal variables and system
=3D
state are not initialized during callbacks, so the search order and
=3D
CONTEXT had to be set before executing EVALUATE in the callback.
There were two solutions. One (from Rick) was to define the callback
=3D
word something like this:
: EVAL DECIMAL ONLY FORTH POSTPONE [ Buffer ZCOUNT ['] MY-EVALUATE
=3D
CATCH IF 2DROP THEN ;
Buffer contained the string to be evaluated and MY-EVALUATE was a =3D
version of EVALUATE that did not try to write errors to the console.
Another solution (again from Rick) was to execute a special word, =3D
INHERIT-SEARCHORDER, just before executing the callback switch =3D
statements:
: INHERIT-SEARCHORDER OPERATOR #ORDER HIS #ORDER #VOCS 3 + CELLS
CMOVE =3D
; \ I'll trust Rick on this one!
I just tried various combos of the above with no success (mostly I got
a =3D
DOS console window that persisted for a while and then went away).
The =3D
evaluated words were simple stack manipulations like : test-word 5 5
+ =3D
; The word didn't seem to execute (nothing on the stack).
Finally, my questions:=3D20
1. Did anyone get this to work? =3D20
2. Do you have code snippets you are willing to share?
This is just for my own edification -- no immediate need. Thanks!
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug=20
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Jun 19 2003 - 08:06:16 PDT
This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:09 PST