User`s manual
Example – Creating and Using a Phone Book
5-83
Description of Function pb_keyfilter
The pb_keyfilter function takes an argument key, which is a name used as a
key in the hash table, and either filters it for storage or unfilters it for display.
The filter, which replaces each space in the key with an underscore (
_), makes
the key usable with the methods of
java.util.Properties.
function out = pb_keyfilter(key)
if ~isempty(findstr(key,' '))
out = strrep(key,' ','_');
else
out = strrep(key,'_',' ');
end;
Running the phonebook Program
In this sample run, a user invokes phonebook with no arguments. The user
selects menu action
5, which displays the two entries currently in the phone
book (all entries are fictitious). Then, the user selects
2, to add an entry. After
adding the entry, the user again selects
5, which displays the new entry along
with the other two entries.
Phonebook Menu:
1. Look up a phone number
2. Add an entry to the phone book
3. Remove an entry from the phone book
4. Change the contents of an entry in the phone book
5. Display entire contents of the phone book
6. Exit this program
Please type the number for a menu selection: 5
-------------------------
Sylvia Woodland
(508) 111-3456
-------------------------
-------------------------
Russell Reddy
(617) 999-8765
-------------------------