You can add your own initialization to the startup sequence of an image
through the deferred word
'cold is invoked just
before the image-specific command line processing (i.e., loading files
and evaluating (
-e) strings) starts.
A sequence for adding your initialization usually looks like this:
:noname Defers 'cold \ do other initialization stuff (e.g., rehashing wordlists) ... \ your stuff ; IS 'cold
'cold, Gforth processes the image options
(see Invoking Gforth), and then it performs
another deferred word. This normally prints Gforth's startup message
and does nothing else.
So, if you want to make a turnkey image (i.e., an image for an application instead of an extended Forth system), you can do this in two ways:
'cold. In that case you probably also want to build the image with
gforthmi --application(see gforthmi) to keep the engine from processing OS command line options. You can then do your own command-line processing with
In either case, you probably do not want the word that you execute in
these hooks to exit normally, but use
Otherwise the Gforth startup process would continue and eventually
present the Forth command line to the user.
'cold– gforth “tick-cold”
Hook (deferred word) for things to do right before interpreting the OS command-line arguments. Normally does some initializations that you also want to perform.
bootmessage– gforth “bootmessage”
Hook (deferred word) executed right after interpreting the OS command-line arguments. Normally prints the Gforth startup message.