ExampleUtilities

ExampleUtilities is a sample that contains binaries and libraries. They are used by the snippet browser component and RunSnippet utility and the SampleWindowProgram. The snippet browser, RunSnippet, and the SampleWindowProgram are not samples and source is not provided for these applications.

Snippets

Snippets are organized into subclasses of TSnippet. TSnippet provides the protocol for accessing and running the snippets. It also provides default behavior for locating the source file for the snippets, locating the snippet text within the source file, and establishes which TSnippetDisplay the snippets output to.

Derived classes of TSnippet follow these conventions:

1) The source of the derived class resides in a file with the same name as the class minus the leading 'T' and with the addition of '.C.'For example, TFooSnippets should have its source in a file called 'FooSnippets.C' under the Examples directory. The default implementation of TSnippet::GetFileName returns this value.

2) Snippets are defined as member functions of TSnippet that take no parameters. Typically they operate as a standalone, but some of the snippets utilize utility functions defined in that subclass of TSnippet. TSnippet itself provides some utility functions, most significantly GetDisplay, which returns a TSnippetDisplay object that snippets use to display text output (similar to ostreams).

3) In the subclass constructor, snippets are 'registered' with the class using the SNIPPETINFO macro. This defines the snippet name and function to call. Snippets appear in the menus using this name.

Snippet browser

Launch the snippet browser using the script SnippetBrowser.

The snippet browser presents a window and a menu listing all the snippet classes. Each snippet class menu presents a submenu listing all the snippets in that class. When you choose a snippet from this menu, it locates and displays the source code for the snippet, and then runs the snippet, displaying its output.

The snippet browser is a Document framework component. It locates the snippets by looking in a snippet database. This allows the snippet viewer to compile and link without reference to the snippets--you can add or remove snippet classes without recompiling or relinking the viewer. The database resides in the CommonPoint(TM) file, $TaligentRoot/RuntimeEnv/Data/Samples/snippet.db.cp. If the browser cannot find this file, it looks for an ASCII version in the same directory, snippet.db.ascii. The ascii version contains a list of class name/library name pairs, one per line. The browser builds the CommonPoint version of the database from this file, and thereafter use the CommonPoint version.

RunSnippet

RunSnippet is a small binary that lets you run a snippet from a command line, and display the output (and source) in a shell window. It is useful only for snippets that involve no graphic or user interface operations. Usage is:

Type 'RunSnippet' to get a help message that explains the options.

Samples

SampleWindowProgram defines a simple derived class of TThreadProgram that displays a window with a close box, an optional menu, and handles user operations until the window is closed. Several of the sample programs define a derived class of the view and use TSampleWindowProgram to present it to the user.


Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.