Build Documentation MetalBase 5.0 ------------------------------------------------------------------------------- Function Relations are built from schema files, which decribe the relation in a more human-friendly syntax. Schema for MetalBase 4.0 and up relations take the following form (Words in brackets are optional syntax, words enclosed in <> are sample entries): [relation] field [type] [length/*] <5> ; field [type] ; field [type] [length/*] <4> ; field [type] [length/*] <11> ; field [type] ; field [type] [] ; index customer [on] customer [] ; index part [on] part_number,price_code [with duplicates] ; index ix_price [on] price_code [] ; [ >] ; end Ah, but note: 4.1 and up expect to find SEMICOLONS after every line save "Relation..." and "End"! It's okay if they're not there, but better get in the habit, 'cause report and form will choke heavily without their semicolons. Build is the program which reads these schema and creates MetalBase-format relations from them; in addition, build released with mbase 4.0 and up can create C-style header files for interface with metalbase routines; these look somewhat like this: #ifndef EQUIPMENT_H #define EQUIPMENT_H /* * This file was created by MetalBase version 5.0 to reflect the structure * of the relation "equipment". * * MetalBase 5.0 released October 1992 by virtual!richid@owlnet.rice.edu * */ typedef struct { char customer[5]; /* field customer type string length 5 */ ushort num_purch; /* field num_purch type ushort */ char part_numb[4]; /* field part_numb type string length 4 */ char shop_addr[11]; /* field shop_addr type string length 11 */ double price_code; /* field price_code type money */ long trans; /* field trans type serial start 100 */ } equipment_str; #ifndef MODULE equipment_str equipment_rec; #else extern equipment_str equipment_rec; #endif #endif The headers created by build include actual data (the reference to equipment_str equipment_rec above), that should be local to only one module of a multiple .c-program executable; all the others should have the headers' variables declared as external. So the headers use #ifdefs and check for the definition of MODULE-- if it's there, variables are declared external, if not, they're declared local. That way, variables always go in this one piece of .c code. Command-Line Options Build's command line is rather simple: build [-q] [-h] schemaname Where -q indicates no output should be sent; all questions are assumed to be answered by their defaults. -h indiciates the header file should be created. When used with -q, this overrides the "No" default answer for build's question; when used without, the header will be created without the user being asked interactively. The schemaname may optionally be terminated in .s; if it is missing, it is added by build. MetalBase requires that schema be terminated in .s, and relations in .rel. Format The build utility released with versions 3.1 and higher supports comments at the end of the "field" and "index" lines, and that's it--that's totally pathetic. 5.0 accepts comments anywhere, like a makefile--anything after a # is ignored. Likewise are form and report. Empty lines are ignored. # Comments [relation] # Another comment. field Create header file for this relation [y/N] ? Header file created. Relation created--zero entries. % ls -C /usr/joe equip.s equipment.rel equipment.h % Once a relation has been built, it contains no entries, and is ready for use. BUILD's sole use is the creation of relations... other utilities (discussed later) must be used for maintenance of relations (if needed). A recent addition to build's operation is its ability to create header files for your programs. When interacting with MetalBase routines, you must pass pointers to structures where data can be placed--build now creates these structures for you, removing chances for error along with mindless tedium. Note that, as in the above example, the line 'typedef equ' has caused the structure to be named as: typedef struct { ... } equ; equ equ_rec; If this line (typedef equ) were not present in the schema, the structure would have been named with: typedef struct { ... } equipment_str; equipment_str equipment_rec; That is, the relation name appended with "_str".