# Module Preludes

A Module prelude is a piece of C code which can be added to the generated code near the beginning of the module (or whole design).

Typically, you would use module preludes for the declaration of any of your own external data structures (such as client data for your callback procedures) that you reference within the generated source.

Module preludes are used for any pieces of code which are applicable to the whole module rather than individual widgets, for which you should use Code preludes.

There are three types of module prelude provided in WorkShop Visual: Module Heading, Module Prelude, and Resource Prelude.

Selecting one of the toggles which appear in the representative text, allows you to edit that type of prelude. There are two ways of adding a code prelude:

- Editing the generated code
- Typing the code into the dialog

Use the "Edit in place" toggle to specify which of the above you wish to use. If the "Edit in place" toggle is set, the generated code is opened for you to add your code.

If the "Edit in place" toggle is not set, a large text widget appears on the right of the dialog. Enter your code here. You should type the code exactly as if you were using a text editor to type any other code. This means that you should observe all the rules and conventions of the target language, including end of line markers, bracketing conventions etc.

Heading Prelude

The heading prelude is inserted at the beginning of the main program file, the code file, the externs file and the stubs file. Typically, a module heading would contain a comment with information such as the program name, SCCS ID, or version number.

Module Prelude

The module prelude is inserted at the top of the generated code file - just after X-Designer's generated #include statements, if you asked for them. The module prelude can be used to supply #define or #include statements or extern declarations which are needed by your code preludes. The module prelude is generated only into the primary module, not the stubs file.

Resource Prelude

The resource prelude is inserted at the beginning of the X resource file to specify application resources - i.e. resources which refer to the whole application and not to individual widgets. Use the following syntax:

`ApplicationName*resource: value`

For example:

`XDesigner.symbolFont: -*-symbol-medium-r-normal--14*`

Although these resource bindings apply to all widgets in the application, they are overridden by more specific resource settings on individual widgets or groups of widgets with a common name.

You may also wish to include comments or SCCS IDs in a resource prelude.

See also:

- Callbacks
- Code Generation
- Widget and Variable Names
- Generate dialog
- Search
- About WorkShop Visual