/* * Concordance Programming Language * * Copyright (c) 1994 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. * * This program, written by Jeff Lipsman, cycles through a database and looks * for matching bates numbers in a list file which was created earlier from an * IPRO TIF conversion. The program finds the matching image file and stores the * image file's name in the IMAGE field. You must use the list.cpl program to create * and load the list file from the ipro database.LOG file before running this program. * */ int isWindows = 1; int DOCBIT = 65536; main() { int db, i, bt, fh, record, hConv, imageField; char string[256]; text data; text szTag; szTag = "Image not found."; if (db.documents < 0) return(Message("Open a database first.", TRUE)); if (isfield(db, "BEGBATES") <= 0) return(Message("This database does not contain a BEGBATES field.", TRUE)); if (isfield(db, "IMAGE") <= 0) return(Message("This database does not contain a IMAGE field.", TRUE)); if ((bt = btopen(db.database + ".LST")) == EOF) return(Message("Can't find the list file.", TRUE)); else { /* Remove our tags. */ tag(db, -1, szTag); cycle(db) { puts(2, 0, str(docno(db))); i = btgte(bt, trim(db->BEGBATES) , string, i); if ((i == 0) and (substr(string, 1, i = len(db->BEGBATES)) == db->BEGBATES)) { puts(0, 0, "Found "+db->BEGBATES + " "+string); string = trim(addr(string, i + 1)); if ((string[0] == 'Y') or (string[0] == 'F')) string = addr(string, 3); db->IMAGE = FileName(string); } else { puts(1, 0, "Didn't find: "+db->BEGBATES); tag(db, 1, szTag); } } } first(db); last(db); unlockdoc(db); return(getkey()); /* Demonstration of the Pentium floating point error. */ /* The result of the equation should be zero, not 256. */ float x, y; x = 4195835; y = 3145727; Message(str(x - (x / y) * y), TRUE); return; } /**************************************************************** * 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); } /* FileName() */ RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ int fg, bk, tr, tc; Message(text message; int wait) { text screen; int key; tr = 8; tc = 13; tr + 3; tc + 56; bk = RGB(255,0,255); fg = isWindows ? RGB(160,0,160) : MenuColor_; cursoroff(); if (wait) screen = save(tr, tc, tr + 3, tc + 56); box(tr, tc, tr + 2, tc + 54,"3U", fg, bk); puts(tr + 1,tc + 1,pad(message,'C',53), isWindows ? RGB(255,255,255) : fg,bk); if (wait) { while(keypress()) getkey(); key = getkey(); restore(tr,tc,screen); } return(asc(upper(chr(key)))); } /* Message() */ /**************************************************************** * Global Variable Declarations and Initialization * ****************************************************************/ /* findfirst() file attributes. _A_NORMAL 00 Normal file - No read/write restrictions _A_RDONLY 01 Read only file _A_HIDDEN 02 Hidden file _A_SYSTEM 04 System file _A_VOLID 08 Volume ID file _A_SUBDIR 16 Subdirectory _A_ARCH 32 Archive file edit() mode attributes. A // Alpha only mode. U // Upper case conversion. N // Numeric only mode. Y // Y mode for dates. M // M mode for dates. D // D mode for dates. C // Cut and paste mode. S // Scroll field left and right, no wordwrapping. E // Return on [Enter], no CR in data. T // Always edit from the top. B // Always edit from the bottom. @ // Display only this field. ! // Return when this field is entered, don't edit. N:99.99 */ 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;