/* * Concordance Programming Language * Utility to bulk load TXT files from all subdirectories. * Copyright (C) 2000 Dataflight Software, Inc. ALL RIGHTS RESERVED. * Dataflight Software and Concordance are registered trademarks of Dataflight Software, Inc. * * Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * */ main() { char string[256]; int db, i, j; text pszPath, pszMask; if (getfile("Text files", "*.txt", string, OFN_NOVALIDATE) == CR) { /* If the user specified a single file, then load it. */ if (exist(string)) import(db->TEXT, string, "", 0, 0, 'B', 0, 8000000); else { /* The file does not exist. Assume that the path has a */ /* wild card in it. Find the wild card and separate */ /* the path from the wild card specification. */ for(i = 0; string[i]; i = i + 1) if (string[i] == '\') j = i; pszPath = substr(string, 1, j + 1); pszMask = substr(string, j + 2); /* Confirm that the user wants to import the files, then call importPDF() to process the files and subdirectories. */ if (messageBox("Import all "+pszMask+" files from "+pszPath+" and all subdirectories?", program(), MB_YESNO) == IDYES) importPDF(db, pszPath, pszMask); } } } /* main() */ importPDF(int db; text pszPath; text pszMask) { char szFile[256]; text szPath; int i, length; /* First import all of the PDF files in the current directory. */ chdir(pszPath); for(szFile = findfirst(pszPath+pszMask, 0); szFile[0]; szFile = findnext()) { Message("Importing "+pszPath + szFile, FALSE); import(db->TEXT, pszPath+szFile, "", 0, 0, 'B', 0, 8000000); } /* Now process all subdirectories. */ for(szFile = findfirst(pszPath+"*.*", 16); szFile[0]; szFile = findnext()) { /* Build a list of every path except . and .. */ if ((szFile <> ".") and (szFile <> "..")) szPath = trim(szPath + newline() + szFile); } /* Now call ourselves recursively to process each subdirectory. */ if (len(szPath) > 0) for(i = findline(szPath, 1, length); i <> 0; i = findnline(szPath, i, length)) { importPDF(db, pszPath+substr(szPath, i, length)+"\", pszMask); } } /* importPDF() */ RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * 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,96); box(5,13,7,96, "3D", RGB(160, 160, 160), RGB(190, 190, 190)); puts(6,14,pad(message,'C',80), RGB(0,0,0), RGB(190, 190, 190)); if (wait) { key = getkey(); restore(5,13,screen); } return(asc(upper(chr(key)))); } /* Message() */