[comp.sys.mac.hypercard] Help on password protection

glen@cory.Berkeley.EDU (Glen Rosendale) (03/07/89)

I'm hoping that somebody can help me, and that I'm also not raising a
question that's already been hashed to death (probably a dead certainty
anyway).  I'm part of a team that's creating tutorial courseware for an
introductory EE course at UC Berkeley, using Hypercard on an SE.  We want to
make our efforts available to the students as soon as we can, but need to be
careful about the security of the Mac.  Specifically, we want to make the
tutorial stack the startup file, and prevent users from getting out of
Hypercard to the finder without a password (so that the team members can get
to the other programs on disk).  Is there an existing stack/xcmd/whatever
that will accomplish this end? Can anybody gently rub my nose in the obvious
solution that I'm patently disregarding?

Replies via email, please--I will post a summary if people wish.
Any and all help will be appreciated.

Glen Rosendale (glen@cory.berkely.edu)
-------------------------------------------------------------------------------
| Glen Rosendale	|    UC Berkeley	|  glen@cory.berkeley.edu     |
| ++++++++++++++	|    ===========    	|  ----------------------     |
-------------------------------------------------------------------------------

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (03/08/89)

In article <10738@pasteur.Berkeley.EDU> glen@cory.Berkeley.EDU (Glen Rosendale) writes:
[ is making a tutorial system in HyperCard, and wants to 1) launch directly
into the tutorial, and 2) prevent users from quitting to the Finder unless
they have the correct password.]

(I am posting this because it illustrates a general technique others may
find useful.)

When the user chooses a menu item, HyperCard sends a "doMenu" message to
the current card. The message's parameter consists of the text of the menu
item.

Like many HyperCard messages, doMenu can be intercepted by a script before
it is executed by HyperCard. You can set up a script to intercept the "Quit"
item as follows:

  on doMenu theItem
    if theItem is "Quit HyperCard" then
      beep
      ask password "Please type the access password."
      if it is not "the password" then -- or whatever password you want
        beep
        answer "Sorry, you do not have authorization to Quit this stack."
      else
        pass doMenu
      end if
    else
      pass doMenu -- THIS LINE IS VERY IMPORTANT!
    end if
  end doMenu

A few notes about this handler:
 - You must remember to pass doMenu commands other than Quit. If you neglect
to do so, you will lock yourself out of all menu items.
 - You may want to trap doMenu "Open..." as well, since otherwise the user
could go to another stack and Quit from there.

As for your other question: you can set HyperCard as the startup application
in the Finder, then place a command to go to the selected stack in the Home
stack's openStack handler.

jeanne a. e. devoto
jdevoto@apple.com

boz@eleazar.dartmouth.edu (John Boswell) (03/09/89)

Just my $0.02:

	Simply putting an "on doMenu" item will not prevent someone from
typing commands directly from the msg box.  (Such as "open _document_ with
Microsoft Word", or "Go stack foo").  You should also trap for unauthorized
departure by putting an "on closeStack" handler in the stack script.  This 
handler could ask for a password, etc.

			Hope this helps,

*************************************************************************
 John Boswell 			  	 	boz@eleazar.dartmouth.edu	
 Dept. of Chemistry		 		boz@dartCMS1.BITNET		
 Dartmouth College, Hangover, Nude Hampster  03755