/p/stat/Data/admin
.
Each database should have a ".form
" file associated with
it. The form file is emacs-lisp code that defines the fields for
forms mode. Thus "phd_info
" has its fields (and the
forms-mode display format) defined in "phd_info.form
".
~/.emacs
file, you will be able to use M-x
get-db
to begin editing a database.
(defun get-db nil "Use forms mode to edit an administrative database" (interactive) (let* ((db-directory "/p/stat/Data/admin/") (extension ".form") (elen (length extension))) (forms-find-file (concat db-directory (completing-read "Database: " (mapcar 'list (mapcar '(lambda (form-name) (substring form-name 0 (- elen))) ; strip off the extension (directory-files db-directory nil (concat ".*\\" extension "$") )))) extension))))The documentation for forms-mode can be found in the info pages accessed through
C-h i
in emacs.
% clean_fields.pl <db_name>This script creates a backup file before modifying the database. There is only one backup file, however, so be careful using this if you are not sure that your edits should be committed.
Some of these checks are also implemented in an emacs-lisp function
called db-check-fields
. The .form
file will
often define this function as the
forms-modified-record-hook
.
lastname
and firstname
), it can be
implemented as a forms-write-file-hook
.
For more complicated sorts, a sample perl script called
sort_phd_info.pl
is available in the database directory.
Only the first part of the script should ever need to be modified to
sort other databases. The database name and the comparison routine
are defined at the top. The names $a
and $b
are magic for the comparisons. The field names are those defined in
the .form
file associated with the database. They are
used as $a->{'grad-yr'}
, etc. In perl terminology, they
are used as the keys in a hash or associative array. The comparison
operator for numeric fields is "<=>
".
For text fields use "cmp
".
Because we often store the fields "lastname" and "firstname" but we
want to print them as "lastname, firstname", I call a subroutine
field_mod
before printing each record. The example
definition is
sub field_mod { $r->{'name'} = $r->{'lastname'} . ", " . $r->{'firstname'}; }If you don't need to modify any fields, just define this as an empty subroutine. Do not delete the definition entirely or perl will become confused.
That report uses some fancy facilities to split the thesis title over two lines while distributing the rest of the information on the two lines.
The report is designed to be printed by
% perl report_phd_info.pl | enscript -rBfCourier8
% S ... > PhDs <- read.table("/p/stat/Data/admin/phd_info", sep = "\t")to read the data into an S data frame. I usually also pull the field names out of the
.form
file and
assign them as the names attribute.
db_name.bak
file and the files in the OldFiles
directory.