/* /* * Concordance Programming Language List Tagging Example * * This program demonstrates how to create a list of all tags * in a tag file, and how to determine if any of the tags have * been applied to the current record. It displays a menu of * the tags, with a check mark next to any tags active on the * current record. * * 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. */ main() { int db; /* Make sure the database is open. */ if (db.documents < 0) Message("Please open a database first.",TRUE); else ListTags(0); } /**************************************************************** * Name: ListTags * * Synopsis: Sample program demonstrates how to get all tag * * IDs from the database.TAG file and determine if * * a document has been tagged to any of the IDs. * * The IDs are displayed in a menu at the end. * ****************************************************************/ ListTags(int db) { int MAXTAGSINMENU = 250; text tagMenu[MAXTAGSINMENU]; int bt, dataValue, count, i; char tagString[256]; /* Make sure the database is open. */ if (db.documents >= 0) { /* Open the .TAG file, if nothing is tagged there is no tag file. */ /* Though this may present a multi-user access problem on single */ /* user version of Concordance if Concordance already has the */ /* tag file open and in use. */ if ((bt = btopen(db.database+".TAG")) >= 0) { /* The file exists so it must have tags in it. Retrieve them */ /* and store them in the menu. An empty string would indicate */ /* the default tag ID. */ /* Add the default tag ID as the first item in the menu. */ /* It will be the only entry with an upper case letter. */ /* All entries in the tag file are lower case. */ tagMenu[1] = "Default"; if (tagged(db,"")) tagMenu[1] = pad(tagMenu[1],'L',30)+" û"; count = 2; for(i = btgt(bt, "", tagString, dataValue); (i == 0) and (count < MAXTAGSINMENU); i = btgt(bt,tagString,tagString,dataValue)) { /* Store the tag string ID to the menu array. */ tagMenu[count] = tagString; /* Is the current document tagged to this ID, add a check mark if so. */ if (tagged(db,tagString)) tagMenu[count] = pad(tagMenu[count],'L',30)+" û"; /* Advance to the next menu item. */ count = count + 1; /* Set tagString to find the next greater tag ID in the file. */ tagString = tagString + " "; } tagMenu[0] = "Tagged Documents"; menu(5, 10, 20, 60, tagMenu, 1,""); btclose(bt); } } } /* ListTags() */ /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key; cursoroff(); if (wait) screen = save(5,13,8,69); box(5,13,8,69, "DD", MenuColor_); puts(6,14,pad(message,'C',53),MenuColor_); if (wait) { key = getkey(); restore(5,13,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 A_NORMAL = 00; int A_RDONLY = 01; int A_HIDDEN = 02; int A_SYSTEM = 04; int A_VOLID = 08; int A_SUBDIR = 16; int A_ARCH = 32; 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;