The button caption is initally 'Start'.
If you click the 'Start' button a timer starts,
which signals the borrower every second.
You previously coded the borrower's response
the check out or check in of a randomly selected book.
While borrowing starts the caption is changed to 'Stop'.
If you click the 'Stop' button the timer stops signalling the borrower,
which stops the checking out and checking in.
Change the 1000 milliseconds timer period if you want.
Instructions
- In the Class Browser, select the RandomBorrowerForm.
- In the properties window, select buttonStartStop.
- In the methods window, select click.
- Copy and compile the code on the right.
|

buttonStartStop_click(btn : Button input) updating;
begin
if btn.caption = "Start" then
myBorrower.beginTimer(1000, Timer_OneShot, 0);
btn.caption := "Stop";
else
myBorrower.endTimer(0);
btn.caption := "Start";
endif;
end; |
|