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 } }
How it works…
These procedures simply increment or decrement the record counter if it is within the range of the number of records and then calls our previously created procedure to load the record.