info-vax@ucbvax.ARPA (07/20/85)
From: Kevin Carosso <engvax!KVC@cit-vax>
I don't know what language your using or what the rules are in it,
but I do this from Pascal (either V2 or V3) all the time. I just
specify:
HISTORY := NEW, SHARING := READWRITE, ORGANIZATION := SEQUENTIAL
in the Pascal OPEN statement. In Pascal, "sequential" is the default
file organization, EXCEPT when you specify "readwrite" sharing. Then
for some reason it changes the default organization to indexed (or
something). I don't know why it does that, but remember: it is a
change of DEFAULT, not something that says sequential files cannot
be shared.
In any case, this seems to work fine. If it can be done in Pascal, it
can be done in any language, though you may need a useropen routine to
set the right bits in the FAB if the language doesn't give you enough
control.
One other thing... Due to RMS buffering, things you write won't
neccessarily make into the file right away for someone else to see.
What I do is a $FLUSH after I write anything significant to the file.
The Pascal code looks something like: (please note that references to
SYS$OUTPUT are NOT referring to a PPF, but rather to whatever file I did
a logical name assignment just before running the daemon this code came
from. This is to allay any fears that this only works to a PPF.)
(*---------------------------------------------------------------------------*)
(*
* "Log" writes an entry into the current log file (SYS$OUTPUT).
* We use $FLUSH to update the log file after every message is written.
*)
procedure Log (Message : varying [maxlen] of Char);
type
Unsafe_file = [UNSAFE] text;
RAB_ptr = ^RAB$TYPE;
var
sys_output_RAB : RAB_ptr;
function PAS$RAB (var F : [volatile] Unsafe_file) : RAB_ptr; extern;
begin (* Log *)
writeln (sys_output, Message);
sys_output_RAB := PAS$RAB (sys_output);
status := $FLUSH (sys_output_RAB^);
if not odd (status) then LIB$SIGNAL (status);
end;
/Kevin Carosso engvax!kvc @ CIT-VAX.ARPA
Hughes Aircraft Co.
ps. Yeah, I really do write all my system-type code in Pascal...
Not exactly standard Pascal, but then things I do are far
from standard... VMS Pascal is pretty neat.info-vax@ucbvax.ARPA (07/22/85)
From: Provan@LLL-MFE.ARPA Ah! I distinctly remember being able to write readable files, and now both of you have reminded me how. Unfortunately, I'd really like to protect the file against other writers. Unless RMS rejects subsequent opens with less sharability, it would seem that the log file writer would end up out in the cold if a casual writer, like a text editor, came along and read the file without any sharability options. Does RMS reject such opens? The manual says nothing about it. If it does, I guess I can put up with other programs, like multiple invocations of the same program, writing the same log file at the same time, although this isn't really desirable. Also, the manual says RMS supports file sharing for relative files, for indexed files, and for sequential files with 512-byte fixed-length records. Does this just mean that the support for other sequential files is only half ass?