{ The Pascal OPEN statement does not allow the record type to be RMS } { "undefined" record type. In order to create such a file from Pascal, you } { must use a user-action routine as demonstrated below. Object files on } { OpenVMS I64 used the "undefined" file format since they are pure byte } { stream files. Using "undefined" allows you to append multiple object } { together into a ".OBS" file that can be processed by the linker. If } { another format was chosen, like fixed-length 512-byte records, single } { .OBJ files work correctly, but when concatenated together, the extra room } { at the end of each .OBJ file gets inserted between the files in the final } { .OBS file making it unusable. } [INHERIT('sys$library:starlet')] PROGRAM Create_UDF_File(INPUT,OUTPUT); TYPE Header_Type = PACKED RECORD F1 : INTEGER; F2 : [WORD] 0..65535; F3 : INTEGER; F4 : [BYTE] 0..255; END; VAR Buffer : VARYING [255] OF CHAR; Filename : VARYING [132] OF CHAR; F : TEXT; Header : Header_Type; { Use a USER_ACTION routine to set the FAB$B_RFM to FAB$C_UDF. } FUNCTION User_Action( VAR Fab : FAB$Type; VAR Rab : RAB$Type; VAR F : TEXT ) : INTEGER; VAR Status : INTEGER; BEGIN { Set the record format to UDF overwriting the VAR } { format that was set by the RTL since the file is } { a TEXT file. } Fab.FAB$B_RFM := FAB$C_UDF; { Do the $create } Status := $create(Fab); IF ODD(Status) THEN BEGIN { The $open was successful, now do the $connect } Status := $connect(Rab); END; { Return status from $open/$connect } User_Action := Status; END; BEGIN WRITE('Filename? '); READLN(Filename); OPEN(File_Variable := F, File_Name := Filename, History := New, Carriage_Control := None, User_Action := User_Action); REWRITE(F); { Since the file is defined as TEXT, we can write variable length things } { to it using a VARYING string as a temporary buffer. We need to use } { variable length write statements to RMS can accurately keep track of } { the file's end-of-file-block and end-of-file-block's last used byte. } { Use the DUMP/HEADER DCL command to examine the end-of-file block and } { end-of-file byte values. They are not displayed by DIRECTORY/FULL } Header.F1 := 16#12344321; Header.F2 := 16#ABCD; Header.F3 := 16#FEDCBA98; Header.F4 := 16#FF; Buffer.body::Header_Type := Header; Buffer.length := size(Header); WRITE(F,Buffer); CLOSE(F); END.