Navigating records

Now that we can add records, we need a means to scroll through them. This is where the Next and Previous command buttons come into play. To accomplish this, we will create two procedures.

How to do it…

In the address book file, enter the following text at the location defined in our main page for procedures, as defined within the comments after the previous section's procedures.

 proc nextRecord {} { global currentRecord global recordCount if {$currentRecord < $recordCount} { # Clear current entries clearRecord incr currentRecord loadRecord } } proc previousRecord {} { global currentRecord global recordCount if {$currentRecord > 1} { # Clear current entries clearRecord set currentRecord [expr $currentRecord - 1] loadRecord } } ...

Get Tcl/Tk 8.5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.