As Time Goes By

These models suggest other edit types that you might find useful. The first one, which I call HRMIN (hour/minute), is a time of day format that excludes seconds and might, therefore, be more appropriate for an appointment calendar than the time edits supplied with the system.

HRMIN \ N N <":"> N N | N <":"> N N | N N <":00"> | N <M:00">

Figure 3.

We'll "parse" this dictionary entry so you can really see how the edit is put together.

First, the name of the edit can be up to seven characters long, not including punctuation symbols and embedded or leading blanks. The distinction between upper- and lowercase is not significant. The chosen name is entered in the left column on the edit definition screen. The "sentence" that defines the edit goes on the right. The names of other edits used in building the new edit must be surrounded either by spaces or punctuation marks. Otherwise (as in this example), the program wouldn't be able to distinguish between "N" and "NN," a possible but different edit. Elsewhere, spaces are optional, but useful for clarity.

The backslash entered by typing fc t r l : GD on the console, ¬°shift) rn on the DT-1 numeric keypad, tells the program to right-justify the entry in the field. The field length for an hour/minute field would be five spaces (" 12:30") although an entry might have as few as four characters (" 1:00"). The backslash must come first on the line if it is used.

"N" allows entry of digits from 0 to 9. The pipe symbol! separates the "or" possibilities from each other. The first of the four allowed entry formats (N N <":"> N N) says: the user can enter four digits, each of which can be any number from 0 to 9. If indeed four digits and only four digits are entered, the program will insert a colon (":") between the second and third digits. If the user enters a colon manually in that position, the program will let it be. Angle brackets (" <" and" >") surround any character that the field should accept if present in the proper position or supply if absent. If the character involved is a punctuation mark, it must be enclosed in quotes to distinguish it from the punctuation that the edit dictionary uses as instructions. Other characters need not be enclosed in quotes.

The second "or" group performs a similar operation, but deals with the case in which the user enters only three digits instead of four. The third group deals with the case of two digits by assuming that if only two digits are entered, the user is referring to the hour as opposed to the minutes, and so it fills in the format by adding ":00". The fourth case takes care of one-digit hours. If you enter a "2" the edit will expand the entry to "2:00".

The order of the "or" groups is important. The program examines each group one at a time, from left to right. If the data you try to enter into the field "fails" the first possibility, the program moves on to the second and so on. Therefore, the longest group should come first, with all other possibilities following in descending order. In my HRMIN edit, the four-digit possibility is first, followed by three, two, then one. It's easier to follow this rule religiously rather than try to predict when order matters and when it doesn't. Conversely, if you invent an edit that doesn't work the way you intended, and you've checked the punctuation, then examine the order of any "or" groups.

(PS. At the last minute, this edit was added to the Profile 16 as a system edit under the name "HM".)

Was this article helpful?

0 0

Post a comment