Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

Hands-On Exercise 3

generated description: handson.gif

For your next hands-on exercise, you will add error checking to your mydatent routine.

  • Write two public user-defined functions that use the pattern match operator to validate the Name and Phone, and write an error message for invalid data. Up to now you've been entering names as “First Last”, but your code should now validate names as “Last,First”.

  • Add a default area code to the Phone prompt, and a line to add this default to phone numbers without area codes.

  • Write a public user-defined function that uses $ZDateH to validate the Date of Birth, and convert it to internal format. The function should write an error message for invalid dates. Make sure it's a date in the past (before today).

  • Call the new user-defined functions from your prompts.

  • Use $ZDate to display the date, no matter how the user actually entered it, in one of the standard formats.

  • Save and run your routine, and test all three prompts with bad and good input.

For instructions, click below.

generated description: stepbystep.gif

Feedback