info-vax@ucbvax.ARPA (07/20/85)
From: <#D15%DDATHD21.BITNET@WISCVM.ARPA>
Hi Don,
Kevin is right, you can share variable-lenghts, sequential
files. There are no problems if you have only one WRITER and one or
more READERS. There are problems if you need more than one WRITER,
because there is no record-locking on sequential files.
All you have to do in the first case, is to ensure that the RMS
buffers are really written to disk. For this purpose you can use the
SYS$FLUSH service. The following FORTRAN-77 program (Hi Kevin, I
do my system programming in FORTRAN...) shows how to prepare a
file for sharing. When the program is running you will have no
problem to TYPE or COPY the file TEST.DAT .
PROGRAM Share_Test
INTEGER I,J,FOR$RAB,SYS$SHARE,STATUS
C
OPEN(UNIT=1,FILE='TEST.DAT',STATUS='NEW',SHARED) ! Open File
I = FOR$RAB(1) ! Get RAB-Adress
J = 0 ! Init Counter
C
DO WHILE (.TRUE.) ! Infinite Loop
WRITE(1,*) ' TEST',J ! Write File
J = J + 1 ! Update Counter
IF(J.GT.100) THEN ! Time to Update File
J = 0
STATUS = SYS$FLUSH(%VAL(I)) ! Update File if necessary
IF(.NOT.STATUS) CALL SYS$EXIT(%VAL(STATUS)) ! Exit on Error
END IF
END DO
ENDinfo-vax@ucbvax.ARPA (07/20/85)
From: <#D15%DDATHD21.BITNET@WISCVM.ARPA>
Hi Don,
forget my firts program. There is an error in the declaration
of the variables and procedures. Here is the correct source:
PROGRAM Share_Test
IMPLICIT NONE
INTEGER I,J,FOR$RAB,SYS$FLUSH,STATUS,SYS$EXIT
C
OPEN(UNIT=1,FILE='TEST.DAT',STATUS='NEW',SHARED) ! Open File
I = FOR$RAB(1) ! Get RAB-Adress
J = 0 ! Init Counter
C
DO WHILE (.TRUE.) ! Infinite Loop
WRITE(1,*) ' TEST',J ! Write File
J = J + 1 ! Update Counter
IF(J.GT.100) THEN ! Time to Update File
J = 0
STATUS = SYS$FLUSH(%VAL(I)) ! Update File if necessary
IF(.NOT.STATUS) CALL SYS$EXIT(%VAL(STATUS)) ! Exit on Error
END IF
END DO
END