Progress
Programming
Handbook
Default Handling
When the ENDKEY condition occurs, Progress follows these steps:
FOR EACH blocks, REPEAT blocks, triggers, and procedure blocks have the endkey property by default. This means that each of these blocks implicitly has the ON ENDKEY UNDO, LEAVE phrase attached to it. The following two examples are the same:
This example shows how Progress handles ENDKEY:
p-txn8.p
![]()
The ON statement defines F9 as the ENDKEY. That is, when the user presses F9, Progress raises the ENDKEY condition. Progress searches for the closest block that has the ENDKEY property and undoes and leaves that block:
![]()
Before entering a sales rep value, press F9. Progress follow these steps:
- Raises the ENDKEY condition.
- Searches outward for the closest block that has the ENDKEY property. REPEAT blocks have the ENDKEY property, so Progress stops at the outer REPEAT block.
- Undoes all work done in the current iteration of the REPEAT block and leaves that REPEAT block. Since there are no statements to process after the END statement of the REPEAT block, Progress returns you to the Procedure Editor:
![]()
Press F9 while entering the second order–line. Progress follows these steps:
- Raises the ENDKEY condition.
- Searches outward for the closest block that has the ENDKEY property. REPEAT blocks have the ENDKEY property so Progress stops at the inner REPEAT block.
- Undoes all work done in the current iteration of the REPEAT block and leaves that iteration of the REPEAT block.
- After leaving the inner REPEAT block, the procedure continues with the next statement after the END of the inner block, encounters the END of the outer REPEAT block, and does the next iteration of the outer block.
Note that this means that the order record and first order–line record that you created are committed to the database. Only the second order–line record is undone.
If you are importing data from an operating system file, the ENDKEY condition occurs when you reach the end of the file. For example,
p-impeof.p
takes advantage of this:
Assume that
customer.d
contains three records. On the third pass through the REPEAT loop,p-impeof.p
creates a customer record and reads data from the last line from the file into that record. On the next pass through the loop, the procedure creates another customer record. However, the IMPORT statement fails because it has reached the end of the file. This causes the ENDKEY condition. The default behavior for ENDKEY undoes the current iteration of the REPEAT loop and therefore undoes the record creation.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |