|INM V12 Database for Director||Windows, Macintosh||General database and table use||All regular version |
The reason why database's exist is essentially for the storage of information. It is thus primordial to understand how to add, edit and erase records. Once you have created your database, this technote will explain how it simple it really is to "work" with a V12 Database file.
Adding Records to a Database
To add a new record to a V12 Database table, use mAddRecord. Calls to mAddRecord must be balanced by mUpdateRecord.
In the following example, a new record is created for the item "goggles" and its price is set to $158.99:
mSetField(gTable, "ItemName", "Goggles")
mSetField(gTable, "Price", 158.99)
If mUpdateRecord is not called, the record created with mAddRecord is not saved to the database. The only V12 Database method that can be called after mAddRecord and before mUpdateRecord are mSetField and mSetMedia, any other call will cancel the new record.
Editing a Record in a Database
Writing data is accomplished with mSetField. Prior to updating a field, you must set the current record, and your intentions must be indicated in V12 Database with mEditRecord. Once this is completed, V12 Database will update your database with mUpdateRecord.
Deleting a Record from a Database
Call mDeleteRecord to delete the current record or a table. The following line will delete the current record in the table "gTable".
After calling mDeleteRecord, the record which follows the record being deleted becomes the new current record. If no record follows the deleted record, the preceding record becomes the new current record. If no record precedes the deleted record, the selection is then empty and the current record is not defined.
Call mSelDelete to delete all the records of a selection at once.
After mSelDelete has been completed, the selection is empty and the current record is undefined.
Browsing records in a database
You can browse your selection with mGoNext, mGoPrevious, mGoFirst and mGoLast. You always have to specify the table you wish to browse in parenthesis.
If you try to do mGoPrevious while on the first record or mGoNext while on the last record, the current record does not change and a warning is reported by INM V12 Database.
For advanced information about adding, editing or browsing selections, please consult the V12 Database user manual. We also suggest that you download the following sample, which is a simple example that will easily show you how to deal with records in a V12 Database file.
This sample is supported on Director 6.5 and later.