13.8 Modifying the Startup Sequence

You can add your own initialization to the startup sequence of an image
through the deferred word 'cold. 'cold is invoked just
before the image-specific command line processing (i.e., loading files
and evaluating (-e) strings) starts.

After 'cold, Gforth processes the image options
(see Invoking Gforth), and then it performs bootmessage,
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:

If you want to do your interpretation of the OS command-line
arguments, hook into '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
next-arg

If you want to have the normal Gforth processing of OS command-line
arguments, hook into bootmessage.

In either case, you probably do not want the word that you execute in
these hooks to exit normally, but use bye or throw.
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.