(FILECREATED "24-Oct-85 00:02:44" {QV}<NOTECARDS>RELEASE1.2I>LIBRARY>NCHACKS.;4 11857 changes to: (FNS NCHACKS.ReorderLinkIconsInTextCards) previous date: "20-Oct-85 17:38:26" {QV}<NOTECARDS>RELEASE1.2I>LIBRARY>NCHACKS.;2) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT NCHACKSCOMS) (RPAQQ NCHACKSCOMS ((FNS NCHACKS.GlobalTextReplace NCHACKS.TextSearch NCHACKS.DateSearch NCHACKS.MakeChain NCHACKS.RemoveDeletedIconsFromTextCards NCHACKS.ReorderLinkIconsInTextCards))) (DEFINEQ (NCHACKS.GlobalTextReplace (LAMBDA (String1 String2 WildCards? Cards) (* rht: "26-Aug-85 12:11") (* * There should be an open notefile. This goes through the Cards list replacing every occurrence of text string String1 by String2. WildCards? non-nil means wild card characters may appear in String1. # matches any single character, * matches any sequence of characters, and ' can be used to quote one of the wildcard characters.) (for Card in (MKLIST Cards) bind (Length ←(NCHARS String1)) WasActiveFlg when (AND (NCP.ValidCard Card) (EQ (NCP.CardTypeSubstance (NCP.CardType Card)) (QUOTE TEXT))) do (if (NOT (SETQ WasActiveFlg (NCP.ActiveCardP Card))) then (NCP.ActivateCards Card)) (for bind (Loc ← 0) (TextStream ←(NCP.CardSubstance Card)) while (SETQ Loc (TEDIT.FIND TextStream String1 (ADD1 Loc) NIL WildCards?)) do (if WildCards? then (SETQ Length (ADD1 (DIFFERENCE (CADR Loc) (CAR Loc)))) (SETQ Loc (CAR Loc))) (TEDIT.DELETE TextStream Loc Length) (TEDIT.INSERT TextStream String2 Loc)) (if (NOT WasActiveFlg) then (NCP.DeactivateCards Card))))) (NCHACKS.TextSearch (LAMBDA (String WildCards? Cards ReturnLocsFlg) (* rht: "26-Aug-85 12:10") (* * There should be an open notefile. This goes through the Cards list looking for occurrences of text string String. WildCards? non-nil means wild card characters may appear in String. # matches any single character, * matches any sequence of characters, and ' can be used to quote one of the wildcard characters. If ReturnLocsFlg is nil, then just return list of cards containing at least one occurrence of String. If ReturnLocsFlg is non-nil, then return a list of lists. Each list has first element a card id followed by the locations of occurrences of String. These are single integers is WildCards? is nil. If WildCards? is non-nil, then these are lists of start and end locations of the matching string.) (for Card in (MKLIST Cards) bind (Length ←(NCHARS String)) WasActiveFlg Hits TextStream when (AND (NCP.ValidCard Card) (EQ (NCP.CardTypeSubstance (NCP.CardType Card)) (QUOTE TEXT))) join (if (NOT (SETQ WasActiveFlg (NCP.ActiveCardP Card))) then (NCP.ActivateCards Card)) (SETQ TextStream (NCP.CardSubstance Card)) (PROG1 (if ReturnLocsFlg then (if (SETQ Hits (for bind (Loc ← 0) while (SETQ Loc (TEDIT.FIND TextStream String (ADD1 Loc) NIL WildCards?)) collect (PROG1 Loc (if WildCards? then (SETQ Loc (CAR Loc)))))) then (LIST (CONS Card Hits))) else (if (TEDIT.FIND TextStream String NIL NIL WildCards?) then (LIST Card))) (if (NOT WasActiveFlg) then (NCP.DeactivateCards Card)))))) (NCHACKS.DateSearch (LAMBDA (DateString1 DateString2 Cards) (* rht: "23-Aug-85 00:00") (* * There should be an open notefile. This goes through the Cards list looking for occurrences of card parts modified between the dates DateString1 and DateString2. If DateString1 is NIL, then defaults to a very early date. If DateString2 is NIL, then defaults to current date.) (LET ((IDate1 (OR (IDATE (OR DateString1 " 1-Jan-70 00:00:00")) (IDATE " 1-Jan-70 00:00:00"))) (IDate2 (OR (IDATE (OR DateString2 (DATE))) (IDATE (DATE))))) (for Card in (MKLIST Cards) bind WasActiveFlg Dates Hits IDate Date join (if (NOT (SETQ WasActiveFlg (NCP.ActiveCardP Card))) then (NCP.ActivateCards Card)) (SETQ Dates (NCP.GetCardDates Card)) (SETQ Hits (LDIFFERENCE (LIST (if (AND (LESSP IDate1 (SETQ IDate (IDATE (SETQ Date (fetch (NOTECARDDATES SUBSTANCEDATE) of Dates))))) (LESSP IDate IDate2)) then (LIST (QUOTE SUBSTANCEDATE) Date)) (if (AND (LESSP IDate1 (SETQ IDate (IDATE (fetch (NOTECARDDATES LINKSDATE) of Dates)))) (LESSP IDate IDate2)) then (LIST (QUOTE LINKSDATE) Date)) (if (AND (LESSP IDate1 (SETQ IDate (IDATE (fetch (NOTECARDDATES TITLEDATE) of Dates)))) (LESSP IDate IDate2)) then (LIST (QUOTE TITLEDATE) Date)) (if (AND (LESSP IDate1 (SETQ IDate (IDATE (fetch (NOTECARDDATES PROPLISTDATE) of Dates)))) (LESSP IDate IDate2)) then (LIST (QUOTE PROPLISTDATE) Date))) (LIST NIL))) (PROG1 (if Hits then (LIST (CONS Card Hits)) else NIL) (if (NOT WasActiveFlg) then (NCP.DeactivateCards Card))))))) (NCHACKS.MakeChain (LAMBDA (LinkType Cards Position AddCRFlg) (* rht: "26-Aug-85 12:12") (* * Create links between successive cards in Cards each of type LinkType positioned at Position.) (for RestOfCards on Cards bind (LastCard ←(CAR (LAST Cards))) Card until (EQ (SETQ Card (CAR RestOfCards)) LastCard) when (AND (NCP.ValidCard Card) (EQ (NCP.CardTypeSubstance (NCP.CardType Card)) (QUOTE TEXT))) do (COND ((AND AddCRFlg (EQ Position (QUOTE END))) (NCP.CardAddText Card (CHARACTER 13) Position))) (NCP.LocalGlobalLink LinkType Card (CADR RestOfCards) Position) (COND ((AND AddCRFlg (EQ Position (QUOTE START))) (NCP.CardAddText Card (CHARACTER 13))))))) (NCHACKS.RemoveDeletedIconsFromTextCards (LAMBDA (Cards) (* rht: "26-Aug-85 12:11") (* * For cards in Cards of substance type TEXT, remove all deleted link icons from their substance.) (for Card in Cards bind Type TextStream WasActiveFlg when (AND (NCP.ValidCard Card) (EQ (NCP.CardTypeSubstance (SETQ Type (NCP.CardType Card))) (QUOTE TEXT))) do (OR (SETQ WasActiveFlg (NCP.ActiveCardP Card)) (NCP.ActivateCards Card)) (if (EQ (NCP.CardTypeSubstance (SETQ Type (NCP.CardType Card))) (QUOTE TEXT)) then (SETQ TextStream (NCP.CardSubstance Card)) (for IconPair in (APPLY* (NCP.CardTypeInheritedField Type (QUOTE CollectLinksInCardFn)) Card NIL PSA.Database T T) do (TEDIT.DELETE TextStream (CADR IconPair) 1))) (OR WasActiveFlg (NCP.DeactivateCards Card))))) (NCHACKS.ReorderLinkIconsInTextCards (LAMBDA (Cards OrderingFn QuietFlg) (* rht: "24-Oct-85 00:01") (* * Resort the link icons occuring in Cards according to OrderingFn. If the latter is NIL, then use the OrderingFn prop of the card. If OrderingFn is the litatom ALPHABETIZE, then use NC.IDAlphOrder. Print message to prompt window unless QuietFlg is non-nil.) (if (EQ OrderingFn (QUOTE ALPHABETIZE)) then (SETQ OrderingFn (FUNCTION NC.IDAlphOrder))) (for Card in (MKLIST Cards) bind LinkIconsAndLocs WasActiveFlg SortedIDsAndLocs OrderingFnToUse TextObj TextStream OldEndLoc eachtime (BLOCK) when (if (AND (NCP.ValidCard Card) (EQ (NCP.CardTypeSubstance (NCP.CardType Card)) (QUOTE TEXT))) else (NC.PrintMsg NIL NIL "Can't sort icons in " Card ". Either invalid card or not TEXT substance.") NIL) do (OR QuietFlg (NCP.PrintMsg NIL T "Sorting link icons in " Card " ...")) (if (NOT (SETQ WasActiveFlg (NCP.ActiveCardP Card))) then (NCP.ActivateCards Card)) (if (SETQ OrderingFnToUse (OR OrderingFn (NCP.CardProp Card (QUOTE OrderingFn)))) then (SETQ TextStream (NCP.CardSubstance Card)) (SETQ TextObj (TEXTOBJ TextStream)) (SETQ LinkIconsAndLocs (TEDIT.LIST.OF.OBJECTS TextObj (FUNCTION NC.LinkIconImageObjP))) (SETQ SortedIDsAndLocs (SORT (for LinkIconAndLoc in LinkIconsAndLocs as i from 0 eachtime (BLOCK) collect (LIST (NCP.GetLinkDestination (NC.FetchLinkFromLinkIcon (CAR LinkIconAndLoc))) (CADR LinkIconAndLoc))) (FUNCTION (LAMBDA (IDAndLoc1 IDAndLoc2) (APPLY* OrderingFnToUse (CAR IDAndLoc1) (CAR IDAndLoc2)))))) (for RestOfSortedIDsAndLocs on SortedIDsAndLocs as LinkIconAndLoc in LinkIconsAndLocs eachtime (BLOCK) bind Loc FromLoc ToLoc Sel1 Sel2 do (* * Location to move FROM is taken from next pair in sorted list.) (TEDIT.SETSEL TextObj (SETQ FromLoc (CADAR RestOfSortedIDsAndLocs)) 1 (QUOTE LEFT)) (SETQ Sel1 (TEDIT.GETSEL TextStream)) (* * Location to move TO is just next pair on unsorted list, except that there may be intervening guys that will later move out of the way.) (TEDIT.SETSEL TextObj (SETQ ToLoc (PLUS (SETQ Loc (CADR LinkIconAndLoc)) (for IDAndLoc in (CDR RestOfSortedIDsAndLocs) eachtime (BLOCK) when (LESSP (CADR IDAndLoc) Loc) count IDAndLoc))) 0 (QUOTE LEFT)) (SETQ Sel2 (TEDIT.GETSEL TextStream)) (TEDIT.MOVE Sel1 Sel2) (* * Now increment any locs of pairs whose location has changed by virtue of this move.) (for IDAndLoc in (CDR RestOfSortedIDsAndLocs) bind Loc eachtime (BLOCK) when (AND (LESSP (SETQ Loc (CADR IDAndLoc)) FromLoc) (LEQ ToLoc Loc)) do (RPLACA (CDR IDAndLoc) (ADD1 Loc))))) (if (NOT WasActiveFlg) then (NCP.DeactivateCards Card)) (OR QuietFlg (NCP.PrintMsg NIL NIL "Done."))))) ) (PUTPROPS NCHACKS COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (545 11779 (NCHACKS.GlobalTextReplace 555 . 1940) (NCHACKS.TextSearch 1942 . 3864) ( NCHACKS.DateSearch 3866 . 6103) (NCHACKS.MakeChain 6105 . 7022) ( NCHACKS.RemoveDeletedIconsFromTextCards 7024 . 8124) (NCHACKS.ReorderLinkIconsInTextCards 8126 . 11777 ))))) STOP