/* * PROGRAM NAME: * ------------- * ASCI2QRY.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 reads an ASCII QRY file and concatenates * the search based on all searches performed. */ text 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: FileName * * Synopsis: Trims the path from the file name. * ****************************************************************/ FileName(text name) { int i; while(i = match(name,"\",1)) name = substr(name,i+1); return(name); } /**************************************************************** * 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: findSearch * * Synopsis: Finds the documents and searches on them * ****************************************************************/ findSearch(int db; text searchString) { int oldQuery, error; text searchString; /* Set this variable for error checking */ oldQuery = db.query; /* Perform the search */ if (search(db, searchString)) error = TRUE; else { if (oldQuery <> db.query) { if (count(db) > 0) { /* Cycle through the found set */ cycle(db) { /* Tag all documents in query */ tag(db, 1, ATTACHTAG); } } else error = TRUE; } else error = TRUE; } /* Clear any excess searches */ if (db.query >= 10) query(db, -1); return(error); } /**************************************************************** * Name: main * * Synopsis: Main entrance point for all Concordance programs* ****************************************************************/ main() { int db, fhInput, fhError, line = 1, key; text szDatabase, szInput, szError; char szInputBuffer[128], szOutputBuffer[128]; /* Is the database open? */ if( db.documents > 0 ) if( Message("Use the "+FileName(db.database)+" database?",TRUE) <> 'Y') closedb( db ); if( db.documents < 0 ) { while( (key <> CR) and (key <> ESC) ) key = getfile("Database","*.DCB",szDatabase); db = opendb( szDatabase ); } /* Open the input file */ if (getfile("Open input file","*.TXT",szInput) == CR) fhInput = open(szInput, "r"); else return(Message("Program aborted. ",TRUE)); /* Open the error file */ if (getfile("Open log file","*.ERR",szError) == CR) fhError = open(szError, "w+"); else return(Message("Program aborted. ",TRUE)); /* Clear the all important tag group */ tag(db, -1, ATTACHTAG); /* Pop-up a message box to show status */ Message("", FALSE); /* Loop through the search file */ while (readln(fhInput, szInputBuffer) <> EOF) { /* Put a status */ puts( 8, 14, pad( "Processing line " + str(line), 'C', 55 ), RGB(255,255,255), RGB(0,0,255)); if (findSearch(db, trim(szInputBuffer)) == TRUE) { szOutputBuffer = "Search error on line " + str(line) + ": " + szInputBuffer; writeln(fhError, szOutputBuffer, len(szOutputBuffer)); } line = line + 1; } /* Set the tag query */ tagquery(db, ATTACHTAG); /* close the files */ close (fhError); close (fhInput); /* 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;