Shop OBEX P1 Docs P2 Docs Learn Events
P2 Taqoz V2.8: Include for SD-files — Parallax Forums

P2 Taqoz V2.8: Include for SD-files

Hi,
like so many things in Forth here is a solution so simple, that it might be too trivial to post. But perhaps it might come handy?

The parent-file contains
include

The child must end with
endInclude
to go back to the parent.

(Tested with version _BOOT_P2.BIX in Taqoz.zip in https://sourceforge.net/projects/tachyon-
forth/files/TAQOZ/binaries/ . )
Have Fun! Christof

long incDepth   incDepth ~

pre include \ <filename>
   incDepth ++
   filesect @ >L
   _fread @ >L
   [C] FOPEN
   @FILE OPEN-SECTOR
;

: endInclude \ resume to the including file
   incDepth @ 0exit
   incDepth --
   L> _fread !
   L> filesect !
   get$ drop \ drop the file name
;

include test2.fth

." Welcome back from test1.fth"

{
\ test2.fth
." Hello from test2!"

endInclude

}

Comments

  • I like trivial Christof , whenever you have these thoughts put it out there I will sit and read all you have to tell, ty.

Sign In or Register to comment.