C******************************************************************************
	PROGRAM AKCONVERT
C******************************************************************************
C  AKCONVERT.FOR
C
C  written by:  M. Serrer
C  date:        March 1984
C  modified:    K. Trumbley, May 1984, this program changed from AKCOUNT.FOR
C                                      to do convert job.
C
C
	INCLUDE 'AK.INC/NOLIST'
	CHARACTER DSKUSG_FILENAME*40,ACCOUNT_FILENAME*40
	CHARACTER ASCII_NUMBER*8
C
C_Ask user to enter starting version number for files DSKUSG.DAT and
C	ACCOUNTNG.OLD
C
 1	TYPE 10
 10	FORMAT(//,' Enter version number of earliest DSKUSG.DAT file : '$)
	READ(5,20,ERR=1) VERSION_NUMBER
 20	FORMAT(I6)
	VERSION_NUMBER=VERSION_NUMBER-1
C
C_Loop for openning files in order of version number
C
 100	VERSION_NUMBER=VERSION_NUMBER+1
	ISTAT=OTS$CVT_L_TI(%REF(VERSION_NUMBER),ASCII_NUMBER)
	IF (.NOT.ISTAT) CALL LIB$SIGNAL(%VAL(ISTAT))
	DO I=1,8
	  IF (ASCII_NUMBER(I:I).NE.' ') GOTO 110
	END DO
 110	DSKUSG_FILENAME='DSKUSG.DAT;'//ASCII_NUMBER(I:8)
	ACCOUNT_FILENAME='ACCOUNTNG.OLD;'//ASCII_NUMBER(I:8)

C
C_Open all files
C
	OPEN(UNIT=DSK_FIL,NAME=DSKUSG_FILENAME,ERR=999,STATUS='OLD')
	OPEN(UNIT=UAF_FIL,NAME='SYS$SYSTEM:SYSUAF.LIS',STATUS='OLD')
	OPEN(UNIT=RAW_FIL,NAME=ACCOUNT_FILENAME,STATUS='OLD')
C
C_Translate PRIME time symbols
C
	CALL AK$TRN_TIM(ISTAT)
C
C_Get USERNAME's, UIC's and ACCOUNT names from SYSUAF.DAT
C
	CALL AK$SYS_UAF(ISTAT)
C
C_Extract information out of the VMS accounting file  ACCOUNTNG.OLD
C
	CALL AK$GET_REC(ISTAT)
C
C_Get OLD DISK usage information
C
	CALL AK$OLD_DSK_USG(ISTAT)
C
C_Save condensed accounting information in new file  AKCOUNT.TOT
C
	CALL AK$TOTALS(ISTAT)
C
C_Close all files and dispose of each of them accordingly
C
	CLOSE(UNIT=UAF_FIL,DISPOSE='KEEP')
	CLOSE(UNIT=DSK_FIL,DISPOSE='KEEP')
	CLOSE(UNIT=RAW_FIL,DISPOSE='KEEP')
	GOTO 100
 999	CONTINUE
	TYPE*, ' Conversion completed!'
C
	END
