Hands-On Exercise 7
Like the last exercise, the final exercise is also lengthy. You'll complete the lookup class by adding edit and delete capabilities to ObjectScript.Lookup2.
-
Before working on ObjectScript.Lookup2, update Store() in ObjectScript.DataEntry4 to use TStart and TCommit to make sure that all the updates to the globals are part of a transaction.
-
Add code to TakeAction() that asks the user if they want to delete the record, and if so, call a new Delete() method.
-
Write the Delete() method. It should lock the record, get the record's data into separate variables, start a transaction, use Kill to delete the record from the data global and the indexes, commit the transaction, and unlock the record.
-
Add code to TakeAction() that asks the user if they want to edit the record, and if so, call a new Edit() method.
-
Write the Edit() method. It should lock the record, call a new Reprompt() method to prompt for new answers, use $ListSame to compare the current answers with the new answers to see if anything was changed, call a new Update() method to update the data global and the indexes, and unlock the record.
-
Write the Reprompt() method. It's similar, but not identical, to Prompt() from ObjectScript.DataEntry4. It should use the three validation methods from ObjectScript.DataEntry4. It should also display the current data within the prompts so that the user knows what they're changing.
-
Write the Update() method. It should start a transaction, and store the new answers in ^PersonD. Next, it should update ^PersonI. Updating an index means using Kill on the old entries in the index and using Set to add the new entries. Finally, it should commit the transaction.
For instructions, click below.