/* * PROGRAM NAME: * ------------- * ATTACH.CPL * Concordance(tm) Information Retrieval System, Professional Edition * * COPYRIGHT: * ---------- * Copyright (c) 1996 Dataflight Software. * All Rights Reserved. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * * ALL RIGHTS RESERVED. * * Unauthorized distribution, adaptation or use may be * subject to civil and criminal penalties. * * SYNOPSIS: * --------- * This program brings together attachment ranges from * the current query as opposed to current document */ text ATTACHFIELD1 = "BEGATTACHN", ATTACHFIELD2 = "ENDATTACHN", ATTACHTAG = "Attachments"; /**************************************************************** * Name: RGB * * Synopsis: Helper routine for Windows color creation. * ****************************************************************/ RGB(int red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message( text message; int wait ) { text screen; int key; cursoroff(); screen = save( 5, 13, 10, 69 ); box( 7, 13, 9, 69, "3U", RGB(0,0,150), RGB(0,0,255) ); puts( 8, 14, pad( message, 'C', 55 ), RGB(255,255,255), RGB(0,0,255)); if( wait ) { key = getkey(); restore( 5, 13, screen ); } if( islower( key )) key = key - ( 'a' - 'A' ); return( key ); } /* Message() */ /**************************************************************** * Name: findAttach * * Synopsis: Finds attachments of the current document * ****************************************************************/ findAttach(int db) { int oldQuery, error; text searchString; /* Set this variable for error checking */ oldQuery = db.query; /* Wait...do we have to perform the search */ if ((db->ATTACHFIELD1 == "") and (db->ATTACHFIELD2 == "")) return (error); /* Set the search string to the current doc fields */ searchString = "(" + ATTACHFIELD1 + " = " + chr(34) + trim(db->ATTACHFIELD1) + chr(34) + ") and "; searchString = searchString + "(" + ATTACHFIELD2 + " = " + chr(34) + trim(db->ATTACHFIELD2) +chr(34) + ")"; /* Perform the search */ if (search(db, searchString)) error = TRUE; else if (oldQuery <> db.query) { /* Cycle through the found set */ cycle(db) { /* Tag all documents in query */ tag(db, 1, ATTACHTAG); } } return(error); } /**************************************************************** * Name: main * * Synopsis: Main entrance point for all Concordance programs* ****************************************************************/ main() { int db, firstQuery, currentDoc, currentRec; float numerator, denominator, quotient; /* Is the database open? */ if (db.documents <= 0) return(Message("Please open database first. ",TRUE)); /* Clear the all important tag group */ tag(db, -1, ATTACHTAG); /* What's the query right now */ firstQuery = db.activequery; if (hits(db) == db.documents) return(Message("Entire database already selected. ",TRUE)); /* Pop-up a message box to show status */ Message("", FALSE); /* Loop through the current query */ for (currentRec = first(db); currentRec > 0; currentRec = next(db)) { /* What's the status */ currentDoc = numerator = docno(db); denominator = count(db); quotient = numerator / denominator * 100; puts( 8, 14, pad("Pulling attachments together (" + str(quotient) + "%)", 'C', 55 ), RGB(255,255,255), RGB(0,0,255)); /* Find and tag all attachments to current query */ findAttach(db); /* Reset to query */ query(db, firstQuery); /* Go to original document */ goto(db, currentDoc); } /* Set the tag query */ tagquery(db, ATTACHTAG); /* Or the first query to the tag */ search(db, str(firstQuery) + " or " + str(db.query)); /* Place the user in browse mode */ user("WINDOWS","BROWSE"); } /**************************************************************** * Global Variable Declarations and Initialization * ****************************************************************/ int CTRLPGUP = 33792, F11 = 34048, F12 = 34304, EOF = -1; short LEFT = 19200, RIGHT = 19712, UP = 18432, DOWN = 20480, HOME = 18176, END = 20224, PGUP = 18688, PGDN = 20736, CTRLPGDN = 30208, F1 = 15104, F2 = 15360, F3 = 15616, F4 = 15872, F5 = 16128, F6 = 16384, F7 = 16640, F8 = 16896, F9 = 17152, F10 = 17408; char ESC = 27, CTRLP = 16, FALSE = 0, TRUE = 1, CR = 13, LF = 10;