(FILECREATED " 5-Sep-86 20:51:34" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH102.;2 5895   

      changes to:  (VARS RHTPATCH102COMS)
		   (FNS NC.DeleteNoteCards NC.ScavengeDatabaseFile)

      previous date: " 5-Sep-86 20:25:46" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH102.;1)


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

(PRETTYCOMPRINT RHTPATCH102COMS)

(RPAQQ RHTPATCH102COMS ((* * Change to NCCARDS)
			  (FNS NC.DeleteNoteCards)))
(* * Change to NCCARDS)

(DEFINEQ

(NC.DeleteNoteCards
  (LAMBDA (CardIdentifiers NoIndividualConfirmFlg DontClearFlg InterestedWindow QuietFlg 
			   NoGroupConfirmFlg Don'tPutToBeDeletedCardsFlg)
                                                             (* rht: " 5-Sep-86 20:50")
                                                             (* Delete note cards. If no card specified then get a 
							     list of note cards to be deleted.
							     Then delete these cards.)

          (* * fgh 11/11/85: Updated to handle new Card objects. Also split off main work of deleteing a single note card 
	  into NC.DeleteNoteCard function.)



          (* * kirk 21Feb86 Added InterestedWindow)



          (* * kirk 29Apr86 Now returns CardIdentifiers)



          (* * fgh 6/9/86 Added checks to see if other operations are in progress)



          (* * rht 7/4/86: Now checks that card is not read-only.)



          (* * kirk 18Aug86 Added main window for windowless cards.)



          (* * rht 8/29/86: Reorganized and added call to NC.SeverAllLinks to make deleting more efficient.
	  Added QuietFlg, NoGroupConfirmFlg and Don'tPutToBeDeletedCardsFlg args.)



          (* * rht 9/5/86: Now forces NoGroupConfirmFlg to be non-nil if NoIndividualConfirmFlg is NIL and only one card to 
	  delete.)


    (OR CardIdentifiers (SETQ CardIdentifiers (NC.SelectNoteCards NIL NIL 
									NC.DeleteSelectingMenu 
									InterestedWindow NIL 
						    "Please select the Note Cards to be deleted.")))

          (* * Kludge in case args are nil, say, when we're called from a card's menu.)


    (if (AND (NULL NoIndividualConfirmFlg)
		 (NULL NoGroupConfirmFlg)
		 (EQ (LENGTH (MKLIST CardIdentifiers))
		       1))
	then (SETQ NoGroupConfirmFlg T)
	       (SETQ QuietFlg T))

          (* * First collect cards that are deletable.)


    (LET ((CardsToDelete (for CardIdentifier in (MKLIST CardIdentifiers) bind Card
			    eachtime (BLOCK)
			    when (AND (SETQ Card (NC.CoerceToCard CardIdentifier))
					  (if (NOT (NC.TopLevelCardP Card))
					    else (NC.PrintMsg (NC.FetchWindow Card)
								  T "You cannot delete this FileBox."
								  (CHARACTER 13))
						   (DISMISS 1000)
						   (NC.ClearMsg (NC.FetchWindow Card)
								  T)
						   NIL)
					  (NC.CheckForNotReadOnly Card (NC.FetchWindow Card)
								    "Can't delete cards from a ")
					  (OR NoIndividualConfirmFlg
						(PROG1 (NC.AskYesOrNo 
							  "Are you sure you want to delete this?"
									  " -- " "Yes" (NULL 
										     DontClearFlg)
									  (OR (NC.FetchWindow
										  Card)
										InterestedWindow)
									  NIL NIL)
							 (NC.ClearMsg))))
			    collect Card))
	  (NumSpecified (LENGTH (MKLIST CardIdentifiers)))
	  NumToDelete)
         (SETQ NumToDelete (LENGTH CardsToDelete))
         (if (AND (GREATERP NumToDelete 0)
		      (if (EQUAL NumToDelete NumSpecified)
			  then (OR NoGroupConfirmFlg (PROG1 (NC.AskYesOrNo
								    (CONCAT "You've specified " 
									      NumToDelete 
									      " cards to delete."
									      (CHARACTER 13)
									      
							 "Are you sure you want to delete them? ")
								    NIL "Yes" (NULL DontClearFlg)
								    InterestedWindow)
								  (NC.ClearMsg)))
			else (PROG1 (NC.AskYesOrNo (CONCAT "Out of " NumSpecified 
								   " cards specified, "
								   (DIFFERENCE NumSpecified 
										 NumToDelete)
								   " are not deletable."
								   (CHARACTER 13)
								   "Want to delete the remaining " 
								   NumToDelete " cards? ")
							 NIL "Yes" (NULL DontClearFlg)
							 InterestedWindow)
					(NC.ClearMsg))))
	     then 

          (* * Mark UIDs of cards about to be deleted.)


		    (for Card in CardsToDelete do (NC.UIDPutProp (fetch (Card UID)
									    of Card)
									 (QUOTE AboutToBeDeletedFlg)
									 T))

          (* * Sever all links into and out of CardsToDelete)


		    (NC.SeverAllLinks CardsToDelete QuietFlg InterestedWindow 
					Don'tPutToBeDeletedCardsFlg)

          (* * Now delete the cards one at a time.)


		    (OR QuietFlg (NC.PrintMsg InterestedWindow T "Deleting cards: 1 out of " 
						  NumToDelete " ..."))
		    (for Card in CardsToDelete as i from 1 eachtime (BLOCK)
		       do (LET ((OperationInProgress (NC.OperationInProgress Card)))
			         (OR QuietFlg (if (ZEROP (REMAINDER i 10))
						    then (NC.PrintMsg InterestedWindow T 
									  "Deleting cards: "
									  i " out of " NumToDelete 
									  " ...")))
			         (if OperationInProgress
				     then (NC.PrintOperationInProgressMsg (NC.FetchWindow
										Card)
									      "Delete Card(s)" 
									      OperationInProgress)
				   else (NC.ProtectedCardOperation Card Delete% Card%(s%)
								     (NC.DeleteNoteCard Card)))))
		    (OR QuietFlg (NC.ClearMsg InterestedWindow T))
		    CardIdentifiers))))
)
(PUTPROPS RHTPATCH102 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (486 5813 (NC.DeleteNoteCards 496 . 5811)))))
STOP