main() { int fi, fo, line; char string[1024]; char szInFile[256], szOutFile[256]; while (getfile("Input file directory", "*.*", szInFile) == CR) { if ((fi = open(szInFile, "r")) == EOF) return(Message("Couldn't open "+szInFile, TRUE)); if ((fo = open(szOutFile = Path(szInFile)+"Temp.tmp", "w+")) == EOF) { close(fi); return(Message("Couldn't create "+szOutFile, TRUE)); } while(readln(fi, string) >= 0) { writeln(fo, string, len(string)); puts(10,40,str( line = line + 1)); } close(fi); close(fo); erase(szInFile); rename(szOutFile, szInFile); szInFile[0] = 0; } } /* main() */ /**************************************************************** * 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() */ /**************************************************************** * Summary: status * * Synopsis: Initializes the first two lines on the screen. * ****************************************************************/ Status(int db) { puts(0,0,rep(' ',80),MenuColor_); puts(1,0,rep('Í',80),MenuColor_); puts(0,8,"³",MenuColor_); puts(1,8,"Ï",MenuColor_); if (db.documents >= 0) puts(0,0,FileName(db.database),MenuColor_); } /* Status() */ /**************************************************************** * Name: FileName * * Synopsis: Trims the path from the file name. * ****************************************************************/ FileName(text name) { int i; if (i = match(name,":",1)) name = substr(name,i+1); while(i = match(name,"\",1)) name = substr(name,i+1); return(name); } /* FileName() */ /**************************************************************** * Name: Path * * Synopsis: Trims the file name from the path. * ****************************************************************/ Path(text name) { int i, j; char string[257]; string = name; if (i = match(name,":",1)) j = i; else i = j = 1; while(j = match(name,"\", i)) i = j + 1; string[i - 1] = 0; return(string); } /* Path() */ /**************************************************************** * 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;