;;; welcome.mhtml: -*- Meta-HTML -*- 

;;;  Copyright (c) 1996 Universal Access Inc.
;;;  Author: Henry Minsky (hqm@ua.com) Fri Sep  6 16:09:26 1996.

<set-var title="MSQL Rolodex Example">
<include header.mhtml>
<include rolodex.mhtml>

<h2>Example MSQL Rolodex Application</h2>

<plain-text>
Welcome to the sample Rolodex application. This is an example of 
how to interface to an MSQL database using Meta-HTML's database
access operators.

The file rolodex.mhtml contains the pointers to the database host
server, localhost by default. Your MSQL database administrator must
create a database called "rolodex" on the MSQL server, in order for
this application to work.

Click on a letter to see entries whose last names begin with
that letter, or on "*" to see all entries.
</plain-text>

;;; Display the database as a list of entries, or an index
;;; if no name is supplied.
;;;
;;; If we get a single letter passed in the variable ind, and
;;; we should list all entries whose last name starts with that letter.

<if <match <get-var posted::action> "Create">
    <prog
      <set-var entry-name=<get-var matching>>
      <redirect add-entry.mhtml?<cgi-encode entry-name>&new-entry=true>>>



;;; We save the last matching string which was selected
;;; in a session-var, so it sticks around until someone
;;; changes it explicitly through posting the Find form.
<if <get-var matching>
    <set-session-var matching = <get-var matching>>>

<set-var matching = <get-session-var matching>>

;;; Display control buttons for adding, viewing, and sorting task list.

<center>
  <show-navbar>
</center>



;;; If the matching criterion is a single letter, find all
;;; last names which match. Last name is defined as the
;;; starting letter of any but the first name. Crude but
;;; generally effective.
;;;
;;; A match string of * means show whole database.

<when <get-var matching>>
  <if <match <get-var matching> "^[A-Z]$">
      <show-people-list "% <get-var matching>%">
    <if <match <get-var matching> "^\\*$">
	<show-people-list "%">
      <prog
	;;; Convert * to % wildcard
	<subst-in-var matching "\\*" "%">
	;;; Make a case insensitive regex search string.
	<subst-in-var matching "([a-zA-Z])" 
		      "[<verbatim><downcase \\1><upcase \\1></verbatim>]">
	<show-people-list "%<get-var matching>%">>>>
</when>

<include footer.mhtml>
