1	extend
2	! &
	! 	Read a random magtape onto a VMS disk.  One file only.	&
	! 	Author: Martin Minow					&
	! &
	!    ->	Ignore the "language feature is declining" message.	&
	! &

5	DefaultRsize = 512%						&
	\ DefaultBsize = (DefaultRsize% * 20%)				&
	! &
	! If you change these, don't forget to change the text		&
	! in the input statements below.				&
	! &

10	print "Input from <mfa0:> ";					&
	\ input line x$\ x$ = cvt$$(x$, -1%)
15	x$ = "mfa0:" if x$ = ""
20	input "Logical record length <512> "; rsize%			&
	\ rsize% = DefaultRsize% if rsize% = 0%
30	input "Blocksize <11200> "; bsize%				&
	\ bsize% = DefaultBsize% if bsize% = 0%
50	print "Don't forget to mount/foreign/blocksize ="; bsize%;  x$
60	open x$ for input as file 1,			&
		access read,				&
		organization undefined,			&
		recordsize bsize%
100	i% = magtape(3%, 0%, 1%)		! Rewind
200	open "tartap.dat" for output as file 2,		&
		access write,				&
		organization sequential fixed,		&
		recordsize rsize%
300	input "Maximum records to read <0 == forever> "; maxinput%
1000	on error goto 19000
1005	counter% = 0%
1007	field #2%, rsize% as outbuffer$
1010	while 1%
1015		on error goto 19000
1017		goto 19800 if maxinput% > 0% and counter% >= maxinput%
1020		get #1\ inputcount% = recount
1050		counter% = counter% + 1%
1060		print "read record"; counter%; inputcount%; " bytes"
2000		place% = 0%
2010		while place% < inputcount%
2020			field #1%, place% as q$, rsize% as q$
2030			lset outbuffer$ = q$
2040			put #2%, count rsize%
2050			outcount% = outcount% + 1%
2060			! print " "; outcount%;
2070			place% = place% + rsize%
2080		next
2090		print
9990	next
19000	if err = 11% then resume 19800
19005	recordcount% = recount
19010	print "Fatal error "; err; " after reading "; counter%; " records."
19011	print ert$(err); " at line"; erl
19015	print "recount = "; recordcount%
19020	print "eof forced after reading "; counter%; " records"\ resume 19810
19800	print "Normal completion after reading "; counter%; " records."
19810	on error goto 0\ close 2%
19820	print "<cr> for another, <ctrl/z> to exit.";\ input line q$
19830	goto 200
32767	end
