cat > input <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
1
5
2
5
3
5
4
10
0
0
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 input
cat > script.ff <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
	subroutine mfmain
	include	'INCLUDE/msf.h'

	integer*2	quant, sold, newq, prcode
	logical	found

	call mfopen (
     &  'DATABASE'
     &  , 'stock', 'u')

10	print 20
20	format (1x, 'Enter product code:')
	read *, prcode

	if (prcode .eq. 0) then
		call mfclos ('stock')
		call mfstop
		end if
	call mfqci ('=', 'part_code', prcode)
	call mfgetb ('stock', char(0))

	found = .false.
30	if (mfget () .ne. 1) goto 70
		found = .true.
		if (.not. mfcpi ('quantity', quant))
     &			quant = 0
		print 40, quant
40		format (1x, 'Number in stock = ', i6)
		print 50
50		format (1x, 'Enter number sold: ')
		read *, sold
		newq = quant - sold
		print 60, newq
60		format (1x, 'Number now in stock = ', i4)

		call mfputi ('quantity', newq)
		call mfput ('stock')
		goto 30
70	call mfgete

	if (.not. found)
     &		print 80
80		format (/, 1x, 'No entries for that part code')
	goto 10
	end
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script.ff
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Enter product code:
Number in stock =     10
Enter number sold: 
Number now in stock =    5
Enter product code:
Number in stock =      9
Enter number sold: 
Number now in stock =    4
Enter product code:
Number in stock =      8
Enter number sold: 
Number now in stock =    3
Enter product code:

No entries for that part code
Enter product code:
Number in stock =      0
Enter number sold: 
Number now in stock =    0
Enter product code:
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Retrieve and update with internal values
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
