CLEAR ALL CLEAR SET CONFIRM ON *** display title box LINE1="ADD DATABSE NAME TO ALL NTX'S IN CURRENT DIRECTORY" LINE2='TODAY IS '+NAMEDATE() CENTERBOX(2,LINE1,LINE2) *** get list of .ntx's in currrent directory & put into dbf file run dir *.ntx>NTXS.TXT select 1 if file("NTXS.DBF") use NTXS zap else && create new database file ntxs.dbf create prg_stru use prg_stru append blank replace field_name with "NAME",field_type with "C",field_len with 8 close databases create NTXS from prg_stru erase prg_stru.dbf use NTXS endif append from NTXS.TXT SDF delete for NAME=" " pack go top DO WHILE .NOT. EOF() *** display index file name & prompt for databse name to be inserted NTX_NAME=TRIM(NAME) LINE1='CATALOGING NTX FILE: '+NTX_NAME @6,0 CLEAR CENTERBOX(7,LINE1) DBF_NAME=SPAC(8) @10,10 SAY 'ENTER DATABASE NAME TO BE INSERTED' GET DBF_NAME READ *** open index file inHANDLE = fopen("&ntx_name..ntx") if ferror() <> 0 @12,10 SAY 'ERROR OPENING FILE: '+NTX_NAME+'.NTX' WAIT CLOSE DATABASES clear screen RETURN endif *** set up temporary output file outhandle= fcreate('tmp.fil') *** get total file length FLEN = fseek(inHANDLE,0,2) *** reset file pointer to beginning fseek(inHANDLE,0) *** read 1st 1008 bytes & put into buffer1 block=1008 buffer=spac(1008) fread(inHANDLE,@buffer,block) OBUFFER = buffer+PAD(DBF_NAME,8) *** move file pointer by 8 bytes & read rest of file into buffer2 fseek(inhandle,8,1) block=flen-1016 buffer=spac(flen-1016) fread(inhandle,@buffer,block) *** set string for output file obuffer=Obuffer+buffer *** write string to output file fwrite(outhandle,obuffer) *** close input & output files fclose(inhandle) fclose(outhandle) *** rename tmp.fil to original name erase &ntx_name..ntx rename tmp.fil to &ntx_name..ntx SKIP ENDDO CLEAR SCREEN CLOSE DATABASES RETURN