Saving the accounts
Setting the module for the global slots:
Setting slot initializers:
Filing out the accounts module:
To read a module:
'applications/accounts.self' runScript
|
Saving the bank and stock accounts
To illustrate the use of the module system, let's put our account example into a
module of its own.
We start by putting the bankAccount and stockAccount slots in globals into a new
module. To do this, we expose their annotation using the slot menu item, 'Show
Annotation.'
We then type the module name into the space provided. We'll call the module
accounts. As soon as we accept the change, the system notes that there is no module
of that name, so we tell it to create one.
It will ask us if the new module is to be a submodule of some existing module; it is
not. It then asks which directory the source file is to live in; the default,
applications, is acceptable.
Having put both of the global slots into the module, we could actually try filing the
module out now using the 'Changed Modules' object. The transporter would note
that the slots referenced objects not yet in a module, and would offer to put them
in the same module for us.
Alternatively, we can set the modules of the slots in the account objects and their
parent using the 'Set module...' menu item on each slot individually (tedious) or
all the slots in each object.
However, we're not quite done yet. We have been experimenting with the
accounts and they have arbitrary values for the number of shares and balance. We
should check that the slot initializers for these slots have reasonable defaults, and
change them if necessary. Having done this, the module can be filed out.
|