14.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.

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

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 several ways:

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-0.2 “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-0.4 “bootmessage”

Hook (deferred word) executed right after interpreting the OS command-line arguments. Normally prints the Gforth startup message.

doc-’quit

process-option ( addr u – true / addr u false  ) gforth-0.7 “process-option”

Process an option addr u, return true, if the option is processed; unprocessed options are loaded as files throu required.