I have a little file open subroutine that I use in a lot of places to keep open files in common:
OPEN.FILE.SUB 0001 SUB(FILENAME,FILEVAR,ERROR) 0002 * open filename to filevar, keep opened files in named common 0003 * 01-20-05 asb 0004 0005 COMMON /OPEN.FILE.SUB/ FILENAMES,FILEVARS(1000) 0006 0007 IF ASSIGNED(FILENAMES) ELSE 0008 FILENAMES = "" 0009 END 0010 0011 ERROR = "" 0012 0013 LOCATE(FILENAME,FILENAMES;POS) THEN 0014 FILEVAR = FILEVARS(POS) 0015 END ELSE 0016 OPEN FILENAME TO FILEVAR THEN 0017 IF POS LE 1000 THEN 0018 FILENAMES<POS> = FILENAME 0019 FILEVARS(POS) = FILEVAR 0020 END 0021 END ELSE 0022 FILEVAR = "" 0023 ERROR = 1 0024 CRT @(0):@(-4):"ERROR! can't open ":FILENAME 0025 END 0026 END 0027 0028 RETURN 0029 Recently (within the last two weeks) I have started getting the following error: Program "SB": Line 69, Read operation failure. [EBADF] Bad file number Line 69 is where I am reading a record from a file variable returned from my "open.file.sub". 1. The file that is generating the error is valid: e.g. I can "LIST filename 'itemid' etc etc etc" from TCL without an error. I can also "OPEN FILENAME TO FILEVAR in basic and read without an error. 2. There are typically about 50 - 100 files in my named common file lists, reads to the other files do not generate this error- just the one. 3. The error is consistent anytime I reference that file variable retrieved from named common, even when I don't use the "open.file.sub" process, until I logoff. If I login again, the error returns, but with a different file. 4. Virtually all the files in my named common file list are q-pointers. 5. FILE.OPEN.SUB has been in place for a few years, these error just started showing up within the last two weeks (have not upgraded anything, to my knowledge, in that time). 6. This is UniVerse on RH EL3: RELLEVEL 001 X 002 10.1.4 003 PICK 004 PICK.FORMAT 005 10.1.4 I tried a little tester program to check all the files in common: SB1 0001 COMMON /OPEN.FILE.SUB/ FILENAMES,FILEVARS(1000) 0002 0003 MAX = DCOUNT(FILENAMES,@AM) 0004 FOR N = 1 TO MAX 0005 PRINT N:" ":FILENAMES<N> 0006 READ X FROM FILEVARS(N),"TESTME" ELSE NULL 0007 NEXT N 0008 Here is the output: >RUN BP SB1 1 ENVC 2 DENCLM14 3 DENCLM12 4 DENCLM45 5 DENCLM23 6 DENCLM33 7 DENCLM15 8 DENCLM71 9 DENCLM31 10 DENCLM72 11 DENCLM26 12 DENCLM39 13 DENCLM62 14 DENCLM16 15 DENCLM22 16 DENCLM19 17 DENCLM34 18 DENCLM24 19 DENCLM41 20 MEDCLM26 21 MEDCLM15 22 MEDCLM33 23 MEDCLM19 24 MEDCLM71 25 MEDCLM27 26 MEDCLM16 27 MEDCLM62 28 MEDCLM72 29 MEDCLM34 30 MEDCLM25 31 MEDCLM24 32 MEDCLM45 33 MEDCLM23 34 MEDCLM31 35 MEDCLM68 36 MEDCLM22 37 VISCLM33 38 MEDCLM14 39 MEDCLM41 40 VISCLM34 41 VISCLM07 42 VISCLM62 43 VISCLM72 44 VISCLM71 45 VISCLM31 46 VISCLM25 47 DENCLM07 48 DENCLM21 49 VISCLM16 50 VISCLM19 51 VISCLM24 52 DENCLM68 Program "SB1": Line 6, Read operation failure. [EBADF] Bad file number > Any suggestions will be greatly appreciated- perhaps the "OPEN.FILE.SUB needs to be more robust? I suppose I could do a test read like "READ XXX FROM FILEVAR,"TEST" ON ERROR .... " after opening the file in the OPEN.FILE.SUB, but that doesn't really solve the problem and seems like a lot of overhead. OPEN.FILE.SUB is embedded in a lot of places and I really don't want to have to replace it with discrete file opens everywhere! Thanks, /Scott Ballinger Pareto Corporation Edmonds WA USA 206 713 6006 ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/