/* ** Concordance Programming Language ** ** Copyright (c) 2001 Dataflight Software, Inc. ** ALL RIGHTS RESERVED. ** 2337 Roscomare Road, Suite 11 ** Bel Air, 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: ** ** Display file names only.cpl */ /*****************************************************/ /* Function: Main */ /* Purpose : Entry point for all programs */ /*****************************************************/ main() { text mainmenu[4], menuString1; int db, done, next, nAttachmentField; /* Make sure the database is open */ if (db.documents <= 0) return(messageBox("Please open a e-mail database first.", "file_conversion.cpl", MB_OK | MB_ICONEXCLAMATION)); /* Setup the menu */ menuString1 = "[1] Attachment field : "; mainmenu[0] = "Display only file names"; if (nAttachmentField = isfield(db, "ATTACHMENT")) { mainmenu[1] = menuString1 + db.name[nAttachmentField]; next = 2; } else { mainmenu[1] = menuString1; next = 1; } mainmenu[2] = "[G] Go"; mainmenu[3] = "[Q] Quit"; /* Display the menu */ while (done == FALSE) { next = menu(5, 10, 11, 70, mainmenu, next, "1GQ"); switch(next) { case 0: done = TRUE; break; case 1: if (nAttachmentField = GetField(db, nAttachmentField)) { mainmenu[1] = menuString1 + db.name[nAttachmentField]; next = 2; } else { mainmenu[1] = menuString1; next = 1; } break; case 2: if (ProcessAttachmentField(db, nAttachmentField) == 0) next = 3; break; case 3: done = TRUE; break; } } } /**************************************************************** * Name: ProcessAttachmentField * * Synopsis: Process attachment field main function * ****************************************************************/ ProcessAttachmentField(int db, nAttachmentField) { int bError = FALSE, nTotalAnnotations, nCurrentAnnotation, nCurrentOffset, i; text pszNewAttachmentField, pszLinkField, pszNoteAttached, pszNoteText, pszNewFile; /* Make sure we have an attachment field */ if (nAttachmentField == 0) { messageBox("Please specify an attachment field.", "Display file names only", MB_OK | MB_ICONEXCLAMATION); bError = TRUE; } if (bError == FALSE) { /* Cycle through the database */ cycle(db) { /* Put up a status message */ puts(0, 0, "Processing record " + str(docno(db))); /* Initialize variables */ pszNewAttachmentField = ""; nCurrentOffset = 0; /* Get the total number of annotations for this record */ nTotalAnnotations = annotationCount(db); /* Loop through the annotations */ for (nCurrentAnnotation = 1; nCurrentAnnotation <= nTotalAnnotations; nCurrentAnnotation = nCurrentAnnotation + 1) { /* Goto the annotation */ annotationGoto(db, nCurrentAnnotation); /* Get the link field */ pszLinkField = annotationRetrieve(db, "LINKFIELD"); /* Only process link field attachments */ if (pszLinkField == "ATTACHMENT") { /* Get the note attached text and the note text */ pszNoteAttached = annotationRetrieve(db, "NOTEATTACHED"); pszNoteText = annotationRetrieve(db, "NOTETEXT"); /* Update any Powerpoint files with pound signs */ if (((i = match(pszNoteAttached , "#", 1)) <> 0) and (match(upper(pszNoteAttached), "PPT", 1) <> 0)) { /* Remove the pound sign */ pszNewFile = substr(pszNoteAttached, 1, i - 1) + substr(pszNoteAttached, i + 1); /* Rename the file */ rename(pszNoteAttached, pszNewFile); /* Update the field */ annotationUpdate(db, "NOTEATTACHED", pszNewFile); } /* Update the offsets */ annotationUpdate(db, "LINKOFFSET", str(nCurrentOffset + 1)); annotationUpdate(db, "LINKLENGTH", str(len(pszNoteText))); /* Save the new attachment field */ if (len(pszNewAttachmentField) > 0) { pszNewAttachmentField = pszNewAttachmentField + chr(13) + pszNoteText; nCurrentOffset = nCurrentOffset + len(pszNoteText) + 1; } else { pszNewAttachmentField = pszNoteText; nCurrentOffset = len(pszNoteText) + 1; } } /* Set the field */ db->nAttachmentField = pszNewAttachmentField; } } } return(bError); } /**************************************************************** * Name: GetField * * Synopsis: Prompt user for field name. * ****************************************************************/ GetField(int db, next) { int i, n; text field[101]; 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); next = i; } return(next); } /* GetField() */