On Tue, Jul 7, 2009 at 10:48 AM, Rick Collins<gnuarm.2006@...> wrote:
> --- In win32forth@yahoogroups.com, "George Hubert" <georgeahubert@...> wrote:
>> --- In win32forth@yahoogroups.com, psg0912@ wrote:
>> >
>> >
>> > Hi,
>> >
>> > I have a text file which consists of a number of lines. Each line has 7
numbers which are tab-separated. I read a line from a file into a buffer in
memory.
<snip>> >
> Just a question to the OP, would it make sense to read and process your
numbers one at a time rather than stacking them? I'm not up with my Forth
enough to offer some code, but I remember doing something like this where I read
in a line from the source and evaluated the words one at a time. I wrote a word
to evaluate one word, if the input buffer was empty it would read a new line, if
the source was empty (for file sources) it would return nothing. I did what was
required with each value read as I read it. No need to evaluate them all and
clog up the stack... at least in my case.
>
> Does that make sense? I think this is simpler than recursing to fill the
stack in the order you need.
>
> Rick
Again to the OP, but you are right Rick. As pointed out by others in
this thread, you can easily blow up the stack if your spreadsheet
contains more than a trivial number of entries. I do have code at
http://vf-plugins.googlecode.com/files/pfDatabase-4.zip that includes
a csvParser.fth which parses comma separated values and passes them to
a user defined word. I can't remember if there is an example in those
tools and I'm sure it will need to be modified to work on Win32Forth,
but the concept is there and I could probably come up with an example
without too much effort. The code is presently configured for
VentureForth and came from polyForth, via SwiftForth, via gforth, so
it's relatively generic and the database is even fairly well
documented. It's free for your use I'd be glad to help to get it
ported to yet another system.
DaR