/* * Concordance Programming Language Accession Numbering Program * * 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. * */ int isWindows; main() { int f, i, db; char string[61]; char szOfCount[25]; ver(string); isWindows = match(upper(string),"WINDOWS",1); cls(); puts(5,5,"This program assigns unique accession numbers to documents."); puts(6,5,"Press the [Esc] key to cancel, any other key to proceed."); if (getkey() == ESC) return; if (db.documents < 0) return(Message("Please open a database first.",TRUE)); while(f == 0) { if ((f = GetField(db, 0)) == 0) return; if ((db.type[f] <> 'P') and (db.type[f] <> 'T')) { Message("Field type must be Text or Paragraph.",TRUE); f = 0; } else { if ((db.type[f] == 'T') and (db.length[f] < 15)) { Message("Field length must be >= 15.",TRUE); f = 0; } } } szOfCount = " of "+trim(str(count(db),10,0,',')); i = clock(); cycle(db) { puts(8,5,"Processing "+ trim(str(docno(db),10,0,','))+szOfCount); if (keypress()) { if (getkey() == ESC) { if (Message("Cancel processing? Y/N",TRUE) == 'Y') break; } } if (len(db->f) == 0) { while(i == clock()) ; db->f = upper(itoa(today(),36)+"-"+itoa(time(),36)+"-"+itoa(i = clock(), 36)); } } first(db); last(db); unlockdoc(db); } /**************************************************************** * Name: GetField * * Synopsis: Prompt user for field name. * ****************************************************************/ GetField(int db, next) { int i, n; text field[255]; text screen; if (db.documents >= 0) { field[0] = "Field Type "; for(i = 1; i <= db.fields; i = i +1) switch(db.type[i]) { case 'T' : field[i] = pad(db.name[i],'L',13)+ "Text "; case 'P' : field[i] = pad(db.name[i],'L',13)+ "Paragraph"; case 'N' : field[i] = pad(db.name[i],'L',13)+ "Numeric "; case 'D' : field[i] = pad(db.name[i],'L',13)+ "Date "; } i = db.fields + 1; screen = save(11,30,21,57); while(i > db.fields) i = menu(11, 30, 21, 57, field, next,""); restore(11,30,screen); if (i) next = i; } return(next); } /* GetField() */ 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; bk = RGB(255,0,255); fg = isWindows ? RGB(160,0,160) : MenuColor_; cursoroff(); 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;