Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Neil Bawd's "back" implementation..

2 views
Skip to first unread message

X-Addict

unread,
Mar 19, 2003, 10:41:49 AM3/19/03
to
Hi all.. I started playing around with VFX Forth and
ran into something I'm sure someone here will have an
answer for -- I suspect it's an immediate vs. compilation
sort of issue.

Anyway, If I declare a word as follows :

=====================
include c:\forth\tool2002.fth
include c:\forth\charcase.fth
include c:\forth\charscan.fth

92 constant BACKSLASH
create mypath MAX_PATH cells allot

: test99 \ path-zaddr --
dup dup zcount + BACKSLASH back 1 - + 0 swap c!
zcount type ;

Z" C:\A\B\C\D\*.*" mypath zmove
mypath test99

=====================

Now, the output from the test99 word comes out as
"C:\A\B\C\D\*.*" instead of what I'm expecting which
is "C:\A\B\C\D".. Now, if I just input the forth words
directly into the command interpreter it works as
expected.

Z" C:\A\B\C\D\*.*" mypath zmove
mypath dup dup zcount + BACKSLASH back 1 - + 0 swap c! zcount type C:\A\B\C\D ok

Any ideas? Is this some issue with the stuff behind
the scenes with the "back" word using immediate? I'm
far from a Forth expert, so don't beat me up too much
for my coding style (or lack thereof)

Thanks!

Graham Smith

unread,
Mar 19, 2003, 12:49:42 PM3/19/03
to
In message <1d0ea.308$WQ5...@tornadotest1.news.pas.earthlink.net>,
X-Addict <X-Ad...@dev.null> writes

>Hi all.. I started playing around with VFX Forth and
>ran into something I'm sure someone here will have an
>answer for -- I suspect it's an immediate vs. compilation
>sort of issue.
>
>Anyway, If I declare a word as follows :
>
>=====================
>include c:\forth\tool2002.fth
>include c:\forth\charcase.fth
>include c:\forth\charscan.fth
>
>92 constant BACKSLASH
>create mypath MAX_PATH cells allot
>
>: test99 \ path-zaddr --
> dup dup zcount + BACKSLASH back 1 - + 0 swap c!
^
I think the above line is incorrect. The '+' shouldn't be there.

> zcount type ;
>
>Z" C:\A\B\C\D\*.*" mypath zmove
>mypath test99
>
>=====================
>
>Now, the output from the test99 word comes out as
>"C:\A\B\C\D\*.*" instead of what I'm expecting which
>is "C:\A\B\C\D".. Now, if I just input the forth words
>directly into the command interpreter it works as
>expected.
>
>Z" C:\A\B\C\D\*.*" mypath zmove
>mypath dup dup zcount + BACKSLASH back 1 - + 0 swap c! zcount type
>C:\A\B\C\D ok
>
>Any ideas? Is this some issue with the stuff behind
>the scenes with the "back" word using immediate? I'm
>far from a Forth expert, so don't beat me up too much
>for my coding style (or lack thereof)
>
>Thanks!
>

Try :

: Before \ add len char -- add len'
back dup if 1- then
;
s" C:\A\B\C\D\*.*" backslash before cr type


Graham Smith

X-Addict

unread,
Mar 19, 2003, 1:40:59 PM3/19/03
to
In article <ywrZBeD2...@tectime.com>, Graham Smith wrote:
>
> Try :
>
>: Before \ add len char -- add len'
> back dup if 1- then
> ;
> s" C:\A\B\C\D\*.*" backslash before cr type

You were right.. On both accounts.. I removed the "+" from
my original source and the problem went away. Your "Before"
routine worked as well..

Thanks!

Leo Wong

unread,
Mar 19, 2003, 1:55:18 PM3/19/03
to
X-Addict <X-Ad...@dev.null> wrote in message news:<1d0ea.308$WQ5...@tornadotest1.news.pas.earthlink.net>...
> ...

This may work better, though it should be factored:

: test100 \ path-zaddr --
dup >R dup zcount BACKSLASH back 1- R@ zplace
R> zcount type ;

Z" C:\A\B\C\D\*.*" mypath zmove

mypath test100

ZStrings in VFX Forth are not Forth counted strings.

> ...


> Now, the output from the test99 word comes out as
> "C:\A\B\C\D\*.*" instead of what I'm expecting which
> is "C:\A\B\C\D".. Now, if I just input the forth words
> directly into the command interpreter it works as
> expected.

> ...

You are lucky, or unlucky.

> ...I'm


> far from a Forth expert, so don't beat me up too much
> for my coding style (or lack thereof)

> ...

Try:

1. factoring more
2. using .S and DUMP
3. reading folderol.f

Leo Wong he...@albany.net
http://www.albany.net/~hello/

Leo Wong

unread,
Mar 19, 2003, 2:09:03 PM3/19/03
to
: test101 \ path-zaddr --
dup >R zcount BACKSLASH back 1- R@ zplace
R> zcount type ;


Rufus V. Smith

unread,
Mar 19, 2003, 4:41:03 PM3/19/03
to

"X-Addict" <X-Ad...@dev.null> wrote in message
news:1d0ea.308$WQ5...@tornadotest1.news.pas.earthlink.net...
>
> Anyway, If I declare a word as follows :
>
> 92 constant BACKSLASH
> create mypath MAX_PATH cells allot
>

Are you sure you want to allot MAX_PATH cells?

My guess is MAX_PATH is a maximum character count so
you want simply

create mypath MAX_PATH 1+ CHARS allot align

(adding 1 byte for the trailing 0)

Rufus

X-Addict

unread,
Mar 20, 2003, 2:01:05 PM3/20/03
to

I just wanted to thank all of you for your help. I was able to get
my little program working OK after a fair amount of stumbling around.

I'll post the program for you all to critique a little later..

I'm having fun with Forth and I'm slowly getting more & more
comfortable with the language.. Right now, I really only know
the more straightforward parts of the language and not the
esoteric areas as much. Anyway, if it weren't for you all
being helpful, this language would be a bit more difficult to
pickup and use.

Thanks again..

0 new messages