ubase.addField

Syntax ubase.addField (fnum, fieldName, fieldType)

Params fnum is the file refnum identifying the uBASE database that a field will be added to.

fieldName is a four-character string that will be used to identify the Þeld.

fieldType is the type of the Þeld. See Notes.

Action Adds a Þeld with the indicated name and type to the database identiÞed by fnum. It is possible to add one or more Þelds to a database which contains records, but see Notes.

Returns True if the new Þeld is added successfully, false otherwise.

Examples To create a database and add a field named 'fld1' to it:
fnum = ubase.newFile (path)

ubase.addField (fnum, 'fld1', stringType)

Errors An error is produced if uBASE is not running, if fnum does not identify an open database, or if some problem prevents adding the new Þeld to the database

Platform Notes uBASE runs only on Mac OS and is not a supported component of Frontier 5.0,

Notes The possible field types are:

booleanType true or false.

longType 32-bit signed number.

dateType the number of seconds since Jan 1, 1904.

stringType a variable length text handle.

doubleType double-precision ßoating point number.

binaryType unformatted data, variable-length.

In general, its best to add fields to a database before there are any records in it.

If a field is added to a database which contains records, ubase.lookupRecord will include an 'errn' entry with a value of 2 and an 'errs' entry in each table it produces for a record which lacks the new Þeld. The errs entry will cause lookupRecord to

return false. One solution is to visit each record, do ubase.lookupRecord on that record (ignoring the false result), add an entry for each missing Þeld to the table produced by ubase.lookupRecord, and add the completed record to the database replacing

the old record. [Consider copying the data from your existing database to a new database which has the additional Þelds, rather than adding Þelds to a database which contains records.]

See Also ubase.getField

ubase.lookupRecord

Discuss