	Function modvolume_inf, volfn, dest, logdiscna, archdir, pre=pre, $
				weekid=weekid, v_year=v_year, v_week=v_week               
;	---------------------------------------------------------
;+						6-Mar-96
;	NAME: modvolume_inf
;	PURPOSE: modify the "volume.inf" files for YMI-makedisc
;		procedure of creating CDRs.
;	PARAMETERS:
;		RETURNED 	1 for sucess and 0 for error or failure
; 
;		volfn		input fully qual. file name of volume.inf file
;		dest		input dest. for the CD, default is LMATC
;		logdiscna	ret. string for logging the disc making.
;		archdir		ret. string for archive dir. for files.
;		pre		ret. PREfix string for /ydb archives.
;		weekid		input for finding nametape and logging name
;               v_year          year of volume being archived 
;               v_week          week of volume being archived 
;
;	History:
;		created  06-Mar-96, gal
;		modified 27-Sep-96, gal
;               modified 12-Jan-98, pgs added v_year and v_week
;-
;	----------------------------------------------------------


;       Update the Volume.inf file
        text = rd_tfile(volfn)
	arcweek = 0 & ydb = 0 & gen = 0	; init. types of CD
	res = strpos(volfn,'week')	; Using volfn test for actual type
	if (res ne -1) then begin
		arcweek = 1
	endif else begin
		res = strpos(volfn,'ydb')
		if (res ne -1) then begin
			ydb = 1
		endif else gen = 1
	endelse

        voln = strmid(text(4),3,strlen(text(4))-4)	; volume name
        vols = strmid(text(5),3,strlen(text(5))-4)	; set name
;
;       pgs980109
;
        vyear = n_elements(v_year)
        vweek = n_elements(v_week)
        IF (NOT ((vyear ne 0) AND (vweek ne 0)) ) THEN BEGIN ;prep_week forces skip if weekid
	   print, ' '
           print, 'CD Volume information:
	   print, 'Current Formal Volume name: ', voln
	   print, 'Current Set name: ', vols
	   print, ' '
           ans = 'y'
	   print, 'Note: Use only alphanum-chars and "_" in the volume/set names'
           print,  ' '
	   input, 'Update this information?', ans, ans
        ENDIF ELSE BEGIN
           ans = 'n'
           yr  = v_year
           wno = v_week
	   IF (STRLEN(wno) EQ 2) THEN voln = strUpcase(yr+'_'+wno+'a') ELSE voln = strUpcase(yr+'_'+wno); pgs 12/2/98
	   strtemp = 'VI"'+voln+'"';right here
	   text(4) = strtemp	    	    
	   archdir = voln
;stop, 'Is it the archdir that is written down, or the volume number?'
        ENDELSE
;
        if (strupcase(ans) eq 'Y') then begin

	  if (arcweek) then begin		; break vol to> yr, wk, letter
;print,'arcweek -path..'
	    yr	   = strmid(voln,0,2)
	    wno    = strmid(voln,3,2)
	    input, 'Update the Year?', yr, yr
	    strput, voln, yr, 0
	    input, 'Update the week number?', wno, wno
	    strput, voln, wno, 3
	   IF (STRLEN(wno) EQ 2) THEN voln = strUpcase(yr+'_'+wno+'a') ELSE voln = strUpcase(yr+'_'+wno); pgs 12/2/98
;	    voln = strUpcase(yr+'_'+wno+'a')
;pgs05feb98	    voln = strUpcase(yr+'_'+wno);pgs feb11
	    strtemp = 'VI"'+voln+'"'
	    text(4) = strtemp	    	    
	    archdir = voln
	  endif

	  if (gen) then begin			; no break for gen
;print,'gen -path...'
	    input, 'Enter new Formal Vol. name?', voln, voln
	    voln = str2alp(voln,plus='_',/num)	; clean the volume name
	    voln = strUpcase(voln)
	    strtemp = 'VI"'+voln+'"'
	    text(4) = strtemp
;print, "New Vol. name string: ", strtemp
	    input, 'Enter new Set name?', vols, vols
	    vols = str2alp(vols,plus='_',/num)	; clean the Set name
	    vols = strUpcase(vols)
	    strtemp = 'VS"'+vols+'"'
	    text(5) = strtemp
;print, "New Set name string: ", strtemp
	    archdir = ''			; empty string
	  endif

	  if (ydb) then begin			; break vol.to> prefix,yr,letter
;print,'ydb -path...'
	    pre = strlowcase(strmid(voln,0,3))
	    sno = strlowcase(strmid(voln,6,2))	; alpha number (a,b,c...)
print, 'pre = ', pre
print, 'sno = ',sno
	    input, 'Update the prefix?', pre, pre
	    strput, voln,pre,0
	    input, 'Update the year?', yr, yr
	    strput, voln,yr, 3
	    input, 'Update the start-week number?', sno, sno
	    strput, voln,sno,6
	    voln = strUpcase(voln)
;	    voln = strUpcase(pre+yr+'_'+sno);original
	    voln = strUpcase(pre+STRTRIM(STRING(FIX(yr)),2)+'_'+STRTRIM(STRING(FIX(sno)),2));original
;print,'voln-- should be upcase?',voln
	    strtemp = 'VI"'+voln+'"'
	    text(4) = strtemp
	    strput, vols, pre,0
	    vols = strUpcase(vols)
	    strtemp = 'VS"'+vols+'"'
	    text(5) = strtemp
;           archdir = strlowcase(pre+yr+'_'+sno) ; define archive directory; original
	    archdir = strlowcase(pre+STRTRIM(STRING(FIX(yr)),2)+'_'+STRTRIM(STRING(FIX(sno)),2)) ; define archive directory
	  endif
        endif else begin
	  if (arcweek) then archdir = voln 
	  if (gen) then archdir = ''	
	  if (ydb) then begin
	    pre = strlowcase(strmid(voln,0,3))
	    yr  = strlowcase(strmid(voln,3,2))
	    ano = strlowcase(strmid(voln,6,2))	; alpha number (a,b,c...)
	    archdir = strlowcase(pre+yr+'_'+sno); define archive directory	
	  endif
        endelse
;           w_dash = STRPOS(text(4), '-')
;           IF (w_dash(0) ne -1) THEN BEGIN;
;              t_text4=text(4)
;              strput, t_text4,'_',w_dash 
;              text(4) = t_text4
;           ENDIF
;stop, 'what is happening with strtemp here?: has text(4) been correctly reset?'

	file_append, volfn, text, /newfile      ; write the new volume.inf
        modcmd = 'chmod 777 '+volfn

        modcmd = str2arr(modcmd, del=' ')
        spawn, modcmd, /noshell

        st = strmid(!stime, 0, 17)
	user = get_user()
        logdiscna = voln+' | '+st

	binaryweekid = Keyword_set(weekid)
	if (binaryweekid) then begin
		tapenam = get_tapename(weekid)
	endif
        if (n_elements(dest) ne 0) then begin
		if (binaryweekid) then begin
		  logdiscna = logdiscna+' | '+dest+' | '+user+' | '+tapenam
		endif else begin
		  logdiscna = logdiscna+' | '+dest+' | '+user
		endelse
	endif else begin
		if (binaryweekid) then begin
		  logdiscna = logdiscna+' | '+'LMATC'+' | '+user+' | '+tapenam
		endif else begin
		  logdiscna = logdiscna+' | '+'LMATC'+' | '+user
		endelse
	endelse

print, 'New log discName: ', logdiscna
	return, 1			; assume no errors
	END
