Skip to main content

Hands-On Exercise 3

generated description: handson.gif

Let's get started with the lookup routine. This routine will allow lookups by name, phone, or date of birth. The instructions below contain suggested names and functionality for the subroutines you need to write.

  • Create a brand new Basic routine, called myBASlookup. It will have a main section at the beginning, and contain these subroutines: getsubmit, help, getdob, getphone, getname, display, and pick.

  • The main section will have a loop that calls getsubmit, which prompts the user for a string. The user may enter ? to get help, a full/partial name, a full/partial phone number, a date of birth, or press Enter to quit. In getsubmit, use validDOB@myBASdatent() to verify the date of birth. If the user enters ?, the help subroutine lists the lookup alternatives.

  • In getsubmit, if the user enters a valid date of birth, the getdob subroutine checks to see if the internal form of the date of birth is in ^PersonI, and then loops through the index to find all ids of the people with that date of birth.

  • In getsubmit, if the user enters a full or partial phone number (617, 617-621, or 617-621-0600), the getphone subroutine finds the matches. Use the three argument form of Traverse(). Note: you may inadvertently introduce a bug when writing getphone. The solution is in the step-by-step guide.

  • In getsubmit, if the user enters a full or partial name (Smith,John; Smith, J; Sm, John; Sm, J), the getname subroutine finds the matches. Use formatName@myBASdatent() to format the name before searching.

  • For any list of matches, each person is displayed using the display subroutine, which should accept the id as a parameter, and print all the data for the person. display also takes an additional argument, either “line” or “table”. Use “line” for displaying matches in a list horizontally, and “table” for displaying the user's single choice vertically, using display@myBASdatent().

  • Keep track of the matches you display using a local array to associate the match number that the user sees with the id number of the match. Write a pick subroutine to allow the user to choose a match.

For instructions, click below.

generated description: stepbystep.gif

FeedbackOpens in a new tab