/* * Concordance Programming Language Text Check Program * * This program cycles through the paragraph fields in a database * checking for any characters that are nonalphanumeric, non-whitespace, * or non-punctuation. It tags these records as "bad" so they can be edited. * * Copyright (c) 1997 Dataflight Software, Inc. * ALL RIGHTS RESERVED. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * * 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) 1997 YOUR NAME. ALL RIGHTS RESERVED. * Portions copyright (c) 1991 Dataflight Software, Inc. */ int TRUE = 1, FALSE = 0, ESC = 27; main() { closedb(0); puts(0,0,"Concordance Database Checker Daemon"); while(TRUE) { TextCheckerDaemon("C:\Program Files\Concordance\database\"); } } /* main() */ /**************************************************************** * Name: TextCheckerDaemon * * Synopsis: Cycles through databases in directory to check * * paragraph fields for erroneous data. * ****************************************************************/ int suspects; TextCheckerDaemon(text directoryPath) { char string[128]; int db, i; string = findfirst(directoryPath+"*.DCB", 0); while(string <> "") { Message("Press [Esc] to quit now.", FALSE); i = clock() + 3000; while(i > clock()) { if (keypress()) if (getkey() == ESC) exit(); else break; } suspects = 0; db = opendb(directoryPath+string); cycle(db) { puts(0,0,pad(db.database,'L',80)); Message("Checking record "+str(docno(db)) +" of "+str(count(db)), FALSE); CheckAlpha(db); } closedb(db); string = findnext(); } } /* TextCheckerDaemon() */ /**************************************************************** * Name: CheckAlpha * * Synopsis: Scans fields for illegal letters. * ****************************************************************/ CheckAlpha(int db) { int i, j, ch, length; for(i = 1; i <= db.fields; i = i + 1) { if (db.type[i] == 'P') { length = len(db->i); for(j = 1; j <= length; j = j + 1) { ch = asc(addr(db->i, j)); if ((ch < 32) or (ch >= 127)) { /* Tag this record if the characters are out of range. */ if ((ch <> CR) and (ch <> LF)) { puts(2,0,str(ch)+" "+chr(ch)+" "); tag(db, 1, "Bad text."); /* Break out of both loops. */ puts(1,0,"Suspect records: "+str(suspects = suspects + 1)); i = db.fields + 1; break; } } } } } } /* CheckAlpha() */ 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 isWindows = TRUE; Message(text message; int wait) { text screen; int key; int fg, bk, tr, tc; tr = 8; tc = 13; 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;