1000	!====================================================================================================
	! title  : fix_ftp_savesets.bas
	! author : Neil Rieck
	! created: 2001.01.11
	! purpose: Files FTP'd into OpenVMS always have a fixed record size of 512. However, OpenVMS save
	! sets (usually of the form "file.A", "file.B", etc.) require a fixed record size of 9216. This
	! program performs that conversion.
	! For an example of a downloadable saveset which requires conversion, check out the freeware area
	! at http://www.openvms.compaq.com/freeware/
	!====================================================================================================
	option type=explicit						! no kids stuff...
	set no prompt
	!
	map(map512)string	my512buffer	= 512			! for our input file
	!
	map(map9216)string	my9216buffer	= 9216			! 9216 = 512 x 18
	map(map9216)string	my512array(17)	= 512			! 0-17 items = 18
	!
	declare string	fs1$					,&
		long	handler_error% 				,&
			read_count%
	!
	print "fix 'ftp induced' saveset corruption (v100)"
	print "==========================================="
	input "input file ? (default=none) ";fs1$
	fs1$ = edit$(fs1$, 32%+2%)
	goto sortie if fs1$ = ""
	!	
	when error in
		print "-i-opening input file : ";fs1$
		open fs1$ for input as #1			&
			,map map512				&
			,organization sequential fixed		&
			,recordtype none
		!
		print "-i-opening output file: yada.a"
		open "yada.a" for output as #2			&
			,map map9216				&
			,organization sequential fixed		&
			,recordtype none
		!
		print "-i-transfering data"
		read_count% = 0%
		while 1=1
			get #1
			my512array(read_count%) = my512buffer
			read_count% = read_count% + 1%
			if read_count% = 18% then
				put #2
				my9216buffer = ""
				read_count% = 0%
			end if
		next
	use
		handler_error% = err
	end when
	!
	if (handler_error%<>11%) or		! if not EOF	&
	   (read_count% <> 0%)			! or partial block of data
	then
		print "-e-error code      : "; str$(handler_error%)
		print "-e-error text      : "; ert$(handler_error%)
		print "-e-read block count: "; str$(read_count%); " (should be zero)"
	else
		print "-i-transfer complete"
		print "-i-use the following DCL command to test your results"
		print "   $back/list yada.a/save"
	end if
	!
	!	adios...
	!
	sortie:
	end	
