/* * Concordance Delete Module DELETE.CPL * * This program marks the current query for deletion, or recalls * the query from deletion. * * Copyright 1993 Dataflight Software, Inc. * 10573 West Pico Blvd., Suite 68 * Los Angeles, CA 90064 * * ALL RIGHTS RESERVED. * * Unauthorized distribution, adaptation or use may be * subject to civil and criminal penalties. * * You may incorporate this program into your own programs * ONLY if you incorporate the following copyright notice: * * Copyright (c) 1993 YOUR NAME. ALL RIGHTS RESERVED. * Portions copyright (c) 1993 Dataflight Software, Inc. */ text copyright = "Copyright 1993 Dataflight Software, Inc. ALL RIGHTS RESERVED."; main() { int db, i, finished, nextItem, key, tr, tc, br, bc; int firstDocument, lastDocument; int oldBack, oldText, color; char string[256]; text screen; text MMenu[7]; cls(); MMenu[0] = "Range Deletion"; MMenu[1] = "Search Database"; MMenu[2] = "Browse Records"; MMenu[3] = "Delete Records"; MMenu[4] = "Recall Records"; MMenu[5] = "Enter Range"; MMenu[6] = "Quit"; /* First determine if windows is running. */ ver(string); isWindows = match(upper(string),"WINDOWS",1); status(db); if (db.documents < 0) { while((key <> CR) and (key <> ESC)) key = getfile("Database Directory","*.dcb",string); if (key == CR) db = opendb(string); } if (db.documents < 0) return; key = 0; firstDocument = 1; lastDocument = count(db); screen = save(tr = 0, tc = 10, br = 9, bc = 28); while(finished == FALSE) { if (isFkey(key) == FALSE) key = menu(tr, tc, br, bc, MMenu, nextItem,"SBDREQ"); restore(tr,tc,screen); cursor(0,0); cursoroff(); switch(key) { case F2: case F4: case 1: key = searchfs(db,""); nextItem = 1; break; case F6: case 2: key = browse(db); nextItem = 2; break; case 3: puts(0,10,"Deleting",MenuColor_); for(i = goto(db,firstDocument); (i > 0) and (docno(db) <= lastDocument); i = next(db)) { delete(db); puts(0,19,str(docno(db),10,0,','),MenuColor_); if (keypress()) { if (getkey() == ESC) break; } } key = 0; nextItem = 3; status(db); break; case 4: puts(0,10,"Recalling",MenuColor_); for(i = goto(db,firstDocument); (i > 0) and (docno(db) <= lastDocument); i = next(db)) { recall(db); puts(0,20,str(docno(db),10,0,','),MenuColor_); if (keypress()) { if (getkey() == ESC) break; } } key = 0; nextItem = 4; status(db); break; case 5: /* Enter range to edit. */ key = 0; if (isWindows) { oldText = TextColor_; oldBack = TextBackground_; scroll(5,13,8,67,0,0,MenuBackground_); box(5,13,9,69,"3D", RGB(160,0,160),TextBackground_ = RGB(255,0,255)); color = TextColor_ = RGB(0,0,0); } else { scroll(5,13,8,67,0,0,MenuColor_); box(5,13,9,69, "3U", MenuColor_); color = MenuColor_; } while((key <> CR) and (key <> ESC)) { key = edit( " First", 6, 14, 6, 20, "@", firstDocument, 6, 22, 6, 40, "N:10.0", " Last", 7, 14, 7, 20, "@", lastDocument, 7, 22, 7, 40, "N:10.0", 2, "", 0, 0, color); } if (isWindows) { TextColor_ = oldText; TextBackground_ = oldBack; } /* Range check the two values. */ if (firstDocument > lastDocument) { i = firstDocument; firstDocument = lastDocument; lastDocument = i; } firstDocument = max(0,firstDocument); lastDocument = min(count(db),lastDocument); cls(); status(db); key = 0; nextItem = 5; case 0: case 6: finished = TRUE; break; default: key = 0; nextItem = 1; break; } } } /**************************************************************** * Name: RGB * * Synopsis: Convert red, green, blue values to a color. * ****************************************************************/ RGB(int red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Summary: status * * Synopsis: Initializes the first two line on the screen. * ****************************************************************/ status(int db) { puts(0,0,rep(' ',80),MenuColor_); puts(1,0,rep('Í',80),MenuColor_); puts(0,8,"³",MenuColor_); puts(1,8,"Ï",MenuColor_); if (db.documents >= 0) puts(0,0,FileName(db.database),MenuColor_); } /* status() */ /**************************************************************** * Name: FileName * * Synopsis: Trims the path from the file name. * ****************************************************************/ FileName(text name) { int i; if (i = match(name,":",1)) name = substr(name,i+1); while(i = match(name,"\",1)) name = substr(name,i+1); return(name); } /* FileName() */ /**************************************************************** * Name: isFkey * * Synopsis: Returns nonzero value if key is a function key. * ****************************************************************/ isFkey(int key) { return((key >= F1) and (key <= F10)); } /* isFkey() */ /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message) { text screen; int key; cursoroff(); screen = save(8,13,11,69); box(8,13,11,69,"DS", MenuColor_); puts(9,14,pad(message,'C',53),MenuColor_); key = getkey(); restore(8,13,screen); return(asc(upper(chr(key)))); } /* Message() */ /**************************************************************** * Name: initialize * * Synopsis: Set global variables to initial values * ****************************************************************/ text NL = chr(13)+chr(10); int CTRLPGUP = 33792, EOF = -1; short LEFT = 19200, RIGHT = 19712, UP = 18432, DOWN = 20480, HOME = 18176, END = 20224, PGUP = 18688, PGDN = 20736, CTRLPGDN = 30208, isWindows; char ESC = 27, FALSE = 0, TRUE = 1, CR = 13, LF = 10; short F1 = 15104, F2 = 15360, F3 = 15616, F4 = 15872, F5 = 16128, F6 = 16384, F7 = 16640, F8 = 16896, F9 = 17152, F10 = 17408;