Accessing Files Programmer's Guide (32650-90885)

126 Chapter8
Writing to a File
Writing to a Magnetic Tape File
Example 8-6. Writing to an Unlabeled Magnetic Tape File
.
.
.
var
control_code : 0..65535; {Declare FWRITE parm. }
record_length: shortint; {Declare FWRITE parm }
file_record : record_type; {Record to be written to file; }
{record_type is 256-byte }
{fixed-length record. }
.
.
.
record_length:= -256; {Number of bytes in record. }
control_code := 0; {Default specified }
FWRITE ( unlabeled_tape_file, {HPFOPEN returned file number. }
file_record {Record to be passed }
record_length {Size of file_record. }
control_code {Required, but ignored. }
);
if ccode = CCL {check FWRITE condition code }
then handle_file_error (labeled_tape_file);
.
.
.
If the FWRITE intrinsic encounters an error condition (CCL), an error-handling procedure,
handle_file_error, is invoked. FWRITE returns a CCG condition code if the EOF is
reached. For details concerning FWRITE intrinsic parameters, refer to the MPE/iX
Intrinsics Reference Manual.
Writing to a labeled magnetic tape file
Example 8-7 is an HP Pascal/iX code segment that writes user-supplied data to the labeled
magnetic tape file opened in Example 5-6. For information about the HPFOPEN call that
returns the file number in the variable labeled_tape_file, refer to example 5-6.
Example 8-7. Writing to a Labeled Magnetic Tape File
.
.
.
var
control_code : 0..65535; {Declare FWRITE parm. }
record_length: shortint; {Declare FWRITE parm }
file_record : record_type; {Record to be written to file; }
{record_type is 256-byte }
{fixed-length record. }
.
.
.
record_length:= -256; {Number of bytes in record. }
control_code := 0; {Default specified }
FWRITE ( labeled_tape_file, {HPFOPEN returned file number. }
file_record {Record to be passed }