ARJAN@HROEUR51.BITNET (07/05/88)
Finding the next free available UIC by searching RIGHTSLIST.DAT; A FORTRAN version. The C program I posted may have been nice, but Bitnet%"carl@CitHex.Bitnet" sent me a fortran program doing the same thing, only it is much more elegant and it's faster too. I felt I had to post it to INFO-VAX, because the method is also much more general than my C program. (Don't forget to replace the spaces at the beginning of line 5 with a tab.) ******************************************************************************** PROGRAM NEXT_FREE_UIC CHARACTER*6 MEMBER INTEGER GROUP, KEYNUM, UIC, NEXT_UIC OPEN(UNIT=1,FILE='SYS$SYSTEM:RIGHTSLIST.DAT',SHARED,READONLY, 1 ACCESS='KEYED',STATUS='OLD',FORM='UNFORMATTED') TYPE 10 10 FORMAT(' GROUP: ',$) READ 20, GROUP 20 FORMAT(O6) KEYNUM = GROUP * '10000'X UIC = KEYNUM READ(1,KEYGE=KEYNUM,KEYID=0,ERR=900) NEXT_UIC 30 IF ((NEXT_UIC/'10000'X) .NE. GROUP) GOTO 900 IF (IAND(NEXT_UIC,'FFFF'X) .EQ. 'FFFF'X) GOTO 900 UIC = NEXT_UIC READ(1,ERR=900) NEXT_UIC GOTO 30 900 UIC = UIC + 1 IF (IAND(UIC,'FFFF'X) .EQ. 'FFFF'X) GOTO 950 TYPE 910, UIC/'10000'X, IAND(UIC,'FFFF'X) 910 FORMAT(1X,'THE NEXT UIC IN THE GROUP IS [',O6.6,',',O6.6,']') WRITE(MEMBER,920) IAND(UIC,'FFFF'X) 920 FORMAT(O6.6) CALL LIB$SET_SYMBOL('MEMBER', MEMBER) GOTO 999 950 TYPE 960, GROUP 960 FORMAT(' GROUP', O6.6, ' IS FULL') 999 END ******************************************************************************** If there were a KEYLT specifier, the loop could be eliminated, and it could all be done with a single read from the file, by setting KEYNUM equal to GROUP * '10000'X + 'FFFF'X. (-Carl's comment)