C This software EX1.FOR is part of the Visual Fortran kit.
C
C This software is provided as an example that demonstrates a particular
C feature/function of the licensed product. The software is not intended to
C provide a complete solution to any application problem but rather is provided
C as a teaching mechanism.
C
C Users may incorporate any part of this sample into their own source after 
C making appropriate changes to make it suitable for the intended application.
C
	PROGRAM EX1
	EXTERNAL UOPEN
	INTEGER ERRNUM, CTR, I

1	FORMAT (I)

	ERRNUM = 0

	WRITE (6,*) 'EX1. Access data using formatted I/O.'
	WRITE (6,*) 'EX1. Open file without USEROPEN and put some data in it.'
	OPEN (UNIT=1, FILE='ex1.dat', STATUS='NEW', ERR=9, IOSTAT=ERRNUM)

	DO CTR=1,10
	    WRITE (1,1) CTR
	END DO

	WRITE (6,*) 'EX1. Close and re-open with USEROPEN.'
	
	CLOSE (UNIT=1)

	OPEN (UNIT=1, FILE='ex1.dat', STATUS='OLD', FORM='FORMATTED', 
	1     USEROPEN=UOPEN, ERR=99, IOSTAT=ERRNUM)

	WRITE (6,*) 'EX1. Read and display what is in file.'

	DO CTR=1,10
	    READ (1,1) I
	    WRITE (6,*) I
	END DO
	
	WRITE (6,*) 'EX1.  Successful if 10 records shown.'

	CLOSE (UNIT=1,STATUS='DELETE')
	STOP

9	WRITE (6,*) 'EX1. Error on first open is ', ERRNUM
	GOTO 999
99	WRITE (6,*) 'EX1. Error on USEROPEN is ', ERRNUM
999	END