The NCHACKS Library Package Xerox Corporation Randy Trigg [First written: 8/23/85 Randy Trigg] [Last updated: 8/18/87 Peggy Irish] [Code: {qv}1.3k>library>nchacks.dcom] [Doc: {qv}1.3k>library>nchacks.ted] This document describes a library package containing miscellaneous handy functions written using the programmer's interface for use in NoteCards Release 1.3k. It is hoped that you will find these useful not only for their functionality, but also as examples of the sort of code that can be written using the programmer's interface. I encourage any readers who have created such functions themselves to send me the code and a short description and I'll incorporate into this package. These functions all apply to groups of cards (and often to a notefile as well) and allow searching for text, global replacement of text, removal of deleted link icons, sorting of link icons, making link icons invisible, card collection by date, and creating chains of cards using a given link type. The following functions are applicable to sets of cards and allow global searching, replacing, and chain creation. For those that take a CardsOrNoteFile argument, it can either be single card, a list of cards or a notefile. In the latter case, the entire notefile is used. To allow user selection of cards, pass (NCP.SelectCards) as the CardsOrNoteFile argument. (NCHACKS.MakeChain takes a Cards argument which can either be a single card or a list of cards, but not a notefile.) (NCHACKS.TextSearch String WildCards? CardsOrNoteFile ReturnLocsFlg) This goes through the list of cards looking for occurrences of text string String. WildCards? being non-nil means wild card characters may appear in String. The pound sign character '#' matches any single character, asterisk '*' matches any sequence of characters, and single quote, "'" can be used to quote one of the wildcard characters. If ReturnLocsFlg is nil, then this just returns a list of cards containing at least one occurrence of String. If ReturnLocsFlg is non-nil, then this returns a list of lists. Each sublist has as first element a card ID followed by the locations of occurences of String. These are single integers if WildCards? is nil and correspond to the location of the first character of String in the text. If WildCards? is non-nil, then these are two element lists of start and end locations of the matching string. Any cards in Cards that are not TEdit-based cards are ignored (i.e. their card type must inherit from the Text card type). (NCHACKS.GlobalTextReplace String1 String2 WildCards? CardsOrNoteFile) This goes through the list of cards replacing every occurrence of text string String1 by String2. WildCards? being non-nil means wild card characters may appear in String1. The pound sign character '#' matches any single character, asterisk '*' matches any sequence of characters, and single quote, "'" can be used to quote one of the wildcard characters. Any cards in Cards that are not TEdit-based cards are ignored (i.e. their card type must inherit from the Text card type). (NCHACKS.RemoveDeletedIconsFromTextCards CardsOrNoteFile) This removes all deleted link icons from the TEdit-based cards in the list of cards. (NCHACKS.ReorderLinkIconsInTextCards CardsOrNoteFile OrderingFn QuietFlg) This moves link icons around in each of the TEdit-based cards in the list of cards so that they appear in sorted order. OrderingFn should be a function which accepts two link arguments (the destination cards of the links) and returns non-nil if the first should appear ahead of the second. OrderingFn can also be the atom ALPHABETIZE in which case NC.IDAlphOrder (orders by title of link's destination card) will be the ordering fn used. If OrderingFn is NIL, then the card's OrderingFn card prop is checked. If that card prop is NIL, then NC.IDAlphOrder is again used. (NCHACKS.MakeLinkIconsInvisible CardsOrLinksOrNoteFile Invisiblity) CardsOrLinksOrNoteFile should be one of: a card, a link, a list of cards and links, or a notefile. Make any link icons for given links or contained in given cards or notefile (but only those in TEdit-based cards) invisible or not depending on whether Invisibility is ON or OFF. (NCHACKS.DateSearch DateString1 DateString2 CardsOrNoteFile) This goes through the list of cards looking for occurrences of card parts modified between the dates DateString1 and DateString2. If DateString1 is NIL, then it defaults to a very early date. If DateString2 is NIL, then it defaults to current date. If you provide values for either DateString1 or DateString2, they should be strings in the same format as that returned by the (DATE) format, i.e. " 1-Jan-85 00:00:00". This returns a list of lists, one sublist for each card modified between the given dates. This sublist consists of the card ID followed by two-element lists containing the card part name that was modified and the date of last modification. For example, if there was one hit, you might get something like (({CardObject}#56,164470 (SUBSTANCEDATE "23-Aug-85 19:15:27") (TITLEDATE "23-Aug-85 19:15:44"))) (NCHACKS.ÿÿCardsModifiedÿBÿÿetweenDatesÿ CardsOrNoteFile CardTypes ModifiedRange LastModifiedRange CreatedRange) This function goes through the list of cards or the notefile looking for cards of types in CardTypes which satisfy all of these criteria: they were modified in the range ModifiedRange, and last modified in the range LastModifiedRange, and created in the range CreatedRange. Each range should be a list of two dates, each in the form DD-Mon-YY (i.e. " 1-Jan-85"). Any of the ranges may be NIL, which means not to include that type of modification/creation. If the first (earlier) date in a range is NIL, then it defaults to the earliest known date. If the second (later) date in a range is NIL, then it defaults to the current date. CardTypes should be a list of card types. CardsOrNoteFile should be a list of cards or an open notefile. The cards which meet all of the given criteria are returned in a list. Examples: (NCHACKS.ÿÿCardsModifiedÿBÿÿetweenDatesÿ (NCP.WNF) '(Text FileBox) ("3-Jul-87" "10-Jul-87") NIL NIL) would return all cards of type Text and FileBox in the notefile pointed to by the mouse which were modified between the dates of July 3, 1987 and July 10, 1987. (NCHACKS.ÿÿCardsModifiedÿBÿÿetweenDatesÿ (NCP.WNF) 'Text NIL ("1-Jun-87" NIL) (NIL "31-May-87")) would return all cards of type Text in the notefile pointed to by the mouse which were created on or before May 31, 1987, and last modified after June 1, 1987. (NCHACKS.MakeChain LinkType Cards Position AddCRFlg) This creates links between successive cards in Cards each of type LinkType positioned at Position. Thus the first card in Cards will be linked to the second, the second to the third, etc. (No link will be built from the last card in Cards.) Position should be in the same form as that accepted by NCP.CardAddText, i.e. either an integer location or one of the litatoms START or END. If the AddCRFlg is non-nil and Position is one of START or END, then a carriage return is inserted after the link icon in the case of START or before the link icon in the case of END. Any cards in Cards that are not TEdit-based cards are ignored (i.e. their card type must inherit from the Text card type). ((( TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN %#1/M—+äEXû{Gf{:UJ=D=¥“ K2  @¡ = 5;{£zº