10: Code Wizards
"Code Wizards work Magic!"
Introducing the TypeWriter IV Code Wizard. This Utility was specifically designed based on the Rules of Applied Object-Based Programming with Blitz3D.
This Utility will parse a *.object definition file to generate a *.class file that contains a set of common object methods. Class includes:
- objectStart: Initializes Class
- objectStop: Shutsdown Class
- objectNew: (Constructor) Creates an Instance; Initializes Default Property Values; Assigns Primary Key Object Pointer
- objectDelete: (Destructor) Deletes an Instance.
- objectWrite: Writes Property Values to a specified file.
- objectRead: Creates Instances; Reads and assigns Property Values from a specified file.
- objectSave: Saves all Instances Property Values to a specified file.
- objectOpen: Loads all Instances from a specified file into Instances.
It's designed to work with all Object Property declarations as explained in the Lesson 02: Advance Custom Types. The utility will also generate needed constructs and methods for Managing Object Key Management and Pointer To Object ID Assignment.
To use it:
- Unzip typewriter.zip into the Typewriter4 Folder.
- Load and Run demo.bb in Blitz3D IDE.
The *.object File
The *.object File is a definition of the object. TypeWriter's Parser is very limited. It reads the *.object File line by line (no tabs allowed). It recognizes only the following keywords:
type {object name}
field {property label}
max={maximum number of objects in collection; an integer value}
recycle={Primary Key Managment; 0=Counter, 1=Stack}
prefix={Project Prefix Acronym}
type obj field id% field a% field b# field c$ field d.subobj field e.subobj[2] end type max=4 recycle=1Typewriter4 requires that each field label to be followed by its datatype extension: %, #, $, .object
Exercise:
1. Create a *.object file of your choice. Modify the demo.bb to execute typewriter v4 on your *.object file.