A useful customization is to allow an
option for a startup script. The script could be a standard,
hardcoded filename or a configuration variable. Users can do almost
anything with this script; they can put in a series of standard
import statements, go off and import commonly used data files from
elsewhere, and (as we’ll see) set up the
BookSet as they want with validation rules and
custom views. The script executes after the
BookSet has been initialized, so it can’t
control the way
This feature is easy to provide with the tools we’ve just built. In Figure 8.3, we’ve gone for a user-defined script name in an Options dialog.
Earlier on we put two public methods in
, and never used the latter. Here
there’s a good use for it.
been expanded as follows (ignoring error trapping to save space):
Sub InitCOMServer() Dim startupScript As String 'called when the program starts On Error GoTo InitCOMServer_error Set BookServer = CreateObject("Doubletalk.BookServer") On Error GoTo 0 'tell it to capture output for the console BookServer.beginTrappingOutput 'if there is an init script, run it If frmOptions.txtStartupScript.text <> "" Then On Error GoTo InitCOMServer_StartupScriptError BookServer.execFile frmOptions.txtStartupScript.text ...