home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / hl10osrc.lzh / EditLibr / DeleteStuff.cc next >
Text File  |  1994-04-23  |  3KB  |  123 lines

  1. /* -*- Mode: C -*- */
  2. /* DeleteStuff.cc - Delete functions
  3.  * Created by Robert Heller on Sat Dec 14 00:11:12 1991
  4.  *
  5.  * ------------------------------------------------------------------
  6.  * Home Libarian by Deepwoods Software
  7.  * Edit a Librarian Card Catalog file
  8.  * ------------------------------------------------------------------
  9.  * Modification History:
  10.  * ------------------------------------------------------------------
  11.  * Contents:
  12.  * ------------------------------------------------------------------
  13.  * 
  14.  * 
  15.  * Copyright (c) 1991,1992 by Robert heller (D/B/A Deepwoods Software)
  16.  *        All Rights Reserved
  17.  * 
  18.  */
  19.  
  20. #include <stream.h>
  21. #include <vBTree.h>
  22. #include <ctype.h>
  23. #ifdef MESSYDOS
  24. #include <CardRec.h>
  25. #include <ListRec.h>
  26. #else
  27. #include <CardRecord.h>
  28. #include <ListRecord.h>
  29. #endif
  30. #include <Terminal.h>
  31. #ifdef MESSYDOS
  32. #include <CmdScren.h>
  33. #include <ScrPmt.h>
  34. #else
  35. #include <CommandScreen.h>
  36. #include <ScrollPrompt.h>
  37. #endif
  38. #include "EditDefs.h"
  39. #include "EditGlob.h"
  40.  
  41. const DescrSize = 4096;
  42. static char SubjList[DescrSize];
  43.  
  44. extern void UpdateSubjs(const char* subjs,const char* osubjs,const Key key);
  45. extern void UpdateAuthor(const char* auth,const char* oauth,const Key key);
  46. extern void UpdateTitle(const char* title,const char* otitle,const Key key);
  47. extern void FetchSubjs(char* subjbuffer,const Key key);
  48.  
  49. static Boolean DeleteCard1(const Key deletekey)
  50. {
  51.     CoreItem item;
  52.     if (Tree->SearchId((Key)deletekey,&item) &&
  53.         strlen(deletekey) == strlen(item.key)) {
  54.         CardRecord rec(&item.data);
  55.         UpdateAuthor("",rec->author,item.key);
  56.         UpdateTitle("",rec->title,item.key);
  57.         FetchSubjs(SubjList,deletekey);
  58.         UpdateSubjs("",SubjList,item.key);
  59.             Tree->DeleteId((Key)deletekey);
  60.             return true;
  61.     } else return false;
  62. }
  63. int DeleteCard()
  64. {
  65.     Key deletekey;
  66.     Term->PromptLine(18,0,"Id of card to delete: ",deletekey,KeySize);
  67.     if (!DeleteCard1(deletekey)) Term->Message("No Such Card");
  68.     return(-1);
  69. }
  70. int DeleteByAuthor()
  71. {
  72.     Key author;
  73.     Term->PromptLine(16,0,"Author to delete by: ",author,KeySize);
  74.     CoreItem item;
  75.     if (Tree->SearchAuthor(author,&item) &&
  76.         strlen(author) == strlen(item.key)) {
  77.         static char line[60];
  78.         ListRecord rec(&item.data);
  79.         int icount = rec.ElementCount();
  80.         for (int i = 0; i < icount;i++) {
  81.             sprintf(line,"Delete %s?",rec[i]);
  82.             if (Term->YorNp(17,0,line)) DeleteCard1(rec[i]);
  83.         }
  84.     } else Term->Message("No such author");
  85.     return(-1);
  86. }
  87. int DeleteByTitle()
  88. {
  89.     Key title;
  90.     Term->PromptLine(16,0,"Title to delete by: ",title,KeySize);
  91.     CoreItem item;
  92.     if (Tree->SearchTitle(title,&item) &&
  93.         strlen(title) == strlen(item.key)) {
  94.         static char line[60];
  95.         ListRecord rec(&item.data);
  96.         int icount = rec.ElementCount();
  97.         for (int i = 0; i < icount;i++) {
  98.             sprintf(line,"Delete %s?",rec[i]);
  99.             if (Term->YorNp(17,0,line)) DeleteCard1(rec[i]);
  100.         }
  101.     } else Term->Message("No such title");
  102.     return(-1);
  103. }
  104. int DeleteBySubj()
  105. {
  106.     Key subject;
  107.     Term->PromptLine(16,0,"Subject to delete by: ",subject,KeySize);
  108.     CoreItem item;
  109.     if (Tree->SearchSubj(subject,&item) &&
  110.         strlen(subject) == strlen(item.key)) {
  111.         static char line[60];
  112.         ListRecord rec(&item.data);
  113.         int icount = rec.ElementCount();
  114.         for (int i = 0; i < icount;i++) {
  115.             sprintf(line,"Delete %s?",rec[i]);
  116.             if (Term->YorNp(17,0,line)) DeleteCard1(rec[i]);
  117.         }
  118.     } else Term->Message("No such subject");
  119.     return(-1);
  120. }
  121.  
  122.  
  123.