- In the Class Browser, select the AddBookForm.
- In the properties window, select buttonOK.
- In the methods window, select click.
A method skeleton for the buttonOK_click method is displayed.
- Select the code on the right by clicking and dragging.
- Copy it to the clipboard.
- Paste the code into the skeleton method.
- Select the Methods | Compile Method menu command.
The status line displays a message
«Compilation complete - no errors»
- Run your application
and add a new book.
- Return to the Class Browser to check that the book is in the database.
- Select the Book class.
- Select the Classes | Inspect Instances menu command.
A database inspector window is displayed.
- Click the last Book object to view its details.
- Close the inspector windows by selecting the File | Close All menu command.
|
buttonOK_click(btn: Button input) updating;
vars
bk : Book; // bk is a variable of type Book
begin
beginTransaction; // required for database changes
// create a Book object and set its properties
create bk;
bk.title := textBoxTitle.text;
bk.isbn := textBoxIsbn.text;
bk.author := textBoxAuthor.text;
commitTransaction; // update and release locks
// clear text boxes and display message on status line
textBoxTitle.text := null;
textBoxIsbn.text := null;
textBoxAuthor.text := null;
statusLine.caption := 'Book "' & bk.title & '" added';
end; |
|