(DEFINE-FILE-INFO PACKAGE "IL" READTABLE "INTERLISP" BASE 10)
(FILECREATED "13-Oct-88 19:39:13" {QV}<NOTECARDS>1.3MNEXT>NCSEARCHCARD.;1 5657   

      previous date%: "13-Aug-88 15:22:59" {QV}<NOTECARDS>1.3LNEXT>NCSEARCHCARD.;5)


(* "
Copyright (c) 1986, 1987, 1988 by Xerox Corporation.  All rights reserved.
")

(PRETTYCOMPRINT NCSEARCHCARDCOMS)

(RPAQQ NCSEARCHCARDCOMS
       (

(* ;;; "Stuff for the Notecards search card.")

        (DECLARE%: DONTEVAL@LOAD (FILES NCTEXTCARD))
        (FNS NCAddStub.SearchCard)
        (FNS NC.MakeSearchCard NC.AddSearchCard NC.TitleSearch)
        (DECLARE%: DONTEVAL@LOAD (P (NC.AddSearchCard)))
        (PROP (FILETYPE MAKEFILE-ENVIRONMENT)
              NCSEARCHCARD)))



(* ;;; "Stuff for the Notecards search card.")

(DECLARE%: DONTEVAL@LOAD 

(FILESLOAD NCTEXTCARD)
)
(DEFINEQ

(NCAddStub.SearchCard
  (LAMBDA NIL                                                (* rht%: " 8-Nov-86 19:20")
          
          (* * kirk 18Jun86 Add the Search card stub)
          
          (* * rht 11/7/86%: Now passes down a \\FILLME// field.)

    (NC.AddCardTypeStub 'Search 'Text 'NCSEARCHCARD NIL '((DisplayedInMenuFlg T)) '(
                                                                               LinkIconAttachedBitMap
                                                                                    ))))
)
(DEFINEQ

(NC.MakeSearchCard
  [LAMBDA (Card Title NoDisplayFlg ParamList InterestedWindow RegionOrPosition)
                                                             (* ; "Edited  5-Aug-88 13:53 by Trigg")

    (* ;; "Search for cards with specified characteristics and create a list card containing pointers to these cards.  For now search is limited to cards whose title contains a specified string.")

    (* ;; "rht 11/8/84: Fixed some confusion between ListCardID and ID variables.")

    (* ;; "fgh 11/17/85 Updated to handle multiple notefiles and crad objects.")

    (* ;; "rht 4/11/86: changed to call NC.ApplySuper.")

    (* ;; "rht 10/21/86: Now deletes card if no search string specified.")

    (* ;; "rg 3/16/87 NC.DeleteNoteCards -> NC.DeleteNoteCard")

    (* ;; "rht 8/5/88: Added RegionOrPosition arg and passed to super's makefn.  Also added ParamList and InterestedWindow args.")

    (LET ((NoteFile (fetch (Card NoteFile) of Card))
          SearchString HitCards WindowOrCard Window)
         (SPAWN.MOUSE)
         (SETQ WindowOrCard (NC.ApplySupersFn MakeFn Card (OR Title "SearchCard")
                                   NoDisplayFlg ParamList InterestedWindow RegionOrPosition))
         (NC.ActivateCard Card)
         (SETQ Window (AND (WINDOWP WindowOrCard)
                           WindowOrCard))
         (SETQ SearchString (NC.AskUser "Please enter the search string: " NIL NIL T (OR Window 
                                                                                     InterestedWindow
                                                                                         )))
         (if (OR (EQUAL SearchString "")
                 (NOT SearchString))
             then (NC.DeleteNoteCard Card NIL T)
                  NIL
           else [NC.SetTitle Card (SETQ Title (OR Title (CONCAT "Cards with %"" SearchString 
                                                               "%" in title"]
                (AND Window (WINDOWPROP Window 'TITLE Title))
                (RESETLST
                    (RESETSAVE (CURSOR WAITINGCURSOR))
                    (NC.PrintMsg (OR Window InterestedWindow)
                           T "Searching for cards ...")
                    (SETQ HitCards (NC.TitleSearch NoteFile SearchString))
                    (TEDIT.INSERT (NC.FetchSubstance Card)
                           (CONCAT " List compiled on: " (DATE)
                                  (CHARACTER 13)
                                  (CHARACTER 13))
                           1)
                    (for HitCard in HitCards unless (EQ HitCard Card)
                       do (NC.InsertLinkBeforeMarker Card HitCard NC.ListContentsLinkLabel NIL NIL))
                    (NC.PrintMsg (OR Window InterestedWindow)
                           NIL "Done!" (CHARACTER 13)))
                (BLOCK 250)
                (NC.ClearMsg (OR Window InterestedWindow)
                       T)
                WindowOrCard])

(NC.AddSearchCard
  (LAMBDA NIL                                                (* ; "Edited  3-Dec-87 19:01 by rht:")
          
          (* * fgh |11/14/85| Updated to ri of substance type param to add card type.)

    (NC.AddCardType 'Search 'Text `((MakeFn ,(FUNCTION NC.MakeSearchCard)))
           `((LinkDisplayMode Title)
             (DisplayedInMenuFlg ,T)))))

(NC.TitleSearch
  (LAMBDA (NoteFile SearchString)                            (* rht%: "25-Mar-87 15:17")
          
          (* * Searchs all cards on NoteFile for ones with SearchString in their title.)
          
          (* * rht 3/25/87%: Now only looks at non-deleted cards.)

    (NC.MapCards NoteFile (FUNCTION (LAMBDA (Card)
                                      Card))
           (FUNCTION (LAMBDA (Card)
                       (AND (NC.ValidCardP Card)
                            (STRPOS SearchString (NC.RetrieveTitle Card))))))))
)
(DECLARE%: DONTEVAL@LOAD 

(NC.AddSearchCard)
)

(PUTPROPS NCSEARCHCARD FILETYPE :TCOMPL)

(PUTPROPS NCSEARCHCARD MAKEFILE-ENVIRONMENT (:PACKAGE "IL" :READTABLE "INTERLISP" :BASE 10))
(PUTPROPS NCSEARCHCARD COPYRIGHT ("Xerox Corporation" 1986 1987 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (837 1382 (NCAddStub.SearchCard 847 . 1380)) (1383 5359 (NC.MakeSearchCard 1393 . 4431) 
(NC.AddSearchCard 4433 . 4807) (NC.TitleSearch 4809 . 5357)))))
STOP