(FILECREATED "26-Mar-85 15:56:21" {PHYLUM}<NOTECARDS>RELEASE1.2>LIBRARY>TYPESMECHSAMPLE.;1 3754   

      changes to:  (VARS TYPESMECHSAMPLECOMS)
		   (FNS NC.GetPassword NC.AddProtectedTextCardType NC.EditProtectedTextCard 
			NC.MakeProtectedTextCard))


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT TYPESMECHSAMPLECOMS)

(RPAQQ TYPESMECHSAMPLECOMS ((FNS NC.AddProtectedTextCardType NC.EditProtectedTextCard NC.GetPassword 
				 NC.MakeProtectedTextCard)))
(DEFINEQ

(NC.AddProtectedTextCardType
  (LAMBDA NIL                                                (* fgh: "26-Mar-85 15:48")

          (* * Create the ProtectedText card type)


    (NCP.CreateCardType (QUOTE ProtectedText)
			(QUOTE Text)
			(QUOTE TEXT)
			(QUOTE ((MakeCardFn NC.MakeProtectedTextCard)
				 (EditCardFn NC.EditProtectedTextCard)))
			(QUOTE ((LinkDisplayMode (T NIL NIL))
				 (CardDefaultHeight 300)
				 (CardDefaultWidth 400)
				 (CardLinkAnchorModesSupported T)
				 (CardDisplayInMenuFlg T))))))

(NC.EditProtectedTextCard
  (LAMBDA (ID Substance Region/Position)                     (* fgh: "26-Mar-85 15:54")

          (* * Edit a Protected Text card, asking for the paswword first.)


    (PROG (ExactRegion Window Password Result)

          (* * Open a window for this card)


          (SETQ ExactRegion (NC.DetermineDisplayRegion ID Region/Position))
          (SETQ Window (CREATEW ExactRegion))

          (* * Get this card's password from the prop list)


          (SETQ Password (NCP.CardProp ID (QUOTE Password)))
          (COND
	    ((EQUAL Password (NC.GetPassword Window))        (* Password is okay. Call the EditCardFn of my 
							     super-type)
	      (SETQ Result (APPLY* (NCP.CardTypeInheritedField (QUOTE ProtectedText)
							       (QUOTE EditCardFn))
				   ID Substance Region/Position)))
	    (T                                               (* Password is bad. Express condole%nces)
	       (NCP.PrintMsg Window T "Sorry." (CHARACTER 13)
			     "You do not know the password!!"
			     (CHARACTER 13)
			     "Bye."
			     (CHARACTER 13))))

          (* * Close the window you created. The super-types EdityCardFn will have created another window.)


          (CLOSEW Window)
          (RETURN Result))))

(NC.GetPassword
  (LAMBDA (Window)                                           (* fgh: "26-Mar-85 15:50")

          (* * Get a password from the user. Window is the main window for the card in question)


    (NCP.AskUser "What is the password for this card?" " -- " NIL T Window)))

(NC.MakeProtectedTextCard
  (LAMBDA (ID Title NoDisplayFlg)                            (* fgh: "26-Mar-85 15:23")

          (* * Make a protected Text card by calling the make card fn for a Text card and then attaching a password to the 
	  card)


    (PROG (Window WindowOrID)

          (* * Create the Text card)


          (SETQ WindowOrID (APPLY* (NCP.CardTypeFn (NCP.CardTypeSuper (QUOTE ProtectedText))
						   (QUOTE MakeCardFn))
				   ID Title NoDisplayFlg))

          (* * Get the window for the card, if there is one)


          (SETQ Window (WINDOWP WindowOrID))

          (* * Get the password from the user and add it to the cards prop list)


          (NCP.CardProp ID (QUOTE Password)
			(NC.GetPassword Window))

          (* * Return whatever the super-type's MakeCardFn returned)


          (RETURN WindowOrID))))
)
(PUTPROPS TYPESMECHSAMPLE COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (507 3668 (NC.AddProtectedTextCardType 517 . 1066) (NC.EditProtectedTextCard 1068 . 2439
) (NC.GetPassword 2441 . 2738) (NC.MakeProtectedTextCard 2740 . 3666)))))
STOP