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!
Try :
: Before \ add len char -- add len'
back dup if 1- then
;
s" C:\A\B\C\D\*.*" backslash before cr type
Graham Smith
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!
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
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
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..