Solving the problem

23 views
Skip to first unread message

The Beez

unread,
Jul 31, 2016, 1:00:25 PM7/31/16
to 4tH-compiler
Hi 4tH-ers!

Yes, it's true, I haven't programmed in 4tH for some time, but when I need a job done, it's the first tool I turn to. Like this week. I had to grab the information of two CSV files to generate an Excel sheet with several worksheets. With 4tH, that isn't too hard, because it supports CSV parsing and Excel XLM generation.

In the first (sorted) column was the category. When I read a new category, it was time to wrap things up. Now I really wished I could "unroll" that line and resume cleanly, which is possible with SEEK. Or I had to parse the entire thing and buffer it. Worse, I had to parse the lines twice, because a category would need to generate two different worksheets.

Well, I worked around it, but I always knew it could be done more elegant. So I wrote a tiny library for that.

> REFILL> is just like REFILL, only <REFILL undoes the last read, just like ungetch() does with characters in C;
> >MARK saves a line position, which MARK> restores;
> MARK- drops a previously made mark by REFILL> or >MARK.

I have no intention yet to rewrite the program I made, but I know that when I would have had this tiny (60 words) library, I would have chosen a different and much cleaner approach. Well, that's one for next time!

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages