ENSCRIBE Programming Manual 198104
ENSCRIBE Programming Manual 198104
111111
1111! I
111111.
m 111111
z(/)
111111
n
-m
1:;tJ
c:J
-c
~..,
l.··o
.
if
(D
8-~
-
3
-·
::J
JO
~
c
::J
c
c
-
ENSCRIBE
Programming
Manual 11 I1 -
I I I
I I I
1
11 . , 11 11
April, 1981
P/N 82083 Printed in U.S.A.
Copyright {c) 1981 by Tandem Computers Incorporated.
i-1
ENSCRIBE PROGRAMMING MANUAL
Table of Contents
i-3
Table of Contents
i-4
Table of Contents
i-5
Table of Contents
i-6
Table of Contents
i-7
Table of Contents
i-8
LIST OF FIGURES
Figure A-1. FC B L i n k i n g • . . • . . . . . • . . • . • . . • • • • • • • • . • • • • . • • • • • • • A- 4 3
i-9
LIST OF TABLES
i-10
SYNTAX CONVENTIONS IN THIS MANUAL
Notation Meaning
i-11
Conventions for Procedure Calls
where
CALL
<retval> :=
<retval>,<type>
where
<type>
is INT or INT(32)
<procedure name>
<parameters>
where
<type>
is INT,INT(32), or STRING.
i-12
ref
value
<num elements>
i-13
SECTION 1
INTRODUCTION TO ENSCRIBE
ENSCRIBE is a data base record manager that provides high level access
to, and manipulation of, records in a data base.
Key-Sequenced
Relative
Entry-Sequenced
Unstructured
• Record Locking
• Index Compression
• Cache Buffer
1-1
INTRODUCTION TO ENSCRIBE
VOLUME NAME
SUBVOL NAMES
SVOL1 - - - - - - - S V O L 2 - - - - - - - A C C T 1
$VOL 1
I (1) I (2) I (3)
---- INFILE
1-2
INTRODUCTION TO ENSCRIBE
STRUCTURED FILES
1-3
INTRODUCTION TO ENSCRIBE
PRIMARY
KEY
I
PRIMARY ACCESS IS VIA ADAMS I
VALUE IN THE PRIMARY
KEY FIELD.
BROWN I
EXAMPLE: COLLINS I
FIND " K I N G " - 7 _ _ _ FISH I
JACKSON I
I
KING KEY-SEQUENCED
I FILE
MASTERS
_l
OBRIEN
l
RYAN
l
r-WATS~_ JI )
I ZANTE
- - ·-~__.__
__.____
___ I
t
RECORDS ARE STORED
IN ASCENDING ORDER
OF "PRIMARY KEY" FIELD
VALUE.
1-4
INTRODUCTION TO ENSCRIBE
RELATIVE FILE:
RECORD
NUMBER RECORD
~~~~~~~I~~~~---~
0th
1st
PRIMARY ACCESS IS VIA
2nd
"RECORD NUMBER".
EXAMPLE: 3rd
F I N D 6 t h - z _ 4 th
5th
6th RELATIVE FILE
7th
~
• ~
fl-----~----lr
nth
t
J
RECORDS ARE STORED
ACCORDING TO A
"RECORD NUMBER"
SUPPLIED BY THE
APPLICATION PROGRAM
1-5
INTRODUCTION TO ENSCRIBE
ENTRY-SEQUENCED Fl LE:
RECORD
....., .., I
LATEST ,-----------, )
1-6
INTRODUCTION TO ENSCRIBE
CUSTOMER
A record is located among records of the same file by the value of its
primary key:
This is the only record of this record type having the primary
key entry "JONES, J.A."
1-7
INTRODUCTION TO ENSCRIBE
1-8
INTRODUCTION TO ENSCRIBE
RECORDS IN ORDER
OF "EMPLOYEE
NUMBER" ACCESS 008 : ::ADAMS
PATH 010 <BROWN
011 <:STEVENS <
013
016
IACCESS I
I PATH I
SAME FILE.
RECORDS IN ORDER
OF "NAME" ACCESS
PATH
ACCESS
PATH
A
A
B
B
SAME FILE. B
RECORDS IN ORDER c
OF "DEPT" ACCESS
PATH c
c
c
D
D
i
ACCESS
PATH
1-9
INTRODUCTION TO ENSCRIBE
FIND "JONES", APPROX. FIND "JONES", GENERIC FIND "JONES, K.A.", EXACT
LAST
RECORD
LANG, M.N.
McGRAW, H.E.
j LANG, M.N.
McGRAW, H.E.
MEYER, D.J.
IN FILE
1-10
INTRODUCTION TO ENSCRIBE
CUSTOMER FILE
NAME
' ADDRESS REGION
J INVENTORY FILE
f
PART NO. DESC'1_1PTfON ON-HAND PRICE
,
...! V" "'../ ...I.
12.50:
0201 T.V. SET
1-11
INTRODUCTION TO ENSCRIBE
1-12
INTRODUCTION TO ENSCRIBE
• an "end-of-file" pointer
1-13
INTRODUCTION TO ENSCRIBE
• Read-Only
• Write-Only
• Exclusive Access
• Protected Access
1-14
INTRODUCTION TO ENSCRIBE
LOCKING
The access and exclusion mode operate on a file from the time it is
opened until the time it is closed. To prevent concurrent access to
a disc file for shorter periods of time, a locking mechanism is
provided. Two types of locking are available, file locking and record
locking.
File Locking
Record Locking
Both record and file locking may be done concurrently to the same
file. A file lock will wait for all records to be unlocked before it
will be granted. Similarly, a record lock must wait if the file is
currently locked.
1-15
INTRODUCTION TO ENSCRIBE
WAIT/NO-WAIT I/O
The file system provides the capability for an application process to
execute concurrently with its file operations.
Two definitions:
• Wait I/O (the default)
"Wait" i/o means that when designated file operations are performed
(i.e., via file management calls), the application process is
suspended, waiting for the operation to complete.
• No-wait I/O
"No-wait" i/o means that when designated file operations are
performed, the application process is not suspended. Rather, the
application process executes concurrently with the file operation.
The application process waits for an i/o completion in a separate
file management call.
Whether "wait" or "no-wait" i/o is to be in effect when designated
file operations are performed is specified on a per OPEN basis when
files are opened. If "no-wait i/o" is specified, then the maximum
number df concurrent operations to be permitted must also be specified
at file open. Disc files are limited to one concurrent operation (one
outstanding no-wait call) per file open.
For example, to open a file so that one concurrent file operation is
permitted (i.e., a "no-wait" file), the following could be written in
~ ..,...., .a... ..: ,..... _
"!);'I"'"\, Y"'\ 1 ..; ....-. ~ ......., .,.. ...-... ,... _ - - I - _ _ •• _ _ .L. 1- - .L. II J: ~ , - - - - - 11 - - - ..1... - .! - - - -- - -W .! ..:I ..t:! ! , -
\,U& "'4J::'J::'..1.....L.'-'U.~..L.VU !::".LV~.LC:Ull \Cl..:>.:>Ulllt::: 1...UQI... .l....1..LCUQlllt:: \.,;Ulll...Q.1.111::> a va.L.1.U L.1.J..t::
name) :
CALL OPEN ~£ilename, fnumAl, 1);
The third parameter, "l", specifies that one concurrent
operation is permitted (this parameter is also used for other
purposes, see "OPEN").
Any input/output operation involves an "initiation" and a
"completion". With "wait" files both the initiation and completion
are performed in the same file management procedure call. For
example, on a wait file, the call
.
CALL READ(fnumAO,buffer, .. );
1-16
INTRODUCTION TO ENSCRIBE
CALL AWAITIO(fnumAl, .. );
1-17
INTRODUCTION TO ENSCRIBE
WAIT 1/0
OPENED AS A "WAIT" FILE
INITIATE
} CALL READ (11, ... );
COMPLETE
NO-WAIT 1/0
OPENED AS A "NO-WAIT" FILE
CONCURRENT
EXECUTION
1-18
INTRODUCTION TO ENSCRIBE
COMPLETED
IN THE ORDER
AS INITIATED
INITIATE f4 CALL READ (f4, ... ); INITIATE f6 1 CALL WRITE (f6, ... );
/
~----
I
INITIATE f5 CALL READ (f5, ... ); INITIATE f7 CALL READ (f7, ... );
I
I
I INITIATE f6 2 CALL WRITE (f6, ... );
;__ ~
COMPLETED IN THE
SAME ORDER AS
anyfile . = -1; INITIATED
anyf ile : = -1
COMPLETE
CALL AWAITIO
FIRST DONE CALL AWAITIO(anyfile, ... );
(anyfile, ... ); COMPLETE
CALL AWAITIO I
NE CALL AWAITIO (anyfile, ... );
COMPLETE
(anyfile, ... );
I
I
I COMPLETE CALL AWAITIO (anyfile, ... );
I
FIRST DONE OF
"f6 1" OR "f7"
Figure 1-9. No-Wait I/O (Multiple Concurrent Operations) 0878
1-19
INTRODUCTION TO ENSCRIBE
CACHE
1-20
INTRODUCTION TO ENSCRIBE
FILE CREATION
Disc files are created {defined) by
• using the Tandem-supplied File Utility Program {FUP)
The "creation parameters" {i.e., file type, record length, key
description, etc.) for a file to be created are set {specified) by
entering FUP commands. The state of file creation parameters can
be displayed and modified before the file is actually created.
Creation parameters can be set to those like another, existing
file.
FUP accepts commands entered at an online terminal or from a file
such as an EDIT-format file.
• calling the File Management CREATE procedure
programmatic file creation of disc files is accomplished by
supplying the appropriate parameters to the CREATE procedure.
File creation is described in section 5, "ENSCRIBE File Creation".
1-21
INTRODUCTION TO ENSCRIBE
FILE LOADING
The File Utility Program (FUP) can also be used to load data into
existing ENSCRIBE files. This is accomplished by supplying the set of
records to be loaded and specifying the f ile~s data and index block
loading factor. (The loading factor determines how much free space to
leave within a block). FUP attempts to optimize access to a file by
placing the lowest level index blocks on the same physical cylinder as
their associated data blocks, thus reducing the amount of head
repositioning.
1-22
INTRODUCTION TO ENSCRIBE
1-23
INTRODUCTION TO ENSCRIBE
• Hardware Structure
and
• Software Structure.
1-24
INTRODUCTION TO ENSCRIBE
1-25
INTRODUCTION TO ENSCRIBE
INTERPROCESSOR BUSES
l I-- 1
0 1 2
i---, r--1
p p
110 CHANNEL l/OCHANNEL
0 DUAL-POAT 0
A CONTROLLER A
T T
A B
~ ~
I
../
-
DISC
1-26
INTRODUCTION TO ENSCRIBE
There are two system i/o processes for each device (or set of devices
in the case of terminals or data communication lines) ; one located in
each of the two processors which are physically connected to a given
device. One process is designated the "primary" i/o process; the
other is designated the "backup" i/o process. (This primary/ backup
designation is made at system generation time.) Either i/o process is
capable of controlling the device. However, they do not control the
device simultaneously. Instead, the primary i/o process controls the
device exclusively and, at the same time, keeps the backup i/o process
informed (via checkpoint messages) of the activity on the device.
1-27
INTRODUCTION TO ENSCRIBE
Figure 1-11 below shows the primary and alternate communication paths
to a device. While the primary path is operable, all i/o transfers
occur via that path. Only when a failure of the primary path is
detected, does the alternate path come into use. Once an alternate
path is brought into use, it becomes the primary path and is used
exclusively.
PRIMARY PA TH
DISC
ALTERNATE PATH
;±:;
l.:iUAHUIAN
' \
DISC
© = APPLICATION PROCESS
1-28
INTRODUCTION TO ENSCRIBE
A
p
p
BUFFER }
L
~11111
I
c
A
T
I
0
N
p
R
0 !!!i=:=::::::~:~:~~~:-::~:i::::::::::{ D
A
c :::: CALL READ ::: T
A
E
s
s
!ill 1I
1
!I .____
oA_T_A___} :gRDS
0
THE READ PROCEDURE.
-{ w:~:=~ }J
BUFFERS
l
PROCEDURE TRANSFERS THE DATA
FROM THE SYSTEM TO THE
APPLICATIONS BUFFER
1-29
INTRODUCTION TO ENSCRIBE
File Open
The OPEN procedure establishes a communication path to a file. The
symbolic file name that identifies a file is used to search a table, a
copy of which resides in each processor module, called the Logical
Device Table. The Logical Device Table contains an entry for each
device connected to the system. Each entry contains a device name or,
in the case of disc files, a volume name, the process id of the
"primary" system i/o process that controls the device/volume, and the
process id of the "backup" system i/o process that controls the
device/volume.
In the following illustration, the logical device table is searched
for an entry corresponding to the volume name "$VOLUME". The entry
is associated with logical device four and a path is established to
the primary i/o process controlling the device.
Next, in the ca9e of disc files, a directory on the disc volume is
searched for the subvolume name and the the disc file name that was
supplied to OPEN. The entry associated with a subvolume and disc file
name is a file label which contains information describing the state
of the file, including the location of allocated extents, end-of-file
location, file type, etc.
In the following illustration, the file label is searched for a
subvol designated "MYFILES" and a disc file named "FILEA".
Once the file is located, whether it is a disc file, non-disc device,
process, or the operator console, an Access Control Block (ACB) is
created for that file in the processor~s memory where the caller to
OPEN is running. The ACB is used by other file system functions when
referencing the file. It contains information such as the logical
device number of the device where the file resides and, for disc
files, information "local" to the particular open of the file such as
the current record pointer and next record pointer.
If the open is to a disc file and the file is not currently open, one
File Control Block (FCB) is created in the memory of each of the two
processor modules that contain the system i/o processes that control
the volume containing the file. The FCB contains information which is
"global" to all accessors of the file. This includes a copy of the
information from the file label, such as allocated extents and
end-of-file location, along with dynamic control information such as
which process has the file locked and which processes if any are
waiting to lock the file.
1-30
INTRODUCTION TO ENSCRIBE
There is a single FCB for each open disc file in the system (in each
of the two processor modules controlling the associated device) while
there is an ACB created every time a file is opened. Thus each open
of a given file provides a logically separate access to that file
(i.e., separate current-record and next-record pointers), yet the
end-of-file location is maintained in the FCB so that it has the same
setting for all accessors of the file.
In the following illustration, the access control block indicates
that logical device four is associated with the file indicated by
"$VOL1 I I .
When OPEN completes, it returns a file number to the application
process. The file number is an index into a table that contains an
address pointer to the associated access control block.
How the File System takes the file name passed with an OPEN procedure
and builds the control blocks used to control subsequent access to the
file is illustrated in Figure 1-13 on the following page.
1-31
r---1LOGICAL
DEVICE
TABLE
DESTINATION
CONTROL
TABLE
II (NonStop
SYSTEM)
(Nonstop 11
SYSTEM)
I LDEV 3
LDEV 4
-
I - -..._ ---......_ CHECKPOINT ~
""- OFFCB ~
I I c:
r--,
LDEV 6
Q)
r---
APPLICATION PROCESS __J___ I FILE
CONTROL
°'
0
\'"Trm" IL
------m
1
I \ i 1
\
§
LOCK QUEUE
1
MAIN-MEMORY M
I \I \I
. ---7 ) I
I I
L
...... __
EOF PTA
DATA ADDRESS
)
RESIDENT IN
i'O PROCESS'S
PROCESSOR MODULE
r-f
I
r-f
Q)
""~'"//T7
/ / E •
I, ~
i:r::I
al
H
I l T~·;;E I
ECP'fR
EC PTA
z
0
H
E-i
u
:::>
0
~
N
M
E-i I
z
H
r-f
INTRODUCTION TO ENSCRIBE
File Transfers
In the case of disc files, the information in the access control block
(such as the current-record and next-record pointers) and the
information in the file control block (such as the end-of-file pointer
and addresses of allocated extents) is updated with the execution of
each i/o operation.
As accesses which necessitate changes to the FCB are made to the file,
the system process which is currently responsible for controlling the
disc ensures that the copy of the FCB in the other processor which can
access the disc is updated. Thus, if the primary processor- fails, the
backup has all the information necessary for a smooth transition
(which is invisible to the user). In addition, when a new extent is
allocated or the file is renamed, the file label on the disc is
updated to reflect this change. This ensures that no disc space is
lost, even in the event of a total system failure. However, when the
end-of-file is changed or the file is written into, which requires
updating the last modification timestamp, only the main-memory copies
are updated. (Updating the file label each time the file is written
into would be an unnecessary amount of additional overhead, because
the current eof and last modification timestamp would be lost only in
the event of a total system failure. The user who is concerned about
the eof being updated on disc can force this to happen with the
CONTROL request to set the end-of-file.)
1-33
,-- LOGICAL
--1
I DEVICE
TABLE
I
(Nonstop
I
SYSTEM)
I
c=27_)___
APPLICATION PROCESS
+~
ii I
I ------,
INT f1lenum
+
'---\
I
I
I II I
1.-4
L
I I
-0 8
Q)
r-1
•..-f
li.t
LL D~~~~~
,
1
FILE
TABLE
A B ADDRESS:--.::
f L
I
J <e:;f4
r-1
r-1
I
I "'-----t- Q)
µ
::s
O'I
·r-1
~ L:Al~Y ~T ~NG SYSTEM
_ _ _J li.t
i:Q
H
p::
{)
Ul
z~
0
E-t
z
0
H
E-t
{)
::::>
Cl
~
<e:;f4
M
E-t I
z r-1
H ---
INTRODUCTION TO ENSCRIBE
Buffering
BUFFER IN FILE
DATA DATA 1/0 DATA
APPLICATION •~---~ SYSTEM 41 •
BUFFER
PROGRAM BUFFER
1-35
INTRODUCTION TO ENSCRIBE
The i/o process first secures resident I/O Buffer space in its
processor module (the amount of I/O Buffer space secured is dependent
on the transfer count specified in the file management procedure call)
then initiates the i/o transfer. When the i/o transfer with the
device is completed, the data is moved from the I/O Buffer in the
device~s processor module to the File System Buffer in the
application~s processor module. If these are different processor
modules, then this is accomplished by an interprocessor bus transfer.
At this point, the file system (executing on behalf of the
application process) moves the data from the resident File System
buffer to an array in the application process~s (virtual) data area.
For the Tandem Nonstop II system, File System buffers are obtained
from the process~s Process File Segment (PFS). I/O buffers are
obtained from the i/o segments as needed by the i/o process.
Processes that require dedicated buffers obtain buffer space during
initialization. Once a process has obtained dedicated buffer space,
it keeps that space until it terminates execution.
For the Tandem Nonstop System, File System Buffers are obtained from a
memory space pool, called SHORTPOOL, in the operating system~s data
area. Processes requiring File System Buffers compete for this space
on a first-come, first-served basis. If space is not available when
needed, the application process is suspended until either the needed
space becomes available or a configured timeout period expires (in the
latter case an error indication is returned to the application
process). When an i/o transfer is completed, the space in use by the
File System Buffer is returned to SHORTPOOL for use in subsequent data
transfers.
For the Tandem Nonstop System, there are three types of IiO Buffers
(the type of buffer that a device uses is specifed at system
generation time) :
1-36
INTRODUCTION TO ENSCRIBE
File Close
When a file is closed, the communication path to the file is broken.
The access control block is deleted and the space that it used is
returned for use as another access control block. In the case of disc
files, if no other opens are outstanding for the file, then the file
control block is also released and information such as the end-of-file
pointer and addresses of allocated extents is updated on the physical
disc from the information that was maintained in the file control
block.
1-37
INTRODUCTION TO ENSCRIBE
The backup i/o process, when notified of the primary~s failure, takes
over the primary~s duties. The first action that the backup performs
is to execute the i/o operation indicated by the latest checkpoint
message received from primary i/o process (this occurs regardless of
whether or not the operation had been completed by the primary).
Following a takeover from its primary, the backup i/o process checks
the sync id and requestor id in the i/o request message for a match in
the list of completed operations. If there is a match, the requested
operation has already completed and the backup i/o process returns the
associated completion status to the file system (and no other action
is taken). If there is no match, the backup i/o process has not
performed the operation. The operation is performed in its entirety
and the operation~s completion status is returned to the file system.
1-38
INTRODUCTION TO ENSCRIBE
I
(i/o) = primary backup = (i/o~)
(i/o) (i/o~)
I I
[ I ] sync id in FCB sync id in FCB ~
1-39
INTRODUCTION TO ENSCRIBE
1-40
INTRODUCTION TO ENSCRIBE
I
(i/o) ( i/o"")
I I .
ITJ sync id in FCB sync id in FCB IT]
(a)
I ( i/o"")
(i/o)
1-41
INTRODUCTION TO ENSCRIBE
~
I
sync id in FCB sync id in FCB [TI
*3. The state of the operation about to be performed is check-
pointed to the backup i/o process. The checkpoint contains:
the requestor id
the updated sector image
the next sync id
(i/o) checkpoint message ~~~~~~-> (i/o ... )
I I
~ sync id in FCB sync id in FCB ~
1-42
INTRODUCTION TO ENSCRIBE
(a)
I
i/o request message (data, sync id, requestor id)
I
I
( i/o"")
I
sync id in FCB IT]
6. The backup i/o process compares the requestor id and sync id
in the i/o request message with that of operations is has
already performed. (*) The backup recognizes that this is a
request to perform an operation is has already completed.
Therefore, the operation is not performed. Rather, the
completion status from the completed operation is returned to
the file system.
(a)
(a)
1-43
INTRODUCTION TO ENSCRIBE
Mirror Volumes
A "mirror" disc volume consists of a pair of physically independent
disc devices that are accessed as a single volume; each device is
usually controlled through two independent disc controllers. With
this configuration, both devices of a mirror volume are controlled by
the same i/o process-pair. Each mirror volume is controlled by a
separate i/o process-pair. The mirror designation for a volume is
indicated to the system at system generation time. The hardware
congiguration of a mirror volume is shown in Figure 1-16.
p p
0 0
R DUAL-PORT R
T CONTROLLER T
A B
p
R
I
lI
I ~I
R
y
p
~ J I
MIRROR VOLlME
A
T
H
p p
0 0
R DUAL-PORT R
T CONTROLLER T
A B
1-44
INTRODUCTION TO ENSCRIBE
1-45
SECTION 2
The ENSCRIBE Data Base Record Manager provides these disc file
structures:
• Key-Sequenced
• Relative
• Entry-Sequenced
• Unstructured
These four file types fall into two major groups, structured files and
unstructured files. Key-sequenced, relative, and entry-sequenced
files are structured files, and unstructured files are, of course,
unstructured files.
STRUCTURED FILES
2-1
ENSCRIBE DISC FILES
Key-Sequenced Files
A record may vary in length from one byte (1) to the maximum specified
for record size when the file was created. The number of bytes
allocated for a record is the same as that written when the record was
inserted into the file. Each record has a length attribute that is
optionally returned when a record is read. A record~s length can be
changed after the record has been entered (with the restriction that
the length cannot exceed the specified record size) • Records in a
key-sequenced file can be deleted.
When an index block fills up (i.e. there is not enough space in the
index block to point to all the data blocks), the block is split into
two parts. A new index block is allocated and some of the pointers
are moved from the old index block to the new one. The first time
that this occurs in a file, it is necessary to generate a new level of
indices. This is accomplished by allocating a higher level index
block which has the low key and pointer to the two lower level index
blocks (which in turn point to many data blocks) .
2-2
ENSCRIBE DISC FILES
The user may optionally specify when the file is created that data
and/or index records are to be compressed. Compression results in
only the significant bytes of the record being stored on the disc.
When the record is accessed, it is reconstructed from the significant
data and additional information which relates the insignificant data
to significant data in another record in the block. Data compression
thus reduces storage requirements on the disc at the cost of slightly
higher processing time. For sequential processing it can also reduce
disc accesses since more records will fit in a block. Data
compression can have the additional affect of reducing index levels.
When compression is applied to index blocks, it may have the added
advantage of reducing the number of index levels so that less reads
are necessary to access any data record. This happens because an
index block may now point to more data blocks, so there is a
proportionate reduction in the number of index blocks.
2-3
r r---K-~~--~SEQUENCEO
tij
FILE STRUCTURE
FINO "PAWf'
1 z
(/)
0
~
H
tP
Cf= I MO~LY I I: <+ l } FIRST IHIGHESTIUVFL INDEX BLOCK
tij
0
H
<D ~
KEY
N
I
I-' ---+----------1......E§oL};Jcfiloe:F l~Ci.Eo>T:IJ~?.~) ---EMPTY - l
~
.. [ o.ANA?1?:< ::.r·~~LE·~.::17 .[FLOSSY-TI)\ EMPTY I
<D
~
•
I
(/)
•
<D •
~o -------•[lo.ulsE]I.?~TMJ\el.eTTMJ\;yT :: :: : :\<\ r-EP.1PTv--]
c: DATA
BLOCKS
<D
::l -------.::MOLLY::1 OLGA RUTH>(: TAMMY+<) PJJTWiuY ::) SECOND LEVEL INDEX BLOCK
0
<D
0.. ' I -+---- FNi()Liv-p?:~T~'.ANCYl:~'..~7\YJTNATJ\l.!J] r- EMPTY---]
t-:rj
..... /
DATA
-"'
f--1 -
<D
(/)
·--+--------r OLGA J?: >?::] PAM -ir~rm \ EMPTY -=i
rt '--,---"
H
c:
KEY •
•
-------Fw1.Li:v-l?]/ znDA +::::::::::::::::::::::1
0
rt \ \--EMPT'Y-J
c:
H
<D ,._ +·
VARIABLE LENGTH
~1 ' I __J
SAVED FOR
FUTURE INSERTIONS
PHYSICAL RECORDS
nrn10
ENSCRIBE DISC FILES
Relative Files
2-5
ENSCRIBE DISC FILES
FIRST RECORD
_l_D_AT_A__ :::_.:<_d~_DA_T_A~_l/_(/_Y~_:·µ._~~_::P.~.:<_:J___D_A_TA~--.......)~
/ v v v v-- ~
,.. ••
·I / v I
v v- ~
I v:n
.. ., ..
DATA DATA DATA DATA )):::]
, .. , ..,
FIXED LENGTH PHYSICAL RECORDS.
EACH RECORD POSITION OCCUPIES
A FIXED AMOUNT OF SPACE, WHETHER
OR NOT THE RECORD HAS BEEN
WRITTEN IN.
0078
Relative files are best suited for applications where random access to
fixed length records is desired and the record number may function as
the key to the file. In the earlier inventory example, it would be
possible to make the inventory file a Relative file where the relative
record number was equal to the part number. However, this would
probably be wasteful of space since part numbering schemes typically
leave large gaps in the numbers and this would result in many records
allocated but not used. However, an employee file where the relative
record number was equal to the employee number would be a good
application for a Relative file, since there are typically no large
gaps in this kind of file. Data fields in the record could consist
of such things as name, address, department, salary, etc.
2-6
ENSCRIBE DISC FILES
Entry-Sequenced Files
A record may vary in length from zero byte (empty) to the maximum
specified for the record size when the file was created. The number
of bytes allocated for a record is the same as that written when the
record was inserted into the file. Each record has a length attribute
that is optionally returned when a record is read. A record~s length
cannot be changed after the record is written into the file. Records
in an entry-sequenced file cannot be deleted.
2-7
ENSCRIBE DISC FILES
Some definitions:
2-8
ENSCRIBE DISC FILES
The current key specifier defines the current access path. The
current access path determines the order that records are returned
when the file is read sequentially.
The current key specifier, and therefore the current access path, is
implicitly set to the file~s primary key when a file is opened or a
call is made to the POSITION procedure (for relative and entry-
sequenced files only). The access path is set explicitly by calling
the KEYPOSITION procedure. Figure 2-4 shows a typical record
structure with a primary key and three alternate keys.
AN INVENTORY RECORD
/ / /
SYSTEM-DEFINED APPLICATION-DEFINED
KEY SPECIFIER = 0 KEY SPECIFIERS ="OH" "LO" "VN"
EXAMPLES:
1. TO POSITION VIA PRIMARY KEY
KS:= 0; ! KEY SPECIFIER. PRIMARY
CALL KEYPOSITION (FNUM, KEY, KS);
2. TO POSITION VIA AN ALTERNATE KEY
KS:= "OH";! ON-HAND KEY FIELD
CALL KEYPOSITION (FNUM, KEY, KS);
2-9
ENSCRIBE DISC FILES
The current key value can be set explicitly by calling the POSITION or
KEYPOSITION procedures. KEYPOSITION is used to position by primary
key for key-sequenced files and by alternate key for key-sequenced,
relative, and entry-sequenced files. POSITION is used to position by
primary key for relative and entry sequenced files. The current key
value is implicitly set following a call to READ to the key value of
the current access path in the record just read.
RECORD
PRIMARY
KEY
KEY':=' "FISH";
MASTERS
OBRIEN
RYAN
2-10
ENSCRIBE DISC FILES
The positioning mode, compare length, and current key value determine
the first record accessed and the records comprising a subset of
records. Positioning mode and compare length (as well as current key
specifier and current key value) are set explicitly by the KEYPOSITION
procedure and implicitly by the OPEN and POSITION procedures. There
are three positioning modes: approximate, generic, and exact.
EXACT. Exact positioning means that the only records accessed are
those whose key field, as designated by the current key specifier,
contains a value of exactly compare length bytes and is equal to the
current key value. When the current key no longer matches, an
end-of-file indication is returned. Exact positioning on a key field
having a unique value accesses at most one record.
2-11
ENSCRIBE DISC FILES
Subset
A subset is a related set of records in the current access path. The
records comprising a subset are determined by the current key value
and positioning mode. A subset may consist of all, part of, or none
of the records in a file.
ALTERNATE KEYS
Alternate keys are implemented as follows. For each file having one
or more alternate keys, at least one alternate key file exists. Each
record in an alternate key file consists of:
• Two bytes for the <key specifier>
• The alternate key value
• The primary key value of the associated record in the primary file.
The length of an alternate key record is at least
2 + alternate key field length + primary key length
Figure 2-6 on the following page shows how alternate keys are
implemented.
2-12
ENSCRIBE DISC FILES
'------.---J/ '--~1--/
KEY SPECIFIERS 0 "OH" "LO" "VN"
EXAMPLE
PRIMARY FILE DATA
A
A
~ ,,.... ~ ~
"LO" D 0322
"OH" 5 0201
"OH" 12 0322
~ ~ ~ ~
"OH"
l"VN"l TWR
l 0115 J
~'
A /
I
KEY ALTERNATE PRIMARY
SPECIFIER KEY VALUE KEY VALUE
2-13
ENSCRIBE DISC FILES
2-14
ENSCRIBE DISC FILES
2-15
ENSCRIBE DISC FILES
UNSTRUCTURED FILES
UC:ULIC-' "LJ.LQU~
2-16
ENSCRIBE DISC FILES
2-17
ENSCRIBE DISC FILES
2-18
ENSCRIBE DISC FILES
CREATE
OPEN (first)
OPEN (any)
READ
WRITE
READUPDATE
WRITEUPDATE
2-19
ENSCRIBE DISC FILES
POSITION
CLOSE (last)
where
2-20
SECTION 3
ENSCRIBE FILE MANAGEMENT PROCEDURES
An application process accesses ENSCRIBE disc files through calls to
ENSCRIBE file management procedures. This section contains detailed
syntax descriptions of all the ENSCRIBE file management procedures.
The section begins with a brief summary of all of the ENSCRIBE calls.
Then characteristics common to all of the calls are described. The
section continues with a full syntax description of disc file names,
both for single system and network applications. Following the file
name description, syntax descriptions of all the ENSCRIBE file
management calls are listed in alphabetical order.
3-1
ENSCRIBE: FILE MANAGEMENT PROCEDURES
DEVICE INFO provides the device type and physical record size
for a file (open or closed)
KEYPOSITION sets the current key value and current key specifier
for an open Enscribe disc file
provides the <system number> corresponding to a
<system name>
3-2
ENSCRIBE: FILE MANAGEMENT PROCEDURES
READUPDATELOCK
is the same as READUPDATE except that it first locks
the record before reading it
REFRESH is used to write the information contained in File
Control Blocks (FCBs) in main-memory, such as the
end-of-file pointer, to the associated physical disc
volume
RENAME renames an open disc file and makes a temporary
disc file permanent
which message is being replied to
3-3
ENSCRIBE: FILE MANAGEMENT PROCEDURES
WRITEUPDATEUNLOCK
Completion
If a file is open with no-wait i/o specified, the following calls must
be completed by a corresponding call to AWAITIO:
If a file is open with no-wait i/o specified, the following calls are
rejected with a file management error 27 if there are any outstanding
{i.e., uncompleted) operations pending:
3-4
ENSCRIBE: FILE MANAGEMENT PROCEDURES
Regardless of whether the file was opened with wait or no-wait i/o
specified, a return from the following calls indicates a completion:
CANCELREQ, CLOSE, CREATE, DEVICEINFO, FILEINFO, FILERECINFO
KEYPOSITION, NEXTFILENAME, OPEN (unless flag <8> is set to 1),
POSITION, PURGE, RENAME, and SETMODE.
<tag> Parameters
An application-specified double integer - INT(32) - tag can be passed
as a calling parameter when initiating an i/o operation (e.g., read or
write) with a no-wait file. The tag is passed back to the application
process, through the AWAITIO procedure, when the i/o operation
completes. The tag is useful for identifying individual file
operations and can be used in application-dependent error recovery
routines.
<buffer> Parameter
The data buffers in an application program used to transfer data
between the application process and the file system must be integer
(INT) or double integer (INT(32)) and must reside in the program's
data area ('P' relative read-only arrays are not permitted).
3-5
ENSCRIBE: FILE MANAGEMENT PROCEDURES
Condition Codes
All file management procedures return a condition code indicating the
outcome of the operation. THE CONDITION CODE SHOULD ALWAYS BE
CHECKED FOLLOWING A CALL TO A FILE SYSTEM PROCEDURE and should be
checked before an arithmetic operation or a store into a variable is
performed. Generally, the condition codes have the following
meanings:
< (CCL) an error occurred (call the file management FILEINFO
procedure to determine the error)
= (CCE) operation was successful
> (CCG) a warning message (typically end-of-file, but see the
individual procedures for the meaning of CCG or call
FILEINFO to obtain an error number)
3-6
ENSCRIBE: FILE MANAGEMENT PROCEDURES
Errors
Associated with each call completion is an error number. The error
numbers into fall into three major categories. As shown below, the
setting of the condition code indicates the category of the error
associated with a completed call.
Error cc Category
0 CCE No error. Operation executed successfully.
The error number associated with an unopen file or a file open failure
can be obtained by passing the <file number> as -1 to the FILEINFO
procedure:
CALL FILEINF0(-1, errAnum) i
3-7
ENSCRIBE: FILE MANAGEMENT PROCEDURES
READ ACCESS. The disc file must be open with read or read/write
access for the following calls to be successful (otherwise the call
will be rejected with a file management <error> 49, "access
violation") :
READ, READLOCK, READUPDATE, and READUPDATELOCK.
WRITE ACCESS. The disc file must be open with write or read/write
access for the following calls to be successful (otherwise the call
will be rejected with a file management <error> 49, "access
violation"):
CONTROL, WRITE, WRITEUPDATE, and WRITEUPDATEUNLOCK.
PURGE ACCESS. The caller must have purge access to a disc file for
the following calls to be successful (otherwise the call will be
rejected with a file management <error> 48, "security violation"):
PURGE and RENAME.
3-8
ENSCRIBE: FILE MANAGEMENT PROCEDURES
EXTERNAL DECLARATIONS
Like all other procedures in an application program, the File
Management Procedures must be declared before being called. These
procedures are declared as having "externaln bodies. The external
declarations for these procedures are provided in a system file
designated "$SYSTEM.SYSTEM.EXTDECS". A SOURCE compiler command
specifying this file should be included in the source program
following the global declarations but preceding the first call to one
of these procedures:
<global declarations>
3-9
File Names
FILE NAMES
File names are used when creating new disc files, purging old disc
files, and renaming disc files.
There are two forms of file name - "external" and "internal". The
external form is used when entering file names into the system from
the outside world (e.g., by a user to specify a file name to the
Command Interpreter). The external form is described in the GUARDIAN
Programming Manual. The internal form is used within the
system when passing file names between application processes and the
operating system. This section describes the internal form.
The conversion from external to internal form is performed
automatically by the Command Interpreter for the IN and OUT file
parameters of the RUN command. (See the COMINT section of the
GUARDIAN Command Language and Utilities Manual for details of the RUN
command.) For general conversion of file names from the external to
the internal form, the FNAMEEXPAND procedure is provided. For
conversion from internal to external form, the FNAMECOLLAPSE procedure
is provided.
The internal form of disc file names is:
3-10
File Names
o <volume name>
<volume names> identify disc packs (each pack in the system has a
<volume name>). They are assigned at system generation time and when
new disc packs are introduced into the system. A <volume name> must
be preceded by a dollar sign "$" and consists of a maximum of seven
alphanumeric characters; the first character must be alphabetical.
o <subvol name>
This name identifies a subset of disc files. <subvol names> are
assigned programmatically when disc files are created. A <subvol
name> consists of a maximum of eight alphanumeric characters; the
first character must be alphabetical.
This name identifies a particular disc file. <disc file names> are
assigned programmatically when disc files are created. A <disc file
name> consists of a maximum of eight alphanumeric characters; the
first character must be alphabetical.
3-11
File Names
3-12
File Names
Note that names of disc volumes and other devices, when embedded
within a network file name, are limited to having six characters, and
do NOT begin with a dollar sign. Similar restrictions apply to the
network form of <process id>, as follows.
Note that <process name> in words 1 and 2 can contain at most four
alphanumeric characters (the first one must be alphabetic, as
usual) and does NOT include the initial dollar sign "$".
The application program rarely, if ever, concerns itself with octal
<system numbers> in network file names. Usually, the application
passes the external form of the file name (which contains a system
name, rather than a number) to the procedure FNAMEEXPAND, which
converts the system name into the corresponding number.
Conversion between internal and external forms of network file names
is accomplished by the procedures FNAMEEXPAND and FNAMECOLLAPSE.
3-13
AWAITIO Procedure
AWAIT IO
The AWAITIO procedure is used to complete a previously initiated
"no-wait" i/o operation. AWAITIO can be used to -
• Wait for a completion with a particular file. Application process
execution is suspended until the completion occurs. A timeout is
considered to be a completion in this case.
• Wait for a completion with any file or a timeout to occur. A
timeout is not considered to be completion in this case.
• Check for a completion with a particular file. The call to AWAITIO
immediately returns to the application process regardless of
whether there is a completion or not. (If there is no completion,
an error indication is returned.)
• Check for a completion with any file.
If AWAITIO is used to wait for a completion, a time limit can be
specified as to maximum time allotted to completing the waited-for
operation.
3-14
AWAITIO Procedure
where
3-15
AWAITIO Procedure
example
CALL AWAITIO ( f ileAnum ) ;
IF< THEN .•• error occurred.
3-16
AWAITIO Procedure
Considerations
• Error Handling
3-17
AWAITIO Procedure
e AWAITIO Completion
• AWAITIO Operation
Figure 3-1 illustrates the operation of the AWAITION procedure.
3-18
AWAITIO Procedure
CHECK for any (file num) WAIT for any (file num)
1/0 completion 1/0 completion
NO COMPLETION NO COMPLETION
CCL (error 40) returned; CCL (error 40) returned;
<
file number returned in fn) ;
No 1/0 operation is canceled.
file number returned in (fn) ;
Oidest (file num) 1/0 operation canceled;
Tag of canceled call returned in (tag) .
- - - - - -11------------------+-----------------
CHECK for any 1/0 completion on any WAIT for any 1/0 completion on any
open file open file
NO COMPLETION NO COMPLETION
CCL (error 40) returned; CCL (error 40) returned;
- 1 returned in (fn) ; - 1 returned in ( fn) ;
No 1/0 operation is canceled. No 1/0 operation is canceled.
3-19
AWAITIO Procedure
CALL AWAITIO
>-1 -1
PARTICULAR Fl LE ANY FILE
COMPLETION
TIMEOUT TIMEOUT
...--------
CCL CCL
<error '= 40 <error>= 40
3-20
CANCEL Procedure
CANCEL
where
example
3-21
CANCELREQ Procedure
CANCELREQ
where
example
Considerations
3-22
CLOSE Procedure
CLOSE
example
CALL CLOSE ( fnum ) ;
Considerations
3-23
CONTROL Procedure
CONTROL
3-24
CONTROL Procedure
example
CALL CONTROL ( printer, formAcontrol, vfuAchannel ) ;
IF< THEN.... ! error occurred.
The control operations that apply to disc files are listed in Table
3-3 below.
3-25
CONTROL Procedure
Considerations
• Writing EOF to an Unstructured File
A write end-of-file to an unstructured disc file sets the
end-of-file pointer to the relative byte address indicated by
the setting of the next-record pointer and writes the new
end-of-file setting in the file label on disc. Specifically:
end-of-file pointer := next-record pointer;
3-26
CREATE Procedure
CREATE
The CREATE procedure is used to a define new structured or
unstructured disc file. The file can be either temporary (and deleted
when closed) or permanent. If a temporary file is created, CREATE
returns a file name suitable for passing to the OPEN procedure.
The call to the CREATE procedure is:
3-27
CREATE Procedure
3-28
CREATE Procedure
3-29
CREATE Procedure
example
CALL CREATE(filename,5,0);
IF< THEN ••• CREATE failed.
Considerations
3-30
CREATE Procedure
• Error Handling
If the CREATE fails (i.e., condition code other than CCE returned},
the reason for the failure can be determined by calling the
FILEINFO procedure and passing -1 as the <file number> parameter.
• File Security
The file is created with the default security associated with
the process creator's access id. Security can be changed by
opening the file and calling SETMODE or SETMODENOWAIT.
3-31
CREATE Procedure
word:
where
- - - - hln~k
<innPx lPnarh>_,
------- ----..1--- TN~-
----,
3-32
CREATE Procedure
0 8
KEY DESCRIPTION
FOR
ALTERNATE KEY nk - 1
FILE NAME
OF
KEY FILE nf - 1
Key Description for key "k" consists of four words of the form:
0 8
[k * 4 + l] <key specifier>
[k * 4 + 2] <key attributes>
3-33
CREATE Procedure
where
where
3-34
CREATE Procedure
3-35
CREATE Procedure
$<volume name> or
\<sys num><volume name>
for partition n
<primary extent size> part 1 [l]
.
. I
.
.
<secondary extent size> part n
3-36
CREATE Procedure
where
<num extra partitions>, INT,
is the number of extra volumes (other than the one specified
in the <file name> parameter) on which the file is to reside.
The maximum value permitted is 15. Note that every other
parameter in the partition array (except <partial key
length>) must be specified <num extra partitions> times.
$<volume name> or
\<sys num><volume name>, eight bytes blank filled,
is the name of the disc volume (including "$" or "\") where
the particular partition is to reside.
3-37
CREATE Procedure
3-38
DEVICEINFO Procedure
DEVICE INFO
The DEVICEINFO Procedure is used to obtain the device type and the
physical record length for a file. The file may be open or closed.
The call to the DEVICEINFO Procedure is:
3-39
DEVICEINFO Procedure
example
CALL DEVICEINFO ( infile, devtype, reclength ) ;
-1
3-40
DEVICEINFO Procedure
3-41
EDITREAD Procedure
EDI TREAD
The EDITREAD procedure reads text lines from an edit file
(filetype = 101). Before EDITREAD can be called, a call to
EDITREADINIT must be completed successfully.
Text lines are transferred, in ascending order, from the text file
to a buffer in the application program~s data area. One line is
transferred with each call to EDITREAD. EDITREAD also returns the
sequence number associated with the text line and performs checks
to ensure that the text file is valid.
The edit file can be opened with nowait i/o specified. However, a
call to EDITREAD completes before returning to the application
program; it is not completed with a call to AWAITIO.
The call to the EDITREAD procedure is:
3-42
EDITREAD Procedure
example
count := EDITREAD(controlAblock, line, length, seqAnum):
3-43
EDITREAD Procedure
First the text file is opened and verified that it is an edit format
file:
CALL OPEN(fname,fnum,.):
IF< THEN·~·:
CALL FILEINFO(fnum,,,,,,,,,fcode):
IF fcode <> 101 THEN •• ! not edit format file.
END:
loop:
IF (count := EDITREAD(controlAblock,line,length,seqAnum)) < 0
THEN
BEGIN unsuccessful
END
ELSE
IF count> length THEN ••• line truncated.
GOTO loop
If the read is successful, a count of the number of bytes in
the text line is returned in "count", the text line is
returned in the array "line", and the sequence number is
returned in "seqAnum".
3-44
EDITREAD Procedure
more EDITREADs
.
editAcb[l] ':=' position for 3; restore saved position
editAcb.<O> := O;
next EDITREAD returns same record returned after position was
! saved
3-45
EDITREADINIT Procedure
EDITREADINIT
The EDITREAD procedure is called to prepare a buffer in the
application program~s data area for subsequent calls to EDITREAD.
The application program designates an array to be used as an
<edit control block>. The <edit control block> is used by the
EDITREAD procedure for storing control information and for an
internal buffer area.
The edit file can be opened with NOWAIT I/O. However, a subsequent
call to EDITREADINIT completes before returning to the application;
it is not completed with a call to AWAITIO.
3-46
EDITREADINIT Procedure
example
INT .contro1Ablock[0:167];
n := EDITREADINIT(controlAblock, fnum, 256);
3-47
FILEERROR Procedure
FILEERROR
The FILEERROR procedure is used to determine if an i/o operation, that
completed with an error, should be retried.
The call to the FILEERROR procedure is:
example
IF FILEERROR(fnum) THEN •• retry
3-48
FILEERROR Procedure
3-49
FILEERROR Procedure
notAopen := notAcreated := l;
WHILE notAopen DO ! open the file.
BEGIN
CALL OPEN(fname, fnum, 0);
IF < THEN
BEGIN
CALL FILEINFO(fnum,error);
IF error = nofile THEN ! file does not exist. create it
WHILE notAcreated DO
BEGIN
CALL CREATE(fname, •• ) ;
IF < THEN ! creation failure
BEGIN
IF NOT FILEERROR(-1) THEN CALL ABEND;
END
ELSE notAcreated := O;
END
ELSE
BEGIN
IF NOT FILEERROR (fnum) THEN CALL ABEND;
END;
END
ELSE notAopen := O;
END; ! open the file.
3-50
FILEINFO Procedure
FILEINFO
where
<file number>, INT:value, passed
identifies the file whose characteristics are to be
returned.
3-51
FILEINFO Procedure
3-52
FILEINFO Procedure
3-53
FILEINFO Procedure
example
CALL FILEINFO infile, errAnum ) ;
3-54
FILEINFO Procedure
Considerations
• Error Handling
The error number of a preceding AWAITIO on any file or waited OPEN
that failed can be obtained by passing a -1 in the <file number>
parameter. The error number is returned in <error>.
3-55
FILERECINFO Procedure
FILERECINFO
3-56
FILERECINFO Procedure
3-57
FILERECINFO Procedure
example
CALL FILERECINFO ( infile,,,,,,,, ftype);
3-58
FNAMECOLLAPSE Procedure
FNAMECOLLAPSE
The FNAMECOLLAPSE procedure converts a file name from its internal
form to its external form. The system number of a network file
name is converted to the corresponding system name.
The call to the FNAMECOLLAPSE procedure is:
example
length := FNAMECOLLAPSE( internal, external ) ;
3-59
FNAMECOLLAPSE Procedure
Considerations
• Passing Invalid File Names
It is the responsibility of the program calling FNAMECOLLAPSE to
pass a valid file name in <internal name>. Invalid file names
cause unpredictable results.
3-60
FNAMECOMPARE Procedure (all files)
FNAMECOMPARE
The FNAMECOMPARE procedure compares two file names within a local or
network environment to determine whether these file names refer to the
same file or device. For example, one name may be a logical system
name or a device number while the other reference is a symbolic name.
The file names compared must be in the standard twelve-word internal
format that is returned by FNAMEEXPAND.
The call to the FNAMECOMPARE procedure is:
3-61
FNAMECOMPARE Procedure (all files)
Considerations
3-62
FNAMECOMPARE Procedure (all files)
3-63
FNAMECOMPARE Procedure (all files)
FNAMECOMPARE can also verify the specified file names, as shown in the
following example:
assume all variables and procedures have been
properly defined and initialized elsewhere
also assume LITERAL legal = O;
IF FNAMEEXPAND ( externalAname, internalAname, defaultAnames ) THEN
BEGIN
! something reasonable was entered.
IF FNAMECOMPARE ( internalAname, internalAname = legal THEN
! it may not exist, but looks okay.
BEGIN
normal processing.
END
ELSE
! the format is not legal.
BEGIN
! error processing.
END;
END;
3-64
FNAMEEXPAND Procedure (all files)
FNAMEEXPAND
The FNAMEEXPAND procedure is used to expand a partial file name from
the compacted external form to the standard twelve-word internal form
usable by file management procedures.
The call to the FNAMEEXPAND procedure is:
3-65
FNAMEEXPAND Procedure (all files)
example
length := FNAMEEXPAND(inname,outname,pmsg[l]);
3-66
FNAMEEXPAND Procedure (all files)
3-67
FNAMEEXPAND Procedure (all files)
SCAN ext"'name WHII,E " " -> @p; ! skip leading blanks.
@p := FNAMEEXPAND(p, infile, defaults) + @p;
on the completion of FNAMEEXPAND, <inf ile> contains
11
$voll svoll f ilea "
which is suitable for passing to the file management CREATE,
OPEN, RENAME, and PURGE procedures as well as the process
control NEWPROCESS procedure.
"p" is incremented by the number of characters in the external
file name.
3-68
FNAMEEXPAND Procedure (all files)
FNAMEEXPAND converts local file names to local names, and network file
names to network names. Network file names are described under
"File Names".
When network file names are involved, in addition to expanding the
local part of the name using the defaults, FNAMEEXPAND converts the
system name to the appropriate system number.
Example:
Suppose that system \NEWYORK is assigned system number 4. Then
the external file name "\NEWYORK.$DATA.SUB.MYFILE" is converted
by FNAMEEXPAND to
.\<%4>DATA SUB MYFILE
where "<%4>" denotes octal 4 in the second byte.
3-69
GETDEVNAME Procedure
GETDEVNAME
The GETDEVNAME procedure is used to obtain the name associated with a
logical device number. GETDEVNAME returns, from the Logical Device
Table (LDT) , the name of a designated logical device if such a device
exists or the name of the next higher (numerically) logical device if
the designated logical device does not exist. A status word is
returned from GETDEVNAME that indicates whether or not the designated
device exists or if higher entry exists in the LDT. By repeatedly
calling GETDEVNAME and supplying successively higher logical device
numbers, the names of all system device can be obtained.
The call to the GETDEVNAME procedure is:
where
<status>, INT returned
indicates the outcome of the call. Where
0 = successful, the name of the designated logical
device is returned in <device name>
1 = the designated logical device does not exist. The
logical device number of the next higher device is
returned in <logical device no>; the name of that
device is returned in <device name>
2 = "end-of-LDT", there is no logical device equal-to or
or greater than <logical device no>
3 = unable to get name for demaountable disc
4 = the system specified could not be accessed
99 ~
parameter error
3-70
GETDEVNAME Procedure
example
! get the names of all logical devices.
ldev := O;
WHILE NOT GETDEVNAME ( ldev , devname DO
BEGIN
CALL print ( ldev , devname ) ;
ldev :~ ldev + l;
END;
Considerations
3-71
KEYPOSITION Procedure
KEYPOSITION
The KEYPOSITION procedure is used to position by primary key within
key-sequenced files, and by alternate key within key-sequenced,
relative and entry-sequenced files.
KEYPOSITION sets the current position, access path, and positioning
mode for the specified file. The current position, access path,
and positioning mode define a subset of the file for subsequent
access.
The calling application process is not suspended because of a call to
KEYPOSITION.
A call to the KEYPOSITION procedure will be rejected with an error
indication if there are any outstanding "no-wait" operations pending
on the specified file.
The call to the KEYPOSITION procedure is:
where
<file number>, INT:value, passed
identifies the file to be positioned.
3-72
KEYPOSITION Procedure
3-73
KEYPOSITION Procedure
example
key ~:=~ "DOE,JOHN";
CALL KEYPOSITION ( infile, key,, 8 ) ;
IF< THEN.... error occurred
3-74
KEYPOSITION Procedure
Considerations
• Positioning Exact
If an exact KEYPOSITION is performed and a <compare length> is
specified that is less than that specified when the file was
created, <compare length> must match the variable key length
specified when the record was entered into the file. Otherwise a
subsequent call to READ, READUPDATE, WRITEUPDATE, etc., is
rejected.
3-75
KEYPOSITION Procedure
3-76
KEYPOSITION Procedure
3-77
LOCKFILE Procedure (file locking)
LOCKFILE
The LOCKFILE procedure is used to temporarily exclude other accesses
to a file.
If the file is currently unlocked or is locked by the caller when
LOCKFILE is called, the file becomes locked and the caller continues
executing.
Two "locking" modes are available:
• With the default mode, if the file is already locked when the call
to LOCKFILE is made, the process requesting the lock is suspended
and queued in a "locking" queue behind any other processes also
requesting to lock or read the file. When the file becomes
unlocked, the process at the head of the locking queue is granted
access to the file. If the process at the head of the locking
queue is req~esting a lock, it is granted the lock and _resumes
execution. If the process at the head of the locking queue is
requesting a read, the read operation continues to completion.
• With the alternate mode, if the file is already locked when the
call to LOCKFILE is made, the lock request is rejected and the call
to LOCKFILE completes immediately with a "file is locked" error
indication (<error> = 73). The alternate locking mode is
established by calling SETMODE and specifying function 4, set lock
mode.
If the LOCKFILE procedure is being used to initiate an operation on a
file opened with "no-wait i/o" specified, the operation must be
completed with a corresponding call to the AWAITIO procedure. Note
that process suspension due to a queued lock occurs when AWAITIO is
called and the alternate locking mode error "file is locked" is
returned by AWAITIO (if the file was already locked).
The call to the LOCKFILE procedure is:
where
<file number>, INT:value, passed
identifies the file to be locked.
3-78
LOCKFILE Procedure (file locking)
example
CALL LOCKFILE { f ile~num ) ;
IF< THEN ••••• ; error
Considerations
3-79
LOCKFILE Procedure (file locking)
3-80
LOCKFILE Procedure (file locking)
3-81
LOCKREC Procedure (record locking)
LOCK REC
The LOCKREC procedure is used to temporarily exclude other accesses to
the record at the current position. For key-sequenced, relative, and
entry-sequenced files, the current position is the record with a key
value that matches the current key value exactly. For unstructured
files, the current position is the record identified by the
current-record pointer.
If the record is either unlocked or is currently locked by the caller
when LOCKREC is called, the record becomes locked and the caller
continues executing.
Two "locking" modes are available:
• With the default mode, if the record is already locked when the
call to LOCKREC is made, the process requesting the lock is
suspended and queued in a "locking" queue behind any other
processes also requesting to lock or read the record. When the
record becomes unlocked, the process at the head of the locking
queue is granted access to the record. If the process at the head
of the locking queue is requesting a lock, it is granted the lock
and resumes execution. If the process at the head of the locking
queue is requesting a read, the read operation continues to
completion.
• With the alternate mode, if the record is already locked when the
call to LOCKREC is made, the lock request is rejected and the call
to LOCKREC completes immediately with a "record is locked" error
indication (<error>= 73). The alternate locking mode is specified
via an option to the SETMODE procedure.
Note: A call to LOCKFILE is equivalent to locking all records in a
file. Therefore, a file lock is queued behind any pending
record locks. Conversely, a record lock is queued behind any
pending file locks.
If the LOCKREC procedure is being used to initiate an operation with
a file opened with "no-wait i/o" specified, the operation must be
completed with a corresponding call to the AWAITIO procedure.
Additionally, the process suspension due to a queued lock occurs when
AWAITIO is called.
The syntax for the LOCKREC procedure is shown on the following page.
3-82
LOCKREC Procedure (record locking)
example
CALL LOCKREC ( f ileAnum, lockAtag ) i
IF< THEN ••••• ; ! error
General Considerations
3-83
LOCKREC Procedure (record locking)
3-84
LOCKREC Procedure (record locking)
3-85
NEXTFILENAME Procedure
NEXTFILENAME
where
<error>, INT returned
is a file management error number indicating the outcome of
the call. Common error number returns are:
0 = no error, next file name in alphabetical sequence is
returned in <file name>
l = end-of-file: there is no file in alphabetical
sequence following the file name supplied in <file
name>
13 = illegal filename specification
3-86
NEXTFILENAME Procedure
on the call, is passed the file name from which search for
the next file name begins. <file name> on the initial call
can be one of the following forms:
<file name[O:ll]> = $<volume name><blank fill>
or \<system number><volume name><blank fill>
The form shown above is used to obtain the name of the
first file on $<volume name>.
<file name[0:3]> =$<volume name><blank fill>
or \<system number><volume name><blank fill>
<file name[4:11]> = <subvol name><blank fill>
The form shown above is used to obtain the name of the
first file in <subvol name> on $<volume name>.
<file name[0:3]> =$<volume name><blank fill>
or \<system number><volume name><blank fill>
<file name[4:7]> = <subvol name><blank fill>
<file name[8:11]> =<disc file name><blank fill>
The form is used to return the name of the next file in
alphabetic sequence.
On the return, <file name> is returned the next file name in
alphabetical sequence, if any.
example
fname ' : =' [ "$SYSTEM ", 8 * (" "] ] ;
WHILE NOT (error := NEXTFILENAME ( fname ) ) DO
BEGIN
END;
3-87
OPEN Procedure
OPEN
The OPEN procedure establishes a communication path between an
application process and a file. When OPEN completes, a "file number"
is returned to the application process. The file number identifies
this access to the file in subsequent file management calls.
The call to the OPEN procedure is:
3-88
OPEN Procedure
3-89
OPEN Procedure
I
I
I
~1
3-90
OPEN Procedure
The next two parameters are supplied only if the open is by the
backup process of a process-pair, the file is currently open by
the primary process, and the Checkpointing Facility (described in
the GUARDIAN Operating System Programming Manual) is not used.
3-91
OPEN Procedure
General Considerations
3-92
OPEN Procedure
3-93
OPEN Procedure
super id = 7, ~ ~
7, 7, 7, 7, = super id
owner = 2,
......
2, 2, 2, 2, = owner
group mem = 1, ~
,. 1, 1, 1, 1, = g:coup
or ~
or or or or member
other = 0 0 0 0 0 = any
<access mode>
read/write
I*-*I
read-only I
write-only I
* execute
* purge
* cannot be specified via OPEN
If the accessor,s security level is equal-to or higher-than the
file,s security level for the requested access mode, then the
accessor passes the security check
Figure 3-2. File Security Checking
3-94
OPEN Procedure
OPEN
ATTEMPTED FILE CURRENTLY OPEN WITH
WITH
Exclusion s s s E E E p p p
Mode c
L
0 R R w R R w R R w
Access s I I I
Mode E w w w
D
s R/W y y y y
s R y y y y y y y
s w y y y y
E R/W y
~
E R y ALWAYS FAILS
~
E w y
p R/W y y
p R y y y
p w y y
Notes:
• BACKUP opens the file currently being backed-up
with R, P.
• BACKUP with "OPEN" option specified opens the file
with R, S.
• RESTORE opens the file currently being restored
with R/W, E.
• When a program file is running it is opened with
the equivalent to R, P.
3-95
OPEN Procedure
• Partitioned Files
For partitioned files, there is a separate pair of FCB~s for each
partition of the file. There is one ACB per accessor (as for
single volume files) , but this ACB requires more main memory since
it contains the information necessary to access all of the
partitions, including the location and partial key value for each
partition.
3-96
OPEN Procedure
3-97
POSITION Procedure (relative, entry-sequenced, and unstructured files)
POSITION
The POSITION procedure is used to position by primary key within
relative and entry-sequenced files. For unstructured files, the
POSITION procedure specifies a new current position.
For relative and unstructured files, POSITION sets the current
position, access path, and positioning mode for the specified file.
The current position, access path, and positioning mode define a
subset of the file for subsequent access.
The POSITION procedure is not used with key-sequenced files.
The caller is not suspended because of a call to POSITION.
A call to the POSITION procedure will be rejected with an error
indication if there are any outstanding "no-wait" operations pending
on the specified file.
The call to the POSITION procedure is:
3-98
POSITION Procedure (relative, entry-sequenced, and unstructured filei)
example
3-99
POSITION Procedure (relative, entry-sequenced, and unstructured files)
3-100
PURGE Procedure
PURGE
The PURGE procedure is used to delete a closed disc file. When PURGE
is executed the disc file name is deleted from the volume~s directory
and any space previously allocated to that file is made available to
other files.
where
3-101
PURGE Procedure
example
CALL PURGE ( oldf ilename ) ;
IF< THEN .•• PURGE failed.
Considerations
• Error Recovery
If PURGE fails, the reason for the failure can be determined by
calling FILEINFO, passing -1 as the <file number> parameter.
3-102
READ Procedure (sequential processing)
READ
The READ procedure is used to perform sequential reading of a disc
file. For key-sequenced, relative, and entry-sequenced files, the
READ procedure reads a subset of records in the file. (A subset of
records is defined by an access path, positioning mode, and compare
length.) For unstructured files, the READ procedure reads records
sequentially on the basis of a beginning relative byte address and the
lengths of the records read. (After each READ, the current-record
pointer is set to the previous next-record pointer and the next-record
pointer is set to the previous next-record pointer plus the number of
bytes read.)
For key-sequenced, relative, and entry-sequenced files, the first call
to READ following a position returns the first record of the subset
(i.e., the record at the current position). Subsequent calls to READ
without intermediate positioning return successive records in the
subset. Following each READ of the subset's records, the position of
the record just read becomes the file's current position. An attempt
to read a record following the last record in a subset returns an
end-of-file indication.
If the READ procedure is being used to initiate an operation with a
file opened with "no-wait i/o" specified, the operation must be
completed with a corresponding call to the AWAITIO procedure.
The call to the READ procedure is:
where
<file number>, INT:value, passed
identifies the file to be read.
3-103
READ Procedure (sequential processing)
example
CALL REJl..D inbuffer, 72 j;
IF < THEN READ failed.
General Considerations
3-104
READ Procedure (sequential processing)
3-105
READ Procedure (sequential processing)
• Unstructured READS
For a read from an unstructured disc file, data transfer begins
at the position indicated by the next-record pointer.
3-106
READ Procedure (sequential processing)
3-107
READLOCK Procedure (sequential processing, record locking)
READ LOCK
The READLOCK procedure is used to perform sequential locking and
reading of records in a disc file. For key-sequenced, relative, and
entry-sequenced files, a subset of the file (defined by the current
access path, positioning mode, and compare length) is locked and read
with successive calls to READLOCK. For unstructured files, the
relative byte address (rba) of the record returned by the READLOCK
procedure is locked before the record data is transferred.
For key-sequenced, relative, and entry-sequenced files, the first call
to READLOCK following a position (or OPEN} first locks and then
returns the first record of the subset. Subsequent calls to READLOCK
without intermediate positioning, lock, then return successive records
in the subset. Following each read of the subset~s records, the
position of the record just read becomes the file~s current position.
An attempt to read a record following the last record in a subset
returns an end-of-file indication.
If the READLOCK procedure is being used to initiate an operation with
a file opened with "no-wait i/o" specified, the operation must be
completed with a corresponding call to the AWAITIO procedure.
The call to the READLOCK procedure is:
-I
3-108
READLOCK Procedure (sequential processing, record locking)
example
CALL READLOCK ( filenum, inbuffer, 72, numAread ) ;
IF< THEN •••• READLOCK failed.
Considerations
3-109
READLOCK Procedure (sequential processing, record locking)
3-110
READUPDATE Procedure (random processing)
READUPDATE
3-111
READUPDATE Procedure (random processing)
example
CALL READUPDATE ( infile, inbuffer, 72 ) ;
IF< THEN .•.. READUPDATE failed
General Considerations
3-112
READUPDATE Procedure (random processing)
3-113
READUPDATE Procedure (random processing)
unchanged.
~ Determination of <count
unchanged.
3-114
READUPDATELOCK Procedure (random processing, record locking)
READUPDATELOCK
3-115
READUPDATELOCK Procedure (random processing, record locking)
example
Considerations
3-116
REFRESH Procedure
REFRESH
where
$<volume name>, INT:ref, passed
specifies a volume whose associated FCB~s should be written
to disc. $<volume name> can be specified as a full
twelve-word <file name>; <file name[4:11]> is ignored.
If omitted, all FCB~s for all volumes are written to their
respective discs.
example
CALL REFRESH;
Consideration
• Calling REFRESH without Specifying <volume name>
When REFRESH is called without a <volume name>, the error returned
is always zero (CCE).
3-117
RENAME Procedure
RENAME
The RENAME procedure is used to change the name of an open disc file.
If the file is temporary, assigning a new name causes the file to be
made permanent.
where
example
3-118
RENAME Procedure
Considerations
3-119
REPOSITION Procedure
REPOSITION
The REPOSITION procedure is used to position a disc file to a "saved"
position (the positioning information having been saved by a calling
the SAVEPOSITION procedure) • The REPOSITION procedure passes the
positioning block obtained via SAVEPOSITION back to the file system.
Following a call to the REPOSITION, the disc file is positioned to the
point where it was when SAVEPOSITION was called.
A call to the REPOSITION procedure will be rejected with an error
indication if there are any outstanding "no-wait" operations pending
on the specified file.
The call to the REPOSITION procedure is:
example
CALL REPOSITION ( f ileAnum, positionAblock ) ;
IF< THEN ••••• ; error
~I
3-120
SAVEPOSITION Procedure
SAVEPOSITION
3-121
SAVEPOSITION Procedure
example
CALL SAVEPOSITION ( f ileAnurn, positionAblock ) ;
IF< THEN ••••• ; error
3-122
SETMODE Procedure
SETMODE
The SETMODE procedure is used to set device-dependent functions.
A call to the SETMODE procedure will be rejected with an error
indication if there are any outstanding "no-wait" operations pending
on the specified file.
The call to the SETMODE procedure is:
NOTE
SETMODE Function Table follows SETMODENOWAIT description.
3-123
SETMODE Procedure
examples
CALL SETMODE ( filenum, 3, 1 ) ; disc verify write, on.
IF> THEN ••• not a disc.
CALL SETMODE ( termfnum, 1,,, sec); return transfer mode.
IF< THEN •.•
Considerations
• SETMODE Defaults
The SETMODE settings designated as being "default" are the values
that apply when a file is opened (not if a particular <function> is
omitted when SETMODE is called).
3-124
SETMODENOWAIT Procedure
SETMODENOWAIT
The SETMODENOWAIT procedure is used to set device-dependent functions
in a no-wait manner, on no-wait files.
When the SETMODENOWAIT procedure is used to initiate an operation
with a file open with "no-wait" specified, the operation must be
completed with a corresponding call to the AWAITIO procedure. The
<count transferred> parameter to AWAITIO has no meaning for
SETMODENOWAIT completions. The <buffer address> parameter is set to
the address of <last params> parameter of SETMODENOWAIT.
The call to the SETMODENOWAIT procedure is:
3-125
SETMODENOWAIT Procedure
Considerations
e SETMODENOWAIT Completion
AWAITIO must be used to complete the call when <file number> is
opened with a wait-depth greater than 0. For files with a
wait-depth equal to zero, a call to SETMODENOWAIT is a waited
operation and performs just as a call to SETMODE.
3-126
SETMODE AND SETMODENOWAIT Functions
<function>
<parameter l>
3-127
SETMODE AND SETMODENOWAIT Functions
3-128
UNLOCKFILE Procedure (file locking)
UNLOCKFILE
The UNLOCKFILE procedure is used to unlock a disc file and any records
in that file that are currently locked by the caller. Unlocking a
file allows other processes to access the file. If any processes are
queued in the locking queue for the file, the process at the head of
the locking queue is granted access and is removed from the queue (the
next read or lock request moves to the head of the queue) . If the
process granted access is waiting to lock the file, it is granted the
lock (which excludes other process from accessing the file) and
resumes processing. If the process granted access is waiting to read
the file, its read is processed by the file system.
where
example
3-129
UNLOCKREC Procedure (record locking)
UNLOCK REC
where
example
3-130
UNLOCKREC Procedure (record locking)
Considerations
unchanged.
unchanged.
3-131
WRITE Procedure (insert)
WRITE
The WRITE operation is used to insert a new record into a file in the
position designated by the file~s primary key:
where
3-132
WRITE Procedure (insert)
example
General Considerations
3-133
WRITE Procedure (insert)
If a call to WRITE is made and the file is locked but not locked
through the <file number> supplied in the call, the call is
rejected with a "file is locked" error indication (<error> = 73).
3-134
WRITE Procedure (insert)
• Unstructured WRITES
3-135
WRITEUPDATE Procedure (random replace and delete)
WRITEUPDATE
The WRITEUPDATE procedure is used for random and sequential processing
•f records in a disc file. WRITEUPDATE has two functions:
• Alter the contents of the record at the current position.
• Delete the record at the current position in a key-sequenced or
relative file.
For key-sequenced, relative, and entry-sequenced files, random
processing implies that a designated record must exist. This means
that positioning for WRITEUPDDATE is always to the record described by
the exact value of the current key and current key specifier. If such
a record does not exist, the call to WRITEUPDATE is rejected with a
"record does not exist" error (<error> = 11).
For unstructured files, data is written in the position indicated by
the current-record pointer. A call to WRITEUPDATE for an unstructured
file typically follows a call to POSITION, READ, or READUPDATE
procedures. The current-record and next-record pointers are not
changed by a call to WRITEUPDATE.
If the WRITEUPDATE. procedure is being used to initiate an operation
with a file opened with "no-wait i/o" specified, the operation must
be completed with a corresponding call to the AWAITIO procedure.
The call to the WRITEUPDATE procedure is:
3-136
WRITEUPDATE Procedure (random replace and delete)
example
General Considerations
3-137
WRITEUPDATE Procedure (random replace and delete}
3-138
WRITEUPDATE Procedure (random replace and delete)
unchanged.
unchanged.
3-139
WRITEUPDATEUNLOCK Procedure (random processing, record locking)
WRITEUPDATEUNLOCK
-1
3-140
WRITEUPDATEUNLOCK Procedure (random processing, record locking)
example
CALL WRITEUPDATEUNLOCK outfile, outbuffer, 72, numAwritten ) ;
IF= THEN ...• ! successful.
3-141
WRITEUPDATEUNLOCK Procedure (random processing, record locking}
Considerations
3-142
SECTION 4
• File Open
• Access Examples
4-1
ENSCRIBE FILE ACCESS
FILE OPEN
• If the file is not partitioned and does not have alternate keys,
there are no special considerations.
• If the file has one or more alternate keys, all alternate key files
are automatically opened when the primary file is opened. If an
alternate key file cannot be opened, a CCG (warning indication) is
returned from OPEN. The FILEINFO Procedure can then be called to
obtain the file management error number and the FILERECINFO
Procedure can be called to determine which key. The file is still
accessible. However, an attempt to use an access path associated
with an alternate key file that did not open results in an error
46, invalid key specified.
• Sequential Processing
4-2
ENSCRIBE FILE ACCESS
• Random Processing
• Insert
4-3
ENSCRIBE FILE ACCESS
• Delete
• Alternate Keys
Alternate key fields are fixed length but need not be written when
inserting or updating a record. If any part of a given alternate
key field is present when inserting or updating a record, the
entire field must be present.
• Current Position
4-4
ENSCRIBE FILE ACCESS
A f ile,s current primary key value is taken from the primary key
associated with the last
operation.
• End-Of-File Pointer
4-5
ENSCRIBE FILE ACCESS
A process can optionally specify (at file open time) that an array in
the process~s data area be used by the file system for record
deblocking. The advantage to using this option is that instead of
requesting each record from an i/o process (which results in an
interprocess message being sent, an environment switch, and, possibly
waiting to obtain space from system data space), an entire block is
returned from the i/o process and stored in the process~s data area.
Once a block is in the application process~s data area, subsequent
accesses to records within that block require no disc accesses and no
environment changes.
Example:
ELSE
IF > THEN
BEGIN ! open successful.
CALL FILEINFO ( fnum , error ) ;
IF error = 5 THEN ! sequential buffer request rejected.
END
open successful.
4-6
ENSCRIBE FILE ACCESS
eof : = 0;
WHILE NOT eof DO
BEGIN
CALL READ ( fnum , buffer , reclen , countread ) ;
IF > THEN eof := 1
ELSE
END;
4-7
ENSCRIBE FILE ACCESS
If the application program does not want the temporary file purged at
close time, the temporary file can be made permanent by use of the
file management RENAME procedure:
4-8
ENSCRIBE FILE ACCESS
Three file pointers are associated with each open unstructured disc
file:
4-9
ENSCRIBE FILE ACCESS
4-10
ENSCRIBE FILE ACCESS
CREATE
OPEN (first)
OPEN (any)
READ
WRITE
READUPDATE
WRITEUPDATE
4-11
ENSCRIBE FILE ACCESS
POSITION
CLOSE {last)
where
Sequential Access
4-12
ENSCRIBE FILE ACCESS
The following sequence of ENSCRIBE calls shows how the file pointers
are used when sequentially accessing an unstructured disc file.
Assume that these are the first operations to the file after OPEN:
4-13
ENSCRIBE FILE ACCESS
I i ! I
t
0 512
t t
1024
t
1536
t
3584
t
4096
RELATIVE BYTE ADDRESS (EOF)
4-14
ENSCRIBE FILE ACCESS
If sequential reads of 400 bytes are executed from the same file, the
results are slightly different:
file"'eof := O;
WHILE NOT f ile"'eof DO
BEGIN
CALL READ ( file"'a, buffer, 400, num"'read, •• ) ;
IF > THEN file"'eof := 1
ELSE
IF = THEN
BEGIN
the data is processed.
END
ELSE •.. error.
END;
In this case, reads one through ten each transfer 400 bytes into
"buffer", return "num"'read" = 400, and set the condition code
indicator to CCE (operation successful) •
Read eleven transfers 96 bytes into "buffer", returns "num"'read"
= 96, and sets the condition code indicator to CCE.
The next read fails and sets the condition code indicator to
CCG. This situation is illustrated in Figure 4-2 below.
t t t t t t t
0 400 800 1200 3600 4000 4096
(EOF)
RELATIVE BYTE ADDRESS
4-15
ENSCRIBE FILE ACCESS
Random Access
Appending to End-of-File
4-16
ENSCRIBE FILE ACCESS
Then a subsequent WRITE appends 512 bytes to the end of the file:
The file system transfers 512 bytes from "buffer" to the current
end of file location (131,072). The next-record and end-of-file
pointers now point to'relative byte 131,584; the current-record
pointer points to relative byte 131,072; the next-record pointer
still contains -lD so that a subsequent write also appends to
end-of-file.
r OPEN
READ 1
READ 2,
WRITEUPDATE READ 3
POSITION (819200)
lRbADUPDATE,
WR ITEUPDATE
/~
~POSITION (-ID)
WRITE
~
4-17
ENSCRIBE FILE ACCESS
Disc Sectors
This call involves only one disc operation: the 512 bytes of
"array" are transferred to the disc sector
The following example illustrates file system action for a write that
crosses sector boundaries. A WRITE of 200 bytes is performed starting
at relative location 400:
CALL WRITE ( fileAa, array, 200 } :
4-18
ENSCRIBE FILE ACCESS
SECTOR BOUNDARY
SECTOR 0 (512 BYTES) + SECTOR 1 (512 BYTES)
t t t t t
0 400 512 600 1024
RELATIVE BYTE ADDRESS
Note that although full sector transfers are most efficient for the
file system to perform, they are not necessarily the most efficient
for a particular application. The application program can block data
in its own memory area to accumulate a record of 512 bytes.
4-19
ENSCRIBE FILE ACCESS
RESIDENT
BUFFER IN 110
APPLICATION ~ BUFFER
PROGRAM
I I
DATA
LJ
IN SAME PROCESSOR MODULE IN SAME PROCESSOR MODULE
4-20
ENSCRIBE FILE ACCESS
For example:
buffer ':=' data FOR writeAcount; ! move data into resident buffer.
CALL WRITE ( fnum, buffer, writeAcount ) ; ! write it.
IF< THEN ... ; ! error.
4-21
ENSCRIBE FILE ACCESS
4-22
ENSCRIBE FILE ACCESS
File Locking
Record Locking
4-23
ENSCRIBE FILE ACCESS
Locking Modes
There are two "locking" modes available. The locking mode determines
the action taken if the file/record is already locked when a request
is made to lock it.
• Default Mode
• Alternate Mode
For a file having one or more pending lock requests, there is a queue
of file lock requests. When a request is made to read from a locked
file, but the file is not locked through the <file number> supplied in
the call, the read request is queued with the file lock requests.
When the current lock is cleared (by means of a call to the UNLOCKFILE
procedure) , the request at the head of the file locking queue is
granted. If the request is a lock request, the lock is granted and
the request continues processing; if the request is a read request,
the request is completed.
4-24
ENSCRIBE FILE ACCESS
Similarly, for a record having more one or more pending lock requests,
there is a queue of record lock requests. When a request is made to
read from a locked record, but the record is not locked through the
<file number> supplied in the call, the read request is queued with
the record lock requests. When the current lock is cleared, the
request at the head of the locking queue for the record is granted.
If the request is a lock request, the lock is granted and the request
continues processing; if the request is a read request, the request is
completed.
LOCKREC: $A.B.C,rec 1
(lock granted)
LOCKFILE: $A.B.C
(lock queued)
LOCKREC: $A.B.C,rec 12
(lock queued)
LOCKREC: $A.B.C,rec 12
(lock granted)
4-25
ENSCRIBE FILE ACCESS
Deadlock
One problem that may occur when multiple processes require multiple
record or file locks is a "deadlock" condition. An example of
deadlock is
Process A Process B
LOCKREC: record 1 LOCKREC: record 2
4-26
ENSCRIBE FILE ACCESS
Purge Data
For example, to purge all data from a file, the following call to
CONTROL could be made:
4-27
ENSCRIBE FILE ACCESS
Verify Write
Ref re sh
4-28
ENSCRIBE FILE ACCESS
4-29
ENSCRIBE FILE ACCESS
END
ELSE GOTO loop;
~
r
I
t
{ t DATA
t t
{
ti
i
L 1 I ?
1
0
I
400
I
800
I
1200
t
1600 ,l I2048
Note that <error> = 43 can also occur when allocating extents via the
CONTROL procedure, allocate/deallocate operation (<operation> = 21).
4-30
ENSCRIBE FILE ACCESS
4-31
ENSCRIBE FILE ACCESS
<operation>
<parameter> = none
20 = disc, purge data (write access is required)
<parameter> = none
l:<total extents>
= total number of extents to allocate
for entry-sequenced, relative and
unstructured files
where
<function>
4-32
ENSCRIBE FILE ACCESS
<function>
4-33
ENSCRIBE FILE ACCESS
The error number associated with an unopen file or a file open failure
can be obtained by passing the <file number> as -1 to the FILEINFO
procedure:
error ca~egory
4-34
ENSCRIBE FILE ACCESS
Many of the file management errors imply that invalid parameters were
supplied to the file management procedures or that illegal operations
were attempted. These could be considered programming errors. Other
types of errors imply that the system is not being operated properly.
And other types are simply informational messages informing the
application about a particular device oriented problem.
Errors occuring during disc file access can be separated into the
following categories:
• Path Errors
• Data Errors
• Device Operation Error
• Failure of Primary Application Process
Path Errors
Data Errors
These are error numbers 50 through 59, 120 through 139, and 190
through 199. The file system automatically retries operations
associated with this type of error. Therefore, if one of these errors
is returned, all or part of the file can be considered invalid. For
errors 50 through 59, the file may be recoverable through use of the
COPY command with the RECOVER option of the Peripheral Utility Program
(PUP). Error 120 (data parity error) causes the associated track to
be flagged by the file system as bad. A bad track can be assigned to
a spare track through use of the SPARE command of PUP.
4-35
ENSCRIBE FILE ACCESS
These are error numbers 60 through 69 and 103. None of these errors
are retried by the file system. Errors 60 through 69 indicate that
the device has been deliberately been made inaccessible and,
therefore, the associated operation probably should not be retried.
Error 103 indicates that the entire system has experienced a power
failure and that the disc is in the process of becoming ready.
Therefore, an operation associated with an error 103 should be retried
periodically.
This section groups of the file system errors by functional class and
provides a description of each error class.
4-36
ENSCRIBE FILE ACCESS
Errors 54-57 also imply that a disc hardware problem exists (file
system retried the associated operation a number of times before
reporting the error) •
4-37
ENSCRIBE FILE ACCESS
Errors 160-178 occur only when using the ENVOY Data Communications
Manager software. The errors are described in detail in the
~NVOY Byte-Control Protocols Manual, P/N 82018.
200-201: Operation never got started; medium movement did not take
place.
200,230, At least one path, and possibly 231: both paths, are
operable.
The table in Appendix D lists all of the file management errors and
gives a brief explanation of each error.
4-38
ENSCRIBE FILE ACCESS
Error Recovery
• The type of device (e.g., disc, magnetic tape, line printer, etc.)
For disc files, if a file is opened with a <sync depth> greater than
er equal to 1, all recoverable errors, including path errors, are
automatically retried by the file system.
When using "no-wait" i/o and executing more than one concurrent
operation to the same file, it is quite possible for one operation to
fail, but subsequent operations to succeed. This is illustrated as
follows:
"line one"
"line three"
("line two" is missing)
The rule of thumb is: when order is important, don't permit concurrent
operations on the same file.
4-39
ENSCRIBE FILE ACCESS
warning/error description
CAUTION
4-40
ENSCRIBE FILE ACCESS
11 record not in file (file is open}. This error can occur only
when the READUPDATE or WRITEUPDATE procedures are called. For
relative files, this error indicates that no record exists at
the designated record number; for key-sequenced files, no
record exists having the designated primary key field value;
for files having alternate keys, no record exists having the
designated key field value.
47 key not consistent with file data. This error is returned if,
for some reason (such as no disc space available), the
alternate key file cannot be updated on an insert, update, or
delete operation to the primary file
4-41
ENSCRIBE FILE ACCESS
In any case, following a CCL (and possibly a CCG) return from a file
management procedure call, the file management error number is
obtained by calling the FILEINFO procedure and the partition number of
the partition in error is obtained by calling the FILERECINFO
procedure. The volume name of the partition in error can be obtained
by examining the file's creation partition parameter array (either
programmatically or via the FUP program) .
For errors in the range of 42-45, it may be possible to alter the size
characteristics of the partition where the error occurred by using the
FUP program.
4-42
ENSCRIBE FILE ACCESS
Table 4-3. Action of Current Key, Key Specifier, and Key Length
Definitions:
CKV =<current key value>
CKS =<current key specifier>
CKL =<current key length>
CMPL =<compare length>
MODE =<pos}tioning mode>: approx = 0
generic = 1
exact = 2
primary = 0
next = flag, if true, means that the next record in
sequence is to be referenced
rip = relative file insertion pointer
present = true if parameter is supplied
keyseq = f iletype = 3
entryseq = f iletype = 2
relative = f iletype = 1
keyf ield record, specifier ) ;
4-43
ENSCRIBE FILE ACCESS
I
I
I
~1
4-44
ENSCRIBE FILE ACCESS
KEYPOSITION:
CKV := rip := <key>;
CKS := if present then <key specifier> else primary;
CKL := CMPL := if present then <compare length>
else keylength(O, CKS);
MODE := if present then <positioning mode> else approx;
next := false;
POSITION:
CKV := rip := <record specifier>;
CKS := primary;
CMPL := CKL := 4;
MODE := approx;
next := false;
READ:
position := if next then findAnext(MODE,CKS,CKV,CMPL)
else find (MODE,CKS,CKV,CMPL);
if <error> then return;
record:= file[position];
CKV := keyfield (record,CKS);
CKL := keylength(record,CKS);
next := true;
READUPDATE:
position := find(exact,CKS,CKV,CKL);
if <error> = 1 then <error> := 11; if <error> then return;
record := file[position];
WRITEUPDATE:
position := find(exact, CKS, CKV, CKL);
if <error> = 1 then <error> := 11; if <error> then return;
if <write count> = 0 then
if entryseq then begin <error> := ##; return; end;
else delete the record
else file[position] := record;
4-45
ENSCRIBE FILE ACCESS
WRITE:
if keyseq then
begin
position := insert(keyfield(record,prirnary),
keylength(record,prirnary));
if <error> then return;
file[positionl := record;
end;
if relative then
begin
if CKS then begin <error> := ##; return; end;
if rip <> -20 and rip <> -10 and next then rip := rip + l;
position := insert(rip,4);
if <error> then return;
file[position] := record;
CKV := keyfield(record,prirnary);
next := true;
end;
if entryseq then
begin
if CKS then begin <error> := ##; return; end;
position := insert(-10,4); ! end-of-file
file[position] := record;
CKV := keyfield(record,prirnary);
next := true;
end;
4-46
ENSCRIBE FILE ACCESS
ACCESS EXAMPLES
byte:
[0] [34] [134] [136] [ 144] [ 152]
i I
Primary Alternate
Key Key "RG"
STRING
.scust := @cust '<<' l; byte addressable.
FIXED(2)
• fcust := @cust; fixed addressable •
DEFINE
cust"len = 152#, customer record length.
cust"name = scust#, name field.
cust"name"len = 34#, name field length.
cust"address = scust[34]#, address field.
cust"address"len = 100#, address field length.
cust"region = scust[l36]#, region field:
NO = northern,
SO = southern,
EA = eastern,
WE = western.
cust"region"len = 2#, region field length.
cust"curbal = fcust[l7]#, current balance field.
cust"limit = fcust[l8]#; credit limit field.
4-47
ENSCRIBE FILE ACCESS
4-48
ENSCRIBE FILE ACCESS
cust"'eof := O;
WHILE NOT cust"'eof DO
BEGIN ! read loop.
CALL READ (cust"'fnum, cust, cust"'len);
IF > THEN cust"'eof := 1
ELSE
IF< THEN ••• ! error.
ELSE
BEGIN ! process the record.
END;
END; ! read loop.
Primary Key
I
v
12 EOF
4-49
ENSCRIBE FILE ACCESS
END;
END; ! read loop.
Alternate Key
"RG"
I
v
12 EOF
4-50
ENSCRIBE FILE ACCESS
custAeof := O;
WHILE NOT custAeof DO
BEGIN ! read loop.
CALL READ (custAfnum, cust, custAlen) ;
IF > THEN custAeof := 1 ! end-of-file.
ELSE
IF < THEN . • • ! error.
ELSE
BEGIN process the record.
END;
END; ! read loop.
4-51
ENSCRIBE FILE ACCESS
END;
END; ! read loop.
4-52
ENSCRIBE FILE ACCESS
cust"'eof := O;
WHILE NOT cust"'eof DO
BEGIN ! read loop.
CALL READ (cust"'fnum, cust, cust"'len) ;
IF > THEN cust"'eof := 1 ! end-of-file.
ELSE
IF < THEN • • • ! error.
ELSE
BEGIN process the record.
END;
END; ! read loop.
4 EOF
4-53
ENSCRIBE FILE ACCESS
Record to be inserted =
cust""region := "WE";
cust""curbal := O.OOF;
cust""limit := 500.00F;
4-54
ENSCRIBE FILE ACCESS
key':=' "HARTLEY";
CALL KEYPOSITION (custAfnum, key) i
IF<> THEN ..•
CALL READUPDATE (custAfnum, cust, custAlen) i
IF<> THEN •••
4-55
ENSCRIBE FILE ACCESS
key~:=~ "BROWN,C";
CALL KEYPOSITION (custAfnum, key) ;
IF<> THEN •..
CALL READUPDATE (custAfnum, cust, custAlen) ;
IF < THEN
BEGIN
CALL FILEINFO (custAfum, error) ;
IF error= 11 THEN .• ! record not found.
4-56
ENSCRIBE FILE ACCESS
The "limit" for each record having a "limit" >= 1000.00 and <= 2000.00
is raised to 2000.00.
compareAlen := O;
CALL KEYPOSITION ( custAfnum, key, , compareAlen);
! position to first record via primary key.
custAeof := O;
WHILE NOT custAeof DO
BEGIN ! read loop.
CALL READ ( custAfnum, cust, custAlen);
IF > THEN custAeof := 1
ELSE
IF< THEN ••. ! erroro
ELSE
BEGIN ! process the record.
IF custAlimit >= 1000.00F AND custAlimit <= 2000.00F THEN
BEGIN
custAlimit := 2000.00F;
CALL WRITEUPDATE ( custAfnum, cust, custAlen ) ;
IF< THEN ••. ! error.
END;
END;
END; ! read loop.
"limit"
4-57
ENSCRIBE FILE ACCESS
4-58
ENSCRIBE FILE ACCESS
END;
END;
END; ! read loop.
"curbal"
4-59
ENSCRIBE FILE ACCESS
and the current primary key value (current position) can be obtained
with either:
or
CALL FILERECINFO (fnum,,,,primaryAkey);
4-60
ENSCRIBE FILE ACCESS
eof := O;
WHILE NOT eof DO
BEGIN ! read loop.
CALL READ (fnum, buffer, len, numread);
IF > THEN eof := 1
ELSE
IF< THEN ••• ! error.
ELSE
BEGIN process the record.
END;
END; ! read loop.
END;
4-61
ENSCRIBE FILE ACCESS
END;
END;
4-62
ENSCRIBE FILE ACCESS
WHILE 1 DO
BEGIN
buffer ~:=~ data FOR (count + 1)/2;
CALL WRITE (fnum, buffer, count);
IF <> THEN • • . ! error.
END;
4-63
ENSCRIBE FILE ACCESS
An "ORDER" Record:
byte:
[0] [2] [38] [ 46] [ 54]
I I T
Primary Alternate Alternate
Key Key "NA" Key "DT"
STRING
.sorder := @order ~<<~ l; byte addressable.
DEFINE
order Alen = 54#, order record length.
A sorder[2]#, name field.
order name =
orderAnameAlen = 36#, name field length.
orderAdate = sorderhrd[38]#, date field.
orderAdateAlen = 8#; date field length.
FIXED(2)
.order Atotal := @order [23]; total field.
"total" = 0 means
order not filled.
"total" <> 0 means
order filled but not
shipped.
4-64
ENSCRIBE FILE ACCESS
byte:
[0] [2] [4] [6] [ 8] [16]
.
"orderno" "itemno" "partno" "qty" "itemtot"
..:
i i
Primary Alternate
Key Key "PN"
INT(32)
.orderdetAorditem := @orderdet; order-item field.
DEFINE
orderdetAlen = 16#, order record length.
orderdetAorderno = orderdet#, order number subfield.
orderdetAitemno = orderdet[l]#, item number subfield.
orderdetApartno = orderdet[2]#, part number field.
orderdetAqty = orderdet[3]#; quantity field.
FIXED(2)
.orderdetAitemtot := @orderdet[4]; item total field.
total = 0 means item
not available.
4-65
ENSCRIBE FILE ACCESS
An "INVENTORY" Record:
byte:
[O] [2] [ 32] [40] [42] [ 46] [ 54]
1
, "partno" "descr" I "price" "availqty" "loc" "vendor"
I NT . in v [ 0 : 2 7 ] ; inventory record.
STRING
.sinv := @inv '<<' l; byte addressable.
DEFINE
inv"len = 54#, inventory record length.
inv"partno = inv#, part number field.
inv"descr = sinv[2]#, part description field.
inv"descr"len = 30#, description field length.
inv"availqty = inv[20]#, avail. quantity field.
inv"location = sinv[42]#, location field.
inv"location"len = 4#, location field length.
inv"vendor = sinv[46]#, vendor field.
inv"vendor"len = 8#; vendor field length.
FIXED ( 2)
.inv"price := @inv[l6]; price field.
4-66
ENSCRIBE FILE ACCESS
The following example finds orders greater then one month old and
fills them:
4. For each line item (i.e., record in the generic subset), the
"inventory" file is read and updated (random processing), the line
item record is updated, and the line item is printed.
5. When all line items for the current order have been processed, the
order record is updated with the total price of the order. Then
the customer current balance is updated and the total are printed.
4-67
ENSCRIBE FILE ACCESS
compareAlen := 0;
! position to beginning of file via date field.
CALL KEYPOSITION (orderAfnum,key,"DT",compareAlen) i
orderAeof := O;
WHILE NOT orderAeof DO
BEGIN ! reading order file via date field.
CALL READ (orderAfum, order, orderAlen);
IF > OR orderAdate >= limitAdate THEN orderAeof := 1
ELSE
BEGIN ! fill order.
! read customer file.
CALL KEYPOSITION {custAfnurn, orderAname) i
CALL READUPDATE {custAfnum, cust, custAlen) ;
PRINT (order header) ;
! read order detail file for current order.
compareAlen := 2;
CALL KEYPOSITION (orderdetAfnum,orderAorderno,,
compareAlen, generic);
orderdetAeof := O;
WHILE NOT orderdetAeof DO
BEGIN
! read line item.
CALL READ (orderdetAfnum, orderdet, orderdetAlen);
IF > THEN orderdetAeof := 1
ELSE
BEGIN
CALL KEYPOSITION {invAfnum, orderdetApartno);
CALL READUPDATE {invAfnum, inv, invAlen);
! update inventory record
CALL WRITEUPDATE (invAfnum, inv, invAlen);
! update order detail record
CALL WRITEUPDATE (orderdetAfnum, orderdet,
ordetlen) ;
! print the line item
PRINT {line item)
END;
END;
! update the order file
CALL WRITEUPDATE (orderAfnum, order, orderAlen);
! update the customer file.
CALL WRITEUPDATE (custAfnum, cust, custAlen) i
PRINT {total);
END; ! of fill order.
END; ! of read order file via date field.
4-68
ENSCRIBE FILE ACCESS
0020 .
0001 23167 00000 0045.00
0020 : 0002 02010 00001 0000.00 <- not filled
0020 : 0003 12950 00000 0102.25
4-69
SECTION 5
ENSCRIBE FILE CREATION
Files on a disc must be created before being opened for access. This
section discusses the concepts necessary for choosing appropriate
parameters when creating a disc file.
Characteristics of ENSCRIBE file creation:
• An ENSCRIBE file is created through use of the Tandem-supplied FUP
program or through a programmatic call to the CREATE procedure.
The DDL compiler will optionally generate a FUP command file that
can be used to create files described by the DDL data base source
schema.
• All partitions of a multi-volume file are automatically created
when the first partition is created.
• For each structured file having one or more alternate key fields,
the user must create the associated alternate key file(s). An
alternate key file is created as a key-sequenced file.
The following topics must be considered when creating an ENSCRIBE
disc file:
• File Type
• File Code
• Extents
• Logical Records
• Blocks
• Characteristics of Key-Sequenced Files
• Characteristics of Structured Files having Alternate Keys
• Characteristics of Partitioned (Multi-Volume) Files
5-1
ENSCRIBE FILE CREATION
File Type
There are four file types:
• Key-Sequenced
• Relative
• Entry-Sequenced
• Unstructured
Key-Sequenced Files
A key-sequenced file consists of a set of variable length records.
Each record is uniquely identified among other records in a
key-sequenced file by the value of its primary key field. Records in
a key-sequenced file are logically stored in order of ascending
primary key values.
Relative Files
A relative file consists of a set of fixed length records. Each
record is uniquely identified among other records in a relative file
by a record number; a record number denotes an ordinal position in a
file. The first record in a relative file is designated by record
number zero; succeeding records are designated by ascending record
numbers in increments of one. A record occupies a position in a file
whether or not the position has been written in.
Entry-Sequenced Files
An entry-sequenced file consists of a set of variable lenqth records.
Records inserted in an entry-sequenced file are always appended to
the end-of-file and, therefore, are physically ordered by the
seqµence presented to the system.
5-2
ENSCRIBE FILE CREATION
Unstructured Files
An unstructured disc file is essentially a byte array, starting at
byte zero and continuing to the last byte of the file, marked by the
end-of-file pointer. The file system imposes no stucture on an
unstructured disc file. How data is grouped into records and where
records are located within the file is the responsibility of the
application process. Unstructured files are accessed on the basis of
a relative byte address. The current location in a file, the current
rba, is automatically incremented by the file system following a READ
or a WRITE. The application process can position to a specific
location within the file by supplying the file system an rba with the
POSITION procedure. Following a call to POSITION, the application
process can issue any other file management call (READ, WRITE,
READUPDATE, etc.).
Extents
Physical storage for a disc file is allocated by the file system in
the form of discontiguous file extents. A file extent itself is a
contiguous block of storage, starting on a sector boundary, containing
a multiple of 2,048 bytes. The file system permits a maximum of 16
file extents to be allocated to a file.
The first extent of the file is called the "primary extent." Its size
may be different from the size of extents 1-15, which are called
"secondary extents." This allows a file to be created having a large
primary extent to contain all the data to be initially placed in the
file, and smaller secondary extents so that as the file grows, a
minimum amount of disc space is allocated.
File Code
An application-defined file code can be assigned to a disc file at
creation time. The file code is typically used to categorize files by
the information they contain. File codes 100 through 999 are reserved
for use by Tandem Computers, Inc.
5-3
ENSCRIBE FILE CREATION
5-4
ENSCRIBE FILE CREATION
Logical Records
Blocks
• Block length must be a multiple of sector size {512 bytes) and can
not be greater than 4096 bytes.
5-5
ENSCRIBE FILE CREATION
• Block length must include 22 bytes for block control and 2 bytes
per record for record control. Therefore the number of records per
block is
N = (B - 22) I (R + 2)
where B is <block length> and R is <record length>. If records are
of varying lengths, then N is the average number of records per
block and R is given as the average record length.
Records may not span blocks. Therefore the block length must be at
least <record length> + 2 + 22.
For key-sequenced files, the data block size determines the maximum
record length that can be defined for the file; the record length
cannot exceed 1/2 * (<data block size> - 26).
I
count of duplicate characters.
5-6
ENSCRIBE FILE CREATION
PRIMARY KEY. For a key-sequenced file, the offset in the record where
the primary key field begins and the length of key field must be
specified.
Some considerations when choosing the offset of the primary key field:
• The primary key field can begin at any offset within a record and
can be of any length up to
$min(<record length> minus <offset>, 255)
• If data compression is to be used, then the primary key field must
be at the beginning of the record.
• If the primary key field is the trailing field in the record, the
the primary key values can be of variable lengths.
5-7
ENSCRIBE FILE CREATION
5-8
ENSCRIBE FILE CREATION
KEY OFFSET AND LENGTH. The offset in the record where the alternate
key field begins and the length of key field must be specified for
each alternate key.
Some considerations when choosing the offset of an alternate key
field:
• An alternate key field can begin at any offset in the record and
can be any length up to <record length> minus <offset>.
• Alternate key fields can overlap each other and the primary key
field of a key-sequenced file.
• Alternate key fields are fixed length but need not be written when
inserting or updating a record.
• If any part of a given alternate key field is present when
inserting or updating a record, the entire field must be present.
• If the key field is to be treated as a data type other than
STRING, the <offset> should be chosen so that the field begins on
a word boundry.
NULL VALUE. Any alternate key can be assigned a "null" value. When a
record is inserted, if each byte in such an alternate key field
contains the "null" value, the alternate key reference is not added to
the alternate key file. In the case of an update, if such an
alternate key field is changed so that it contains only bytes of the
"null" value, the alternate key reference is deleted from the
alternate key file.
If the file is read sequentially via such an alternate key, records
containing the null value will not be found. Instead, the record
returned (if any) is the next record in the access path not having the
null value in the alternate key field.
The most common "null" values are ASCII blank (%40) and binary 0.
5-9
ENSCRIBE FILE CREATION
NO AUTOMATIC UPDATE. The data base designer can designate that the
alternate key file contents for an alternate key not be automatically
updated by the system when the value of an alternate key field
changes.
Some reasons for not having automatic updating by the system are:
• Certain fields may not be referenced until a later date. Therefore,
they can be updated in a "batch" {one pass) mode more efficiently.
• A field may have multiple "null" values. In this case, the
application program must have the alternate key file open
separately. The program must determine whether or not the field
contains a "null" value. If it does not, the application program
then inserts the alternate key reference into the alternate key
file.
5-10
ENSCRIBE FILE CREATION
ALTERNATE KEY FILE(S). For each primary structured file having one or
more alternate keys, at least one corresponding alternate key file
must be created by the user. Characteristics of alternate key files
are:
• A primary file can have a separate alternate key file for each
group of one or more alternate keys. Some reasons to have separate
alternate key files are:
The alternate key file can be smaller than if many alternate key
references are in the same file. This results in less indices
being referenced to locate a given alternate key.
• The primary key length for an alternate key file containing unique
key references is
5-11
ENSCRIBE FILE CREATION: FUP PROGRAM
Typically, ENSCRIBE files are created through use of the File Utility
Program (FUP).
For creating disc files, the FUP Program is intended to be used in the
following manner:
• The user sets the creation parameters describing the file to be
created by executing one or more SET commands.
The SET command has a feature that allows the creation parameters
to be set to match those of an existing file. This is useful for
duplicating file structures.
• Once the creation parameters have the desired settings, the file is
created by executing a CREATE command. An option to the CREATE
command permits the user to override current creation parameter
setting{s).
5-12
ENSCRIBE FILE CREATION: FUP PROGRAM
Running FUP
The File Utility Program resides in a file designated
$SYSTEM.SYSTEM.FUP
Normally, it is run through use of the Command Interpreter program.
The command to run FUP is:
5-13
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
The SET Command is used to set one or more creation parameter values
for a subsequent creation. Parameter values can be specified
explicitly or can be set to match those of an existing file.
where
5-14
ENSCRIBE FILE GREATION: FUP PROGRAM: SET Command
[ NO ] PARTONLY
ODDUNSTR
[ NO ] REFRESH
[ NO ] AUDIT
example
Notes:
e LIKE
e TYPE
is used to set the file type. Legitimate values for <file type> and
their meanings are:
u or 0 = unstructured
R or 1 = relative
E or 2 = entry-sequenced
K or 3 = key-sequenced
5-15
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
• CODE
e EXT
is used to set the extent size. Legitimate values for extent sizes
and their meanings are:
e [ NO ] REFRESH
specifies that the file label is written to disc each time the
end-of-file is modified. Either FUP or the file system CREATE
call can set the REFRESH option. The setting defaults to no
refreshing.
FUP
SET LIKE <old-filename>
SET REFRESH
CREATE <new-filename>
EXIT
5-16
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
• REC
is used to set the record length. <record length> is an integer in
the ran9e of {0:4072} for relative and entry-sequence files,
{0:20351 for key-sequence files, and {0:4096} for unstructured
files. The default setting for <record length> is 80 bytes.
• BLOCK
is used to set the data block length. <data block length> is an
integer in the range of {0:4096}. The default setting for <data
block length> is 1024 bytes.
5-17
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
e KEYOFF
• ALTKEY
<key specifier>
"[<cl>]<c2>"
{-32768:65535}
5-18
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
KEYOFF
is used to set the key offset for <key specifier>. The
default setting for <key offset> is 0.
KEYL EN
is used to set the key length for <key specifier>. This must
be specified. Otherwise a subsequent creation attempt will
fail.
NULL
is used to set a null value for <key specifier>. <null value>
is an ascii character within quotation marks or an integer in
the range of {0:255}. The default setting for this
specification is "key does not have null value"
UNIQUE
is used to set "key is unique" for <key specifier>. The
default setting if this is omitted is "key is not unique".
NO UPDATE
is used to set "no automatic updating" for <key specifier>.
The default setting for this specification is "key is
automatically updated".
5-19
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
e ALTFILE
is used to set the file name of an alternate key file. This must be
specified for each different <key file number> specified in an
ALTKEY specification. The form of ALTFILE specification is
ALTFILE ( <key file number> , <file name> )
<key file number>
is an integer in the range of {0:255} specifying the alternate
key file being named
A partial <file name> is expanded using the default system, volume
and subvolume names.
e [ NO ] ALTCREATE
is used to set/clear automatic alternate key file creation. If
ALTCREATE is specified, the alternate key file(s) will be created
when the primary file is created. The default setting for this
specification is ALTCREATE.
5-20
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
5-21
ENSCRIBE FILE CREATION: FUP PROGRAM: SET Command
e [ NO ] PARTONLY
specifies whether a subsequent creation is to create all partitions
of a partitioned file ("NO PARTONLY") or a subsequent creation is to
create a single partition ("PARTONLY"). The default setting, "NO
PARTONLY", causes all partitions to be created.
If PARTONLY is specified and a PART specification is in effect, the
subsequently created file will be designated a primary partition.
Conversely, if no PART specification is in effect, the subsequently
created file will be designated a secondary partition. In either
case, the <file name> of the (primary or secondary) partition is
specified when the file is created.
5-22
ENSCRIBE FILE CREATION: FUP PROGRAM: SHOW Command
{ TYPE }
CODE
EXT
REC
BLOCK
!BLOCK
COMPRESS
DCOMPRESS
I COMPRESS
KEY LEN
KEYOFF
REFRESH
AUDIT
ODDUNSTR
5-23
ENSCRIBE FILE CREATION: FUP PROGRAM: CREATE Command
5-24
ENSCRIBE FILE CREATION: FUP PROGRAM: RESET Command
5-25
ENSCRIBE FILE CREATION: FUP PROGRAM: INFO Command
I
DETAIL
STAT [ ISTICS]
INFO [ /OUT <list file> / ] <fileset list> [, { EXTENTS
where
LI I
<f ileset list>
I
5-26
ENSCRIBE FILE CREATION: FUP PROGRAM: INFO Command
DETAIL
provides detailed information regarding file
characteristics (see "DETAIL Option Listing Format"
in the FUP section of the GUARDIAN Command Language
and Utilities Manual for details.)
STAT[ISTICS]
provides information given by the DETAIL option plus
summarized data concerning the usage of records and blocks
in ENSCRIBE file structures (see "STATISTICS Option Listing
Format" in the FUP section of the GUARDIAN Command Language
and Utilities Manual for details.)
EXTENTS
provides a listing of extent allocation by file (see
"EXTENTS" Option Listing Format in the FUP section of the
GUARDIAN Command Language and Utilities Manual for
details.)
example
INFO myfile,DETAIL
5-27
ENSCRIBE FILE CREATION: CREATE Procedure
CREATE
The CREATE procedure is used to a define new structured or
unstructured disc file. The file can be either temporary (and deleted
when closed) or permanent. If a temporary file is created, CREATE
returns a file name suitable for passing to the OPEN procedure.
The call to the CREATE procedure is:
5-28
ENSCRIBE FILE CREATION: CREATE Procedure
5-29
ENSCRIBE FILE CREATION: CREATE Procedure
5-30
ENSCRIBE FILE CREATION: CREATE Procedure
example
CALL CREATE(filename,5,0);
IF< THEN ••. CREATE failed.
Considerations
5-31
ENSCRIBE FILE CREATION: CREATE Procedure
• Error Handling
If the CREATE fails (i.e., condition code other than CCE returned),
the reason for the failure can be determined by calling the
FILEINFO procedure and passing -1 as the <file number> parameter.
• File Security
The file is created with the default security associated with
the process creator's access id. Security can be changed by
opening the file and calling SETMODE or SETMODENOWAIT.
5-32
ENSCRIBE FILE CREATION: CREATE Procedure
word:
[0] <key length>
[l] <key offset>
[2] <index block length>
where
<key length>, INT,
is the length, in bytes, of the record~s primary key field
<key offset>, INT,
is the number of bytes from the beginning of the record where
the primary key field starts.
<index block length>, INT,
5-33
ENSCRIBE FILE CREATION: CREATE Procedure
0 8
KEY DESCRIPTION
FOR
ALTERNATE KEY nk - 1
FILE NAME
OF
KEY FILE nf - 1
Key Description for key "k" consists of four words of the form:
0 8
[k * 4 + l] <key specifier>
[k * 4 + 2] <key attributes>
5-34
ENSCRIBE FILE CREATION: CREATE Procedure
where
<nf alt files>, one-byte value,
specifies the number of alternate key files for this primary
file.
5-35
ENSCRIBE FILE CREATION: CREATE Procedure
5-36
ENSCRIBE FILE CREATION: CREATE Procedure
$<volume name> or
\<sys num><volume name>
for partition n
<primary extent size> part 1 [l]
.
.
<primary extent size> part n
<secondary extent size> part 1 [l]
.
.
<secondary extent size> part n
5-37
ENSCRIBE FILE CREATION: CREATE Procedure
where
<num extra partitions>, INT,
is the number of extra volumes (other than the one specified
in the <file name> parameter) on which the file is to reside.
The maximum value permitted is 15. Note that every other
parameter in the partition array (except <partial key
length>) must be specified <num extra partitions> times.
$<volume name> or
\<sys num><volume name>, eight bytes blank filled,
is the name of the disc volume (including "$" or "\") where
the particular partition is to reside.
5-38
ENSCRIBE FILE CREATION: CREATE Procedure
5-39
ENSCRIBE FILE CREATION: CREATION EXAMPLES
CREATION EXAMPLES
This section contains the following file creation examples.
1) Key-Sequenced file
2) Key-Sequenced file with alternate keys
3) Alternate Key file for programmatically created primary
4) Partitioned Relative file
5) Partitioned Key-Sequenced file
l
Primary
key
using FUP, the following commands could be entered:
:FUP
GUARDIAN FILE UTILITY PROGRAM B06
-SET TYPE K
-SET CODE 1000
-SET EXT (16,1)
-SET REC 150
-SET BLOCK 2048
-SET COMPRESS
-SET !BLOCK 2048
-SET KEYLEN 34
-SHOW
TYPE K
CODE 1000
EXT ( 16 PAGES, 1 PAGES )
REC 150
BLOCK 2048
!BLOCK 2048
KEYLEN 34
KEYOFF 0
DCOMPRESS, !COMPRESS
-CREATE myf ile
CREATED - $STORE1.SVOL1.MYFILE
5-40
ENSCRIBE FILE CREATION: CREATION EXAMPLES
5-41
ENSCRIBE FILE CREATION: CREATION EXAMPLES
T r T T
Primary Alternate Alternate Alternate
Key Key "AQ" Key "LO" Key "VN"
Using FUP, the following commands could be entered:
-SET TYPE K
-SET CODE 1001
-SET EXT (32,8)
-SET REC 54
-SET BLOCK 4096
-SET !BLOCK 1024
-SET KEYLEN 2
-SET ALTKEY ("AQ",KEYOFF 40,KEYLEN 2)
-SET ALTKEY ("LO", KEYOFF 42, KEYLEN 4)
-SET ALTKEY ("VN",KEYOFF 46,KEYLEN 8)
-SET ALTFILE (0,INVALT)
-SHOW
TYPE K
CODE 1001
EXT ( 32 PAGES, 8 PAGES )
REC 54
BLOCK 4096
!BLOCK 1024
KEYLEN 2
KEYOFF 0
ALTKEY ( "AQ", FILE 0, KEYOFF 40, KEYLEN 2
ALTKEY ( "LO", FILE 0, KEYOFF 42, KEYLEN 4
ALTKEY ( "VN", FILE O, KEYOFF 46, KEYLEN 8
ALTFILE ( 0, $STORE1.SVOL1.INVALT )
ALTCREATE
-CREATE inv
CREATED - $STORE1.SVOL1.INV
CREATED - $STORE1.SVOL1.INVALT
5-42
ENSCRIBE FILE CREATION: CREATION EXAMPLES
LITERAL
pri"extent = 32, primary extent size = 32 * 2048.
file"code ~ 1001,
sec"extent = 8, secondary extent size = 8 * 2048.
file"type = %03, file type = key-sequenced.
rec"len = 54, record length = 54.
data"block"len = 4096; data block length = 4096.
CALL CREATE (inv"filename, pri"extent, file"code,
sec"extent, file"type, rec"len,
data"block"len, pri"key, alt"keys);
IF < THEN ! error.
5-43
ENSCRIBE FILE CREATION: CREATION EXAMPLES
5-44
ENSCRIBE FILE CREATION: CREATION EXAMPLES
5-45
ENSCRIBE FILE CREATION: CREATION EXAMPLES
byte:
[0] [36] [136]
<name> <address>
I
Primary Key
l
00 $PARTO
DA ] $PART1
]
HA
LA
I]
]
$PART2
$PART3
PA
l
f~
$PART4
TA ] $PARTS
]
]
]
Using FUP to create this file, the following commands would be entered
to describe the partitioning:
5-46
ENSCRIBE FILE CREATION: CREATION EXAMPLES
Using the CREATE procedure to create this file, source program, the
partitioning would be described in the following partition array:
partition params array.
.partarray [0:36] := S, num extra partitions.
"$PART1 ". , vol name of first extra.
"$PART2 " vol name of second extra.
"$PART3 " vol name of third extra.
"$PART4 " I vol name of fourth extra.
"$PARTS " vol name of fifth extra.
64, pri ext for first extra.
64, pri ext for second extra.
64, pri ext for third extra.
64, pri ext for fourth extra.
64, pri ext for fifth extra.
8, sec ext for first extra.
8, sec ext for second extra.
8, sec ext for third extra.
8, sec ext for fourth extra.
8, sec ext for fifth extra.
2, partial key length = 2.
"DA II, key value for $PART1.
"HA" I key value for $PART2.
II LA" , key value for $PART3.
"PA", key value for $PART4.
"TA" ] ; key value for $PARTS.
5-47
SECTION 6
The File Utility Program (FUP) can be used to load data into an
existing file.
e LOAD
• LOADALTFILE
Alternate key files are loaded with the alternate key records of a
specified file by means of the LOADALTFILE command. A slack
percentage can be specified. This command always performs a sort
of the alternate key records before the actual load is performed.
e BUILDKEYRECORDS
Because some systems may have insufficient disc space for the sort
operation, the alternate file load operation can be separated into
two steps by first performing a BUILDKEYRECORDS operations; the
input to BUILDKEYRECORDS is the "primary" file for which the
alternate key records are to be built; this output (which can be to
a magnetic tape file) are the file's alternate key records. The
key records on tape can then be loaded into the alternate key file
by means of a COPY or LOAD command.
6-1
ENSCRIBE FILE LOADING: FUP PROGRAM: LOAD Command
The LOAD command is used to load data into a structured disc file
without affecting any associated alternate key files. Existing data
in the file being loaded is lost.
[ , <load option>
where
<load option>
{ SORTED
<in option>
<key-seq option>
{ PARTOF $<volume name>
I
<load option> is one of
SORTED
6-2
ENSCRIBE FILE LOADING: FUP PROGRAM: LOAD Command
<in option>
6-3
ENSCRIBE FILE LOADING: FUP PROGRAM: LOAD Command
Considerations
• Disc Space Requirement for the SORT Option
If the <in file> records must be sorted, then during the sorting
phase, disc space for both the sort scratch file and for the
<destination file> must exist concurrently.
• Key-Sequenced File LOAD Options Explained
The syntax for the <key-seq option> is:
6-4
ENSCRIBE FILE LOADING: FUP PROGRAM: LOAD Command
- DSLACK <percentage>
specifies the minimum percentage of slack space in data blocks.
If omitted, the "SLACK <percentage>" value is used.
- !SLACK <percentage>
specifies the minimum percentage of slack space in index blocks.
If omitted, the "SLACK <percentage>" value is used.
6-5
ENSCRIBE FILE LOADING: FUP PROGRAM: LOADALTFILE Command
6-6
ENSCRIBE FILE LOADING: FUP PROGRAM: LOADALTFILE Command
Considerations
• Key-Sequenced Options
The syntax for the LOADALTFILE key-sequenced options is
MAX <num records>
SCRATCH <scratch file name>
SLACK <percentage>
DSLACK <percentage>
!SLACK <percentage>
The following two options pertain to sorting the alternate key
records generated from the <primary file>.
- MAX <num records>
specifies the number of records in the <source file>. <num
records> is given as a value in the range of {0:2099999999}. The
<num records> value is used to determine the size of the scratch
file used by the SORT process. If omitted, 10,000 is used. This
value need not be exact, but if given, should equal-to or
greater-than then actual number of records in the <source file>.
6-7
ENSCRIBE FILE LOADING: FUP PROGRAM: LOADALTFILE Command
6-8
ENSCRIBE FILE LOADING: FUP PROGRAM: BUILDKEYRECORDS Command
where
<primary file name>
specifies an existing primary file whose alternate key
records are to be generated. The primary file must have one
or more alternate key fields defined.
<out file name>
specifies an existing file where the alternate key records
generated by this command are to be written.
6-9
ENSCRIBE FILE LOADING: FUP PROGRAM: BUILDKEYRECORDS Command
<out option>
specifies the format and control of the out file. <out
option> is one of
,
{ RECOUT <out record length> j
~ BLOCKOUT <out block length> ~
6-10
ENSCRIBE FILE LOADING: FUP PROGRAM: BUILDKEYRECORDS Command
Considerations
6-11
ENSCRIBE FILE LOADING: FUP PROGRAM: EXAMPLES
This reads the records from tape and sends them to the SORT
process. When all records have been input, sorting begins.
When the sort is finished, the records are read from the SORT
process and loaded into the file according to the f ile~s
<partial key value> specifications. The data and index block
slack percentage is zero (0).
6-12
ENSCRIBE FILE LOADING: FUP PROGRAM: EXAMPLES
6-13
ENSCRIBE FILE LOADING: FUP PROGRAM: EXAMPLES
$voll.svol.filea.
It is an entry-sequenced file.
$voll.svol.fileb.
The alternate key records for the new key field will be added to this
file.
The <key specifier> for the new key is "XY", the <key offset> in the
record is (0) , the <key length> is ten (10) .
-VOLUME $voll.svol
-CREATE fileb, type K, rec 16, keylen 16
-ALTER filea, ALTFILE ( 0, fileb ) , ALTKEY "XY", KEYLEN 10 )
-LOADALTFILE o, filea
The ALTER command changes the file label for ~filea~ so that it
references "fileb" as <alternate key file> 0, and contains the
definition for the key field specified by <key specifier> "XY".
6-14
ENSCRIBE FILE LOADING: FUP PROGRAM: EXAMPLES
$voll.svol.partfile
-VOLUME $voll.svol
-SET LIKE $vol2.partfile
-SET NO PARTONLY
-CREATE temp
-DUP $vol2.partfile, temp, OLD, PARTONLY
-LOAD temp, $vol2.partfile, SORTED, PARTOF $voll
-PURGE temp
6-15
ENSCRIBE FILE LOADING: FUP PROGRAM: EXAMPLES
6-16
ENSCRIBE FILE LOADING: FUP PROGRAM: EXAMPLES
-VOLUME $voll.svol
-CREATE sortin, ext 30
-CREATE sortout, ext 30
-BUILDKEYRECORDS prifile, sortin, "F2", RECOUT 22, BLOCKOUT 2200
-EXIT
:SORT
<FROM sortin, RECORD 22
<TO sortout
<ASC 1:22
<RUN
<EXIT
:FUP
-VOLUME $voll.svol
-LOAD sortout, $vol2.altfile, SORTED, PARTOF $voll, RECIN 22,
BLOCKIN 2200
-PURGE ! sortin, sortout
The CREATE commands create the disc file used as the output of
BUILDKEYRECORDS (which is also the input to SORT) and the disc
file to be used as the output of SORT.
6-17
APPENDIX A
SEQUENTIAL I/O PROCEDURES
The Sequential I/O procedures provide TAL programmers with a
standardized set of procedures for performing common input and
output operations. These operations include reading and writing IN
and OUT files, and handling BREAK from a terminal. The primary use
of these procedures is intended for TANDEM subsystem and user utility
programs. The primary benefit is that programs using these procedures
can treat different file types in a consistent and predictable manner.
Some characteristics of the Sequential I/O procedures are:
• All file types are accessed in a uniform manner.
File access characteristics, such as access mode, exclusion
modes, and record size, are selected according to device type
and the intended access.
The Sequential I/O procedures default characteristics are
set to facilitate their most general use.
• Error recovery is automatic. All fatal errors cause the display
of a comprehensive error message, all files to close and the
process to abort. The automatic error handling and/or the display
of error messages may be turned.off. This allows the program to do
the error handling.
• The characteristics of Sequential I/O operations can be altered at
open time with the OPENAFILE procedure. This is also possible
before or after the open time with the SETAFILE procedure. Some
optional characteristics are:
Record blocking/deblocking
Duplicative file capability where data read from one file is
automatically echoed to another file.
An error reporting file where all error messages are directed.
When a particular file is not specified the error reporting
file is the home terminal.
• The Sequential I/O procedures can be used with the INITIALIZER
procedure to make run-time changes. File transfer characteristics,
such as record length, can be changed using the Command Interpreter
ASSIGN command. (See "Interface with INITIALIZER and ASSIGN
Messages".)
• The Sequential I/O procedures retain information about the files
in file control blocks. There is one file control block (FCB)
for each open file plus one common file control block which is
linked to the other FCBs. (See FCB Structure.)
A-1
SEQUENTIAL I/O PROCEDURES
A-2
SEQUENTIAL I/O PROCEDURES
A-3
SIO: CHECKABREAK Procedure
The CHECKABREAK procedure tests whether the break key has been typeo
since the last CHECKABREAK.
The call to CHECKABREAK is
Example:
CALL TAKEABREAK ( outAf ile ) ;
WHILE NOT ( break := CHECKABREAK ( outAfile ) ) DO
BEGIN
CONSIDERATIONS
• If CR/LF on break is enabled, the default case, a carriage
return/line feed sequence is executed on the terminal where break
is typed.
A-4
SIO: CHECKAFILE Procedure
A-5
SIO: CHECKAFILE Procedure
<operation> = FILEAASSIGNMASK2,
<retval> := <low-order word of ASSIGN fieldmask>
returns the low-order word of the ASSIGN message
"f ieldmask" in the FCB. This value generally has
meaning only after being set by the INITIALIZER
procedure.
<operation> = FILEABLOCKBUFLEN,
<retval> := <block buffer length>
returns a count of the number of bytes used for blocking.
<operation> = FILEABREAKHIT,
<retval> := <state of the break hit bit>
returns: 0 if the break hit bit is equal to zero in
the FCB or
1 if the break hit bit is equal to one in the
FCB.
The break hit bit is an internal indicator normally
used only by the Sequential I/O procedures.
When using the break handling procedures, do not use
FILEABREAKHIT to determine if the break key has been
typed. Instead, the CHECKABREAK procedure must be
called.
<operation> = FILEABWDLINKFCB,
<retval> := <backward-link-pointer>
A-6
SIO: CHECKAFILE Procedure
A-7
SIO: CHECKAFILE Procedure
A-8
SIO: CHECKAFILE Procedure
<operation> = FILEALOGICALFILENAMEAADDR
<retval> := @<logical filename>
<operation> = FILEAPRIEXT,
<retval> := <primary extent size>
A-9
SIO: CHECKAFILE Procedure
A-10
SIO: CHECKAFILE Procedure
<operation> = FILEALOGICALFILENAMEAADDR
<retval> := @<logical filename>
<operation> = FILEAPRIEXT,
<retval> := <primary extent size>
A-9
SIO: CHECKAFILE Procedure
A-10
SIO: CHECKAFILE Procedure
<operation> = FILEASEQNUMAADDR
<retval> := @<sequence number>
returns the word address within the FCB of an INT (32)
sequence number. This is the line number of the last
record of an edit file. For a non-edit file this is the
sequence number of the last record multiplied by 1000.
<operation> = FILEASYSTEMMESSAGES, (file must be open)
<retval> := <system message mask>
returns a mask word indicating which system messages the
user handles directly. See SETAFILE for the format.
A zero indicates that the Sequential I/O procedures
handle all system messages.
<operation> = FILEATRACEBACK,
<retval> := <state of traceback bit>
returns: 0 if the P-relative address should not be
appended to all SIO error messages
1 if the P-relative address should be
appended to all SIO error messages
<operation> = FILEAUSERFLAG,
<retval> := <user flag>
returns the user flag word. (See SETAFILE procedure,
SETAUSERFLAG operation.)
<operation> = FILEAUSERFLAGAADDR
<retval> := @<user flag>
returns the word address within the FCB of the user
flag word.
<operation> = FILEAWRITEAFOLD, (file must be open)
<retval> := <state of the write-fold bit>
returns: 0 if records longer than the logical record
length are truncated.
1 if long records are folded.
A-11
SIO: CHECKAFILE Procedure
examples:
INT .infileAname;
INT .infnum;
@infnum := CHECKAFILE ( infile , FILEAFNUMAADDR);
CONSIDERATIONS
• During the execution of this procedure the detection of any
error causes the display of an error message and the process
is aborted.
A-12
SIO: CLOSEAFILE Procedure
A-13
SIO: CLOSEAFILE Procedure
CONSIDERATIONS
• Edit files or files that are open with write access and
blocking capability must be closed with the CLOSEAFILE
procedure or the data is lost.
A-14
SIO: GIVEABREAK Procedure
CALL GIVEABREAK
! <common FCB }
<file FCB> }
where
<common FCB>, INT:ref,
<file FCB>, INT:ref,
identifies the file receiving break. <common FCB> is
allowed for convenience. If break is not enabled, this
call is ignored.
example:
CALL TAKEABREAK ( outAf ile ) ;
WHILE NOT ( break := CHECKABREAK ( outAfile ) ) DO
BEGIN
A-15
SIO: OPENAFILE Procedure
where
<error>, INT,
A-16
SIO: OPENAFILE Procedure
A-17
SIO: OPENAFILE Procedure
A-18
SIO: OPENAFILE Procedure
A-19
SIO: OPENAFILE Procedure
Considerations
A-20
SIO: OPENAFILE Procedure
Example:
LITERAL prompt= ">", !prompt character
bufferAsize = 144; !minimum edit file buffer size
INT error,
.commonAfcb [ O:FCBSIZE-1 ] := 0,
.inAfile [ O:FCBSIZE-1 ] := 0,
.inAfilename [0:11] := [ "$VOLUME SUBVOL FILENAME" ],
.buffer [ O:bufferAsize >> 1 ];
INT(32) flags := OD,
flagsAmask := ABORTAOPENERR; !return control on error
CALL SETAFILE ( inAf ile ' INITAFILEFCB ) i
CALL SETAFILE ( inAfile , ASSIGNAFILENAME, @inAfilename ) ;
IF ( error := OPENAFILE ( commonAfcb ,
inAf ile ,
buffer ,
bufferAsize ,
flags ,
f lagsAmask ,
prompt ) ) THEN
BEGIN
! handle open error here
END;
A-21
SIO: READAFILE Procedure
A-22
SIO: READAFILE Procedure
END;
CONSIDERATIONS
• If the file is a terminal or process a WRITEREAD operation will
be performed using the interactive prompt character or <prompt
count> character from <buffer>.
A-23
SIO: SETAFILE Procedure
where
<error>, INT,
is a file system or Sequential I/O procedure error
indicating the outcome of the SETAFILE.
If abort-on-error mode is in effect, the only possible
value for <error> is zero.
<common FCB>, INT:ref,
identifies those files whose characteristics are to be
altered. The <common FCB> can be used for certain
operations; it must be used for the operations
SETABREAKHIT, SETAERRORFILE, and SETATRACEBACK. If an
improper FCB is specified, an error is indicated.
<file FCB>, INT:ref,
identifies the file whose characteristics are to be altered.
If an improper FCB is specified, an error is indicated.
<operation>, INT:value,
specifies the file characteristic to be altered. See "List
of SETAFILE Operations".
<new value>, INT:value,
specifies a new value for the specified <operation>. This
may be optional depending on the <operation> desired.
A-24
SIO: SETAFILE Procedure
A-25
SIO: SETAFILE Procedure
<operation> = ASSIGNALOGICALFILENAME
<new value> = @<logical file name> (optional, file must be closed)
<old value> := <logical file name> FOR 4 words (optional)
specifies the logical name of the file to be opened. The
<logical file name> must be encoded as follows:
byte numbers
[0] [l] [8]
<len><logical filename>
A-26
SIO: SETAFILE Procedure
A-27
SIO: SETAFILE Procedure
<operation> = SETACHECKSUM
<new value> = <new checksum word>
<old value> := <checksum word in FCB>
Sets/clears checksum word in the FCB. This is useful after
modifying an FCB directly (i.e., without using the SIO
procedures).
<operation> = SETACRLFABREAK (file must be open)
<new value> = <new state> (optional)
<old value> := <state> (optional)
Sets/clears carriage return/line feed on break for the file.
If on, a CR/LF is executed on the terminal when the break
key is typed.
<operation> = SETADUPFILE (file must be open)
<new value> = @<new dup file FCB> {optional)
<old value> := @<dup file FCB> {optional)
specifies a duplicative file for the file. This is a file
where data read from <file FCB> is printed. Defaults to no
duplicative file.
example
CALL SETAFILE {inAfile, SETADUPFILE, @outAfile);
<operation> = SETAERRORFILE
<new value> = @<new error file FCB> {optional)
<old value> := @<error file FCB> (optional)
Sets error reporting file for all files. Defaults to home
terminal. If the error reporting file is not open when needed
by the Sequential I/O procedures, it is opened for the
duration of the message printing then closed.
II
~1
A-28
SIO: SETAFILE Procedure
A-29
SIO: SETAFILE Procedure
A-30
SIO: SETAFILE Procedure
A-31
SIO: SETAFILE Procedure
<operation> = SETAUSERFLAG
<new value> = <new user flag> (optional)
<old value> := <user flag in FCB> (optional)
Sets user flag for the file. The user flag is a one-word
value in the FCB which can be manipulated by the user to
maintain information about calls to that file.
<operation> = SETAWRITEAFOLD (file must be open)
<new value> = <new state> (optional)
<old value> := <state> (optional)
Sets/clears write-fold for the file. If on, writes exceeding
the record length cause multiple logical records to be
written. If off, writes exceeding the record length are
truncated to record length bytes; no error message or warning
is given.
<operation> = SETAWRITEAPAD (file must be open)
<new value> = <new state> (optional)
<old value> := <state> (optional)
Sets/clears write-blank pad for the file. If on, writes of
less than record length bytes, including the last record if
WRITEAFOLD is in effect, are padded with trailing blanks to
fill out the logical record.
<operation> = SETAWRITEATRIM (file must be open)
<new value> = <new state> (optional)
<old value> := <state> (optional)
Sets/clears write-trailing-blank trim for the file. If on,
trailing blanks are trimmed from the output record before
being written to the file.
Note:
The following operations are used only if the user is
performing NOWAIT I/O and calls the AWAITIO procedure
directly. See GUARDIAN Programming Manual, File Management
section.
A-32
SIO: SETAFILE Procedure
A-33
SIO: TAKEABREAK Procedure
A-34
SIO: WAITAFILE Procedure
A-35
SIO: WAITAFILE Procedure
A-36
SIO: WRITEAFILE Procedure
<error>, INT,
A-37
SIO: WRITEAFILE Procedure
A-38
SIO: PROCEDURE ERRORS
512 SIOERRAINVALIDPARAM
The SIO procedure contains an invalid parameter. This error applies
to all procedures. Correct the parameter in error.
513 SIOERRAMISSINGFILENAME
The SIO procedure is missing a file name. This error is an open
error. Specify a file name in the procedure call.
514 SIOERRADEVNOTSUPPORTED
The SIO procedures do not support the specified device type. This
error is an open error. Change the device type.
515 SIOERRAINVALIDACCESS
The access mode is not compatible with the device type. This error
occurs if the program opens the edit file with read or write access
or with blocking specified. This error is an open error. Change
either the device type or the access mode.
516 SIOAINVALIDBUFADDR
The buffer address is not within 'G'[0:32767] of the data area.
This error is an open error. Move the buffer into lower memory.
517 SIOERRAINVALIDFILECODE
The file code specified in an ASSIGN command does not match the file
code of the file. Change either the file name or the file code in
the ASSIGN command.
518 SIOERRABUFTOOSMALL
The buffer specified is too small. For reading an edit file,
allocate at least 144 bytes of buffer space. For writing an edit
file, allocate at least 1024 bytes of buffer space. For blocking,
allocate at least the same number of bytes for buffer space as for
the logical record length. If this error persists after increasing
the buffer space, the directory of the edit file is in error. Edit
the file; the editor usually can correct the directory error. This
error is an open error.
519 SIOERRAINVALIDBLKLENGTH
The ASSIGN block length is greater than the block buffer length.
Either correct the ASSIGN command or use a larger buffer.
A-39
SIO: PROCEDURE ERRORS
520 SIOERRAINVALIDRECLENGTH
This error occurs when the specified record length is either zero or
greater than <max record length> specified in the OPENAFILE
procedure, when the record length for the $RECEIVE file is less than
14, or when the record length is greater than 254 and the procedure
specifies variable length records. This error is an open error.
Correct the specified record length.
521 SIOERRAINVALIDEDITFILE
An edit file is invalid. This error is an open error.
522 SIOERRAFILEALREADYOPEN
The program used the SETAFILE procedure for a file that should be
closed or used the OPENAFILE procedure for a file that is
already open.
523 SIOERRAEDITREADERR
Indicates an edit read error. This error is an open or read
error.
524 SIOERRAFILENOTOPEN
The specified file is not open. This error is a check, read, set,
write, or wait error. Either open the file or correct the procedure
call (for example, change the parameters to permit the operation
when the file is closed).
525 SIOERRAACCESSVIOLATION
The access mode is not compatible with the requested operation.
This error is a read or write error. Change either the operation or
the access mode.
526 SIOERRANOSTACKSPACE
The program requires a temporary buffer, but the stack has
insufficient space. Increase the run-time memory size if it is
less than 32K; otherwise, move one or more non-string arrays to
upper memory.
527 SIOERRABLOCKINGREQD
The program is attempting a write fold or write pad without a block
buffer. This error is a write error. Supply a block buffer.
528 SIOERRAEDITDIROVERFLOW
An overflow occurred in the internal directory of an edit file.
This error is a write error.
529 SIOERRAINVALIDEDITWRITE
The program attempted to write to an edit file after writing the
internal directory. This error is a write error.
530 SIOERRAINVALIDRECVWRITE
The program read the $RECEIVE file, but did not follow the read with
a write to the $RECEIVE file. This error is a write error. Either
add the missing write or delete the extra read.
A-40
SIO: PROCEDURE ERRORS
531 SIOERRACANTOPENRECV
The SIO procedure cannot open $RECEIVE for break monitoring. The
user did not open the $RECEIVE file with the SIO procedure
OPENAFILE. This error is a CHECKABREAK error. Open the $RECEIVE
file with the OPENAFILE procedure to do break monitoring while using
$RECEIVE.
532 SIOERRAIORESTARTED
The NOWAIT I/O restarted. This message is a warning, not an error.
Call WAITAFILE again to continue waiting.
533 SIOERRAINTERNAL
Indicates there is an internal error. This error is a
wait error.
534 SIOERRACHECKSUMCOM
While performing a checksum on the common FCB, the SIO procedure
encountered an error. This error applies to all procedures. Check
the program for pointer errors.
535 SIOERRACHECKSUM
While performing a checksum on the file FCB, the SIO procedure
encountered an error. This error applies to all procedures. Check
the program for pointer errors.
A-41
SIO: FCB STRUCTURE
COMMON FCB
I
LINK I~
I
FILE FCB
FILE FCB
FILE FCB
A-42
SIO: INITIALIZING THE FILE FCB
4. Specify the access mode for this open. This step is optional.
CALL SETAFILE ( <file FCB> , ASSIGNAOPENACCESS , <open access>
The following LITERALS are provided for <open access> :
READWRITEAACCESS (0)
READAACCESS (1)
WRITEAACCESS (2)
A-43
SIO: INITIALIZING THE FILE FCB
A-44
SIO: INITIALIZING THE FILE FCB
7. Set the file code. This step is optional and has two meanings:
1) if AUTOACREATE is on, the file code specifies the type of file
to be created. 2) implies the file code must match the file code
specified for the open to succeed.
CALL SETAFILE ( <file FCB> , ASSIGNAFILECODE , <file code>
8. Set the primary extent size. This step is optional and has
meaning only if AUTOACREATE is on.
CALL SETAFILE ( <file FCB> , ASSIGNAPRIMARYEXTENTSIZE ,
<primary extent size> )
<primary extent size> is given in pages (2048-byte units).
10. Set the file's physical block length. This step is optional.
It is the number of bytes transferred between the file and the
process in a single I/O operation. If the <block length> is
specified, blocking is also specified. A physical block is
composed of <block length> divided by <record length> logical
records. When <block length> is not exactly divisible by <record
length>, the portion of that block following the last logical
record is filled with blanks.
A-45
SIO: INITIALIZING THE FILE FCB
Note that the specified form of blocking differs from the type
of blocking performed when no <block length> is specified. In the
unspecified form, there is no indication of a physical block size,
the records are contiguous on the media.
CALL SET~FILE ( <file FCB> , ASSIGN~BLOCKLENGTH , <block length> )
<block length> is given in bytes.
A-46
SIO: INTERFACE WITH INITIALIZER AND ASSIGN MESSAGES
INITIALIZER-RELATED DEFINES
Two Defines are provided for allocating Run-Unit Control Block
Space {CBS) and for allocating FCB space. These defines are:
1. ~llocate Run-Unit Control Block and Common FCB {data declaration).
ALLOCATEACBS { <run-unit control block> , <common FCB> ,
<numf iles> ) ;
where
A-47
SIO: INTERFACE WITH INITIALIZER AND ASSIGN MESSAGES
<common FCB>
is the name to be given to the common FCB, this name is
passed to the OPENAFILE procedure.
<nurnf iles>
is the number of FCBs to be prepared by the INITIALIZER
procedure. The INITIALIZER begins with the first FCB
following ALLOCATEACBS.
example
ALLOCATEACBS ( rucb , commfcb , 2 ) ;
2. Allocate FCB (data declaration).
<file FCB>
A-48
SIO: INTERFACE WITH INITIALIZER AND ASSIGN MESSAGES
II
#TEMP II
A-49
SIO: INTERFACE WITH INITIALIZER AND ASSIGN MESSAGES
example
INT .buf [ 0:11 ];
STRING .sbuf := @buf '<<' l;
sbu f , : =' [ 5' Ii INPUT" ] ;
CALL SETAFILE ( inAf ile , ASSIGNALOGICALFILENAME , @buf ) ;
sbuf ':=' [ 6, "OUTPUT"];
CALL SETAFILE ( outAf ile ' ASSIGNALOGICALFILENAME ' @buf ) ;
CONSIDERATIONS
• If run-time changes to file transfer characteristics are not
allowed then do not assign a logical file name to the file.
A-50
SIO: INTERFACE WITH INITIALIZER AND ASSIGN MESSAGES
CALL INITIALIZER ( •• ) ;
CALL OPENAFILE (<common FCB> , <file FCB>, ••• ) ;
If the user neglects to ASSIGN a physical file to the logical
file, the open will fail with an error number 513,
SIOERRAMISSINGFILENAME, file name is not supplied.
USAGE EXAMPLE
The following shows the use of the INITIALIZER and Sequential I/O
procedures for opening the IN and OUT files of a typical TANDEM
subsystem program.
If the IN and OUT files are the same file and either is a terminal
or a process, only the IN file is opened. The address of the inAfile
FCB is put into the pointer to the outAf ile FCB.
The open access is assigned after the INITIALIZER is called. This
overrides the open access specified in an ASSIGN command.
?NOLIST, SOURCE $SYSTEM.SYSTEM.GPLDEFS
?LIST
! Set up the control blocks for the initializer with supplied
!DEFINES.
Initialize Run Unit Control Block and common FCB.
rucb - Array holding Run Unit Control Block.
commf cb - Array for the common File Control Block.
ALLOCATEACBS ( rucb, commfcb, 2 ) ;
A-51
SIO: USAGE EXAMPLE WITH THE INITIALIZER
LITERAL
process = 0, Process device type.
terminal = 6, Terminal device type.
inblklen = 4096, Length of block buffer for in
file.
outblklen = 4096, Length of block buffer for out
file.
rec""len = 255; Maximum record length to read
or write.
INT .inblkbuf [ O:inblklen/2 - 1 ], In file's buffer for blocking.
• outblkbuf [ O:outblklen/2 - 1 ], Out file's buffer for blocking •
• infname, In file's file name •
• outfname, Out file's file name •
device"type, Device type, GUARDIAN manual,
p2. 3-21.
phys""rec""len, Physical record length of
device.
interactive; Indicates if in and out file
are interactive implying use
READWRITE access.
A-52
SIO: USAGE EXAMPLE WITH THE INITIALIZER
Set up in and out files using startup message from RUN command.
sbuf ~:=~ [ 5, "INPUT"];
CALL SETAFILE{ inAfile, ASSIGNALOGICALFILENAME, @buf ) ;
sbuf ~:=~ [ 6, "OUTPUT"];
CALL SETAFILE{ outAfile, ASSIGNALOGICALFILENAME, @buf ) ;
CALL INITIALIZER{ rucb );
get physical file names for in and out files.
A-53
SIO: USAGE EXAMPLE WITH THE INITIALIZER
END;
To change the record length of the input file, the following ASSIGN
command can be entered before the program is run.
ASSIGN INPUT,,REC 80
To change the file code of the output file, the following ASSIGN
command can be entered before the program is run.
ASSIGN OUTPUT,,CODE 9876
SUMMARY
The following are the steps involved to use the INITIALIZER with the
Sequential I/O procedures~
Allocate the CBS and FCB and assign the default physical file
names using ALLOCATEACBS and ALLOCATEAFCBs.
Assign a logical file name using the SETAFILE operation,
ASSIGNALOGICALFILENAME.
If ASSIGN command characteristics are to override program
calls to SETAFILE, invoke assignment defines.
Invoke the INITIALIZER to read the startup, ASSIGN, and PARAM
messages and prepare the file FCBs.
If programmatic calls to SETAFILE are to oveiride ASSIGN command
characteristics, invoke assignment defines.
Open the files with calls to OPENAFILE.
A-54
SIO: USAGE EXAMPLE WITHOUT INITIALIZER PROCEDURE
The following example shows the use of the Sequential I/O procedures
for the IN and OUT files of a typical TANDEM subsystem program when
the INITIALIZER procedure is not used.
?SOURCE $SYSTEM.SYSTEM.GPLDEFS
INT interactive,
error,
.commonAfcb [O:FCBSIZE-1] := 0,
.rcvAfile [O:FCBSIZE-1],
.inAfile [O:FCBSIZE-1],
.. outAf ile [O:FCBSIZE-1],
.buffer [0:99],
mompid [0:3],
devtype,
junk;
LITERAL
process = 0,
terminal = 6,
inAblkbuf len = 1024,
outAblkbuf len = 1024;
INT .inAblkbuf [O:inAblkbuflen/2 - l],
.outAblkbuf [O:outAblkbuflen/2 - l];
?SOURCE $SYSTEM.SYSTEM.EXTDECS { •••
read the startup message.
- open $receive.
!
CALL SETAFILE { rcvAf ile , INITAFILEFCB ) ;
buffer ':=' "$RECEIVE " & buffer [ 4 ] FOR 7;
! file name.
CALL SETAFILE { rcvAf ile , ASSIGNAFILENAME , @buffer ) ;
! number of bytes to read.
CALL SETAFILE { rcvAf ile , ASSIGNARECORDLENGTH , 200 ) ;
CALL OPENAFILE { commonAfcb , rcvAfile ,,, nowait , nowait);
- get moms process id.
- first, see if i'm named.
CALL GETCRTPID { MYPID I buffer ) ;
IF buffer.<0:1> = 2 THEN
! not named.
CALL MOM { mompid ) ;
ELSE
BEGIN
! named.
CALL LOOKUPPROCESSNAME { buffer ) ;
mompid ':=' buffer [ 5 ] FOR 4;
END;
- allow startup message from mom only.
A-55
SIO: USAGE EXAMPLE WITHOUT INITIALIZER PROCEDURE
DO
BEGIN
CALL READAFILE ( rcvAfile , buffer ,,,, 1);
DO error := WAITAFILE ( rcvAfile , length , 3000D
UNTIL error <> SIOERRAIORESTARTED;
END
UNTIL buffer = -1; ! startup message read.
! - close $receive.
CALL CLOSEAFILE ( rcvAf ile ) ;
!
! see if program is being run interactivelye
!
CALL DEVICEINFO ( buffer [ 9 ] , devtype , junk ) ;
interactive :=
IF ( devtype.<4:9> = terminal OR
devtype.<4:9> = process ) AND
buffer [ 9 ] = buffer [ 21 ] for 12 THEN 1
ELSE O;
CALL SETAFILE ( inAf ile , INITAFILEFCB ) ;
CALL SETAFILE ( inAf ile , ASSIGNAFILENAME , @buffer 9 ] );
CALL SETAFILE ( inAf ile , ASSIGNAOPENACCESS ,
IF interactive THEN READWRITEAACCESS
ELSE READAACCESS );
CALL OPENAFILE ( commonAfcb , inAf ile , inAblkbuf , inAblkbuflen
,,,,, outAfile);
IF interactive THEN
! use in file as out file.
@outAfile := @inAfile
ELSE
BEGIN
CALL SETAFILE ( outAf ile , INITAFILEFCB ) ;
CALL SETAFILE ( outAf ile , ASSIGNAFILENAME , @buffer [ 21 ] ) ;
CALL SETAFILE ( outAf ile , ASSIGNAOPENACCESS , WRITEAACCESS ) ;
CALL OPENAFILE ( commonAfcb , outAf ile , outAblkbuf ,
outAblkbuflen ) ;
! set duplicative file.
CALL SETAFILE ( inAf ile , SETADUPFILE , @outAf ile ) ;
END;
A-56
SIO: NOAERROR Procedure
{ <no retry> :=
{ CALL
l <state>
, <file FCB>
, <good error list>
, <retryable> )
where
<no retry>, INT,
indicates whether or not the I/O operation should be
retried. Values of <no retry> are:
0 = operation should be retried.
<>0 = operation should not be retried.
If <no retry> is not zero, one of the following
is indicated:
- <state> is not zero.
- no error occurred, error is zero.
- error is a good error number on the list.
- fatal error occurred and abort-on-error mode is off.
- error is a break error and break is enabled for
<file FCB>.
<state>, INT:value,
if non-zero, indicates the operation is to be considered
successful. The file error and retry count variables are
set to zero with <no retry> returned as non-zero.
Typically, either of two values is passed in this position:
= CCE for example, immediately following a file system
call. If equal is true, the operation is successful.
This eliminates a call to FILEINFO by NOAERROR.
0 forces NOAERROR to first check the error value in the
FCB. If the FCB error is zero, NOAERROR calls FILEINFO
for the file.
A-57
SIO: NOAERROR Procedure
A-58
SIO: NOAERROR Procedure
A-59
SIO: NOAERROR Procedure
A-60
SIO: $RECEIVE HANDLING
A-61
SIO: $RECEIVE HANDLING
A-62
SIO: $RECEIVE HANDLING
A-63
SIO: NOWAIT I/O
If it is desirable to wait for any file, the user can call AWAITIO
before calling WAITAFILE. Dependent on whether blocking is
performed, a physical I/0 may not always take place with a logical
I/O. Therefore, the CHECKAFILE operation FILEAPHYSIOOUT is used to
determine if an I/O is outstanding. The SETAFILE operations
SETAPHYSIOOUT, SETAERROR, and SETACOUNTXFERRED are provided to
condition the FCB, if the I/O is completed. The user must call
WAITAFILE following the call to AWAITIO for the file state
information to be updated.
example
fnum := -1;
CALL AWAITIO ( fnum ,, countread ,, 3000D);
IF fnum = inAfnum THEN
BEGIN
CALL FILEINFO ( inAfnum inAfile ) , error ) ;
! set I/O done.
CALL SETAFILE ( inAf ile , SETAPHYSIOOUT , 0 ) ;
! set count read.
CALL SETAFILE ( inAf ile , SETACOUNTXFERRED , countread ) ;
! set error code.
CALL SETAFILE ( inAf ile , SETAERROR , error ) ;
IF ( error :=
WAITAFILE ( inAf ile , inAf ileAcountread ) ) <>
SIOERRAIORESTARTED THEN
BEGIN ! completed.
!
! process read.
!
END;
END
ELSE
A-64
SIO: $SYSTEM.SYSTEM.GPLDEFS
LITERAL
FCBSIZE = 60;
! DECLARE RUCB , PUCB, AND COMMON FCB.
DEFINE
ALLOCATEACBS ( RUCBANAME ' COMMONAFCBANAME ' NUMAFILES =
INT .RUCBANAME [ 0:65 ] :=
RUCB PART.
[ 62 ' 1 ' 27 * [ 0 ] ' 62 ' 32 * [ 0 ] '
! PUCB PART.
4 'NUMAFILES' 4 + FCBSIZE ];
INT .COMMONAFCBANAME [ O:FCBSIZE - 1 ] :=
[ FCBS I ZE * [ 0 ] ] # ;
DECLARE FCB.
DEFINE
ALLOCATEAFCB ( FCBANAME ' PHYSAFILENAME } =
INT .FCBANAME [ O:FCBSIZE ~ 1 ] :=
[ FCBSIZE ' %000061 ' -1 ' %100000 ' 0 ' PHYSAFILENAME ,
( FCB SI ZE - 1 7 } * [ 0 ] ] # ;
SETAFILE OPERATIONS.
LITERAL
INITAFILEFCB = 0,
ASSIGNAFILENAME = 1,
ASSIGNALOGICALFILENAME = 2,
ASSIGNAOPENACCESS = 3,
ASSIGNAOPENEXCLUSION = 4,
ASSIGNARECORDLENGTH = 5,
ASSIGNAFILECODE = 6,
ASSIGNAPRIMARYEXTENTSIZE = 7,
ASSIGNASECONDARYEXTENTSIZE = 8,
ASSIGNABLOCKLENGTH = 9,
!
SETADUPFILE = 10,
SETASYSTEMMESSAGES = 11,
SETAOPENERSPID = 12,
SETARCVUSEROPENREPLY = 13,
SETARCVOPENCNT = 14,
SETARCVEOF = 15,
SETAUSERFLAG = 16,
SETAABORTAXFERERR = 17,
SETAPRINTAERRAMSG = 18,
A-65
SIO: $SYSTEM.SYSTEM.GPLDEFS
SET""READ"'TRIM = 19,
SET""WRITE""TRIM = 20,
SET"'WRITE"'FOLD = 21,
SET""WRITE""PAD = 22,
SET""CRLF""BREAK = 23,
SET"' PROMPT = 24,
SET""ERRORFILE = 25,
SET""PHYSIOOUT = 26,
SET""LOGIOOUT = 27,
SET""COUNTXFERRED = 28,
SET"'ERROR = 29,
SET""BREAKHIT = 30,
SET"' TRACEBACK = 31,
SET"'EDITREAD"'REPOSITION = 32,
!
FILE"'FILENAME"'ADDR = 33,
FILE"'LOGICALFILENAME"'ADDR = 34,
FILE"'FNUM"'ADDR = 35,
FILE""ERROR"'ADDR = 36,
FILE"'USERFLAG"'ADDR = 37,
FILE"'SEQNUM"'ADDR = 38,
FILE"'FILEINFO = 39,
FILE""CREATED = 40,
FILE"'FNUM = 41,
FILE"'SEQNUM = 42,
!
MAX"'OPERATION = 42,
FILE"" FILENAME = ASSIGN""FILENAME + 256,
FILE"'LOGICALFILENAME = ASSIGN"'LOGICALFILENAME + 256,
FILE .... OPENACCESS = ASSIGN"'OPENACCESS + 256,
FILE"'OPENEXCLUSION = ASSIGN""OPENEXCLUSION + 256,
FILE"'RECORDLEN = ASSIGN"'RECORDLENGTH + 256,
FILE"'FILECODE = ASSIGN"'FILECODE + 256,
FILE"'PRIEXT = ASSIGN"'PRIMARYEXTENTSIZE + 256,
FILE"'SECEXT = ASSIGN"'SECONDARYEXTENTSIZE + 256,
FILE"'BLOCKBUFLEN = ASSIGN"'BLOCKLENGTH + 256,
FILE"'DUPFILE = SET"'DUPFILE + 256,
FILE"'SYSTEMMESSAGES = SET"'SYSTEMMESSAGES + 256,
FILE""OPENERSPID = SET"'OPENERSPID + 256,
FILE"'RCVUSEROPENREPLY = SET"'RCVUSEROPENREPLY + 256,
FILE""RCVOPENCNT = SET"'RCVOPENCNT + 256,
FILE"'RCVEOF = SET"'RCVEOF + 256,
FILE"'USERF.LAG = SET"'USERFLAG + 256,
FILE"'ABORT"'XFERERR = SET"'ABORT""XFERERR + 256,
FILE""PRINT"'ERR"'MSG = SET"'PRINT"'ERR"'MSG + 256,
FILE"'READ"'TRIM = SET"'READ"'TRIM + 256,
FILE""WRITE""TRIM = SET"'WRITE"'TRIM + 256,
FILE""WRITE"'FOLD = SET"'WRITE"'FOLD + 256,
FILE""WRITE""PAD = SET"'WRITE"'PAD + 256,
F!LE"'CRLF"'BREAK = SET""CRLF""BREAK + 256,
FILE"" PROMPT = SET"" PROMPT + 256,
FILE"'ERRORFILE = SET"'ERRORFILE + 256,
A-66
SIO: $SYSTEM.SYSTEM.GPLDEFS
OPEN EXCLUSION.
LITERAL
SHARE = O,
EXCLUSIVE = 1,
PROTECTED = 3;
OPEN"'FILE FLAGS v 111111
0123456789012345
1111111111222222222233
DEFINE !4567890123456789012345678901
ABORT"'OPENERR = %B0000000000000000000000000001D#,
ABORT"'XFERERR = %B0000000000000000000000000010D#,
PRINT"'ERR"'MSG = %B0000000000000000000000000100D#,
AUTO"'CREATE = %B0000000000000000000000001000D#,
MUSTBENEW = %B0000000000000000000000010000D#,
PURGE"'DATA = %B0000000000000000000000100000D#,
AUTO"'TOF = %B0000000000000000000001000000D#,
NOWAIT = %B0000000000000000000010000000D#,
BLOCKED = %B0000000000000000000100000000D#,
VAR"'FORMAT = %B0000000000000000001000000000D#,
READ"'TRIM = %B0000000000000000010000000000D#,
WRITE"'TRIM = %B0000000000000000100000000000D#,
WRITE"' FOLD = %B0000000000000001000000000000D#,
WRITE"' PAD = %B0000000000000010000000000000D#,
CRLF"'BREAK = %B0000000000000100000000000000D#;
sio procedure errors.
LITERAL
SIOERR"'INVALIDPARAM = 512, parameter is invalid.
SIOERR"'MISSINGFILENAME = 513, filename not supplied.
SIOERR"'DEVNOTSUPPORTED = 514, device not supported.
SIOERR"'INVALIDACCESS = 515, access mode incompatible with
device.
SIOERR"'INVALIDBUFADDR = 516, buffer address not in lower 32k.
SIOERR"'INVALIDFILECODE = 517, file code of file does not match
assigned file code.
SIOERR"'BUFTOOSMALL = 518, buffer to small for edit write
(ie., less than 1024 bytes) or
A-67
SIO: $SYSTEM.SYSTEM.GPLDEFS
A-68
SIO: FILE CONTROL BLOCK (FCB) FORMAT
open options.
OPENEXCLUSION, (22) exclusion bits to OPEN.
OPENACCESS; (23) access bits to OPEN.
initializer group.
!
INT PUCBAPOINTER, (24) not used by sio procedures.
SAMEFILELINK; (25) not used by sio procedures.
beginning of sio groups.
A-69
SIO: FILE CONTROL BLOCK (FCB) FORMAT
A-70
SIO: FILE CONTROL BLOCK (FCB} FORMAT
Break Group.
INT BRKFCBADDR = (31) FCB of file owning break.
DEVINFO,
BRKMSG = (32:33) break message buffer.
OPENFLAGS2,
BRKCNTL = {34) break control.
XFERCNTLl,
BRKLASTOWNER = (35} break last owner.
XFERCNTL2:
$RECEIVE Group.
INT SYSMSGS = (36} System messages to be
DUPFCBADDR, passed back to caller.
RCVCNTL = (37) $RECEIVE control.
LINENO,
PRIMARYPID [-1:-1] = (38:41) Primary opener's <process
id>.
LINENO,
BACKUPPID = (42:45) Backup opener's <process
id>.
BLKNEXTREC,
REPLYCODE = (46) $RECEIVE reply error code.
TFOLDLEN:
A-71
SIO: FILE CONTROL BLOCK (FCB) FORMAT
Misc Group.
INT COMMCNTL = ( 4 7)
PHYSXFERCNT,
OPRQSTFCBADDR = (48) FCB of file for which operator
PHYSIOCNTXFERRED, console messages are being
displayed. (see NO""ERROR,
prompt).
OPRQSTCOUNT = (49) count of number of operator
LOGICALFILENAME, messages displayed. (see
NO""ERROR, prompt).
ERRFCBADDR [-1:-1) = (50) FCB address of file where
LOGICALFILENAME; errors are to be reported.
INT SPARE!, (53) unused fcb word.
SPARE2, (54) unused fcb word.
SPARE3, (55) unused fcb word.
SPARE4, (56) unused fcb word.
SPARES, (57) unused fcb word.
SPARE6, (58) unused fcb word.
SPARE7; (59) unused fcb word.
END; FCB""TMPL.
-- BIT FIELDS.
- ASSIGN BITS.
DEFINE
FILENAMESUPPLD = <0>#,
FCB""FILENAMESUPPLD = FCB.OPTIONSl.FLLENAMESUPPLD#,
PRIEXTSUPPLD = <l>#,
FCB""PRIEXTSUPPLD = FCB.OPTIONSl.PRIEXTSUPPLD#,
SECEXTSUPPLD = <2>#,
FCB""SECEXTSUPPLD = FCB.OPTIONSl.SECEXTSUPPLD#,
FCODESUPPLD = <3>#,
FCB""FCODESUPPLD = FCB.OPTIONSl.FCODESUPPLD#,
EXCLUSIONSUPPLD = <4>#,
FCB""EXCLUSIONSUPPLD = FCB.OPTIONSl.EXCLUSIONSUPPLD#,
ACCESSSUPPLD = <5>#,
FCB""ACCESSSUPPLD = FCB.OPTIONSl.ACCESSSUPPLD#,
RRECLENSUPPLD = <6>#,
FCB""RRECLENSUPPLD = FCB.OPTIONSl.RRECLENSUPPLD#,
BLOCKLENSUPPLD = <7>#,
FCB""BLOCKLENSUPPLD = FCB.OPTIONSl.BLOCKLENSUPPLD#;
A-72
SIO: FILE CONTROL BLOCK (FCB) FORMAT
DEFINE
EXCLUSIONFIELD = <9:11>#,
FCBAEXCLUSIONFIELD = FCB.OPENEXCLUSION.EXCLUSIONFIELD#;
- OPEN ACCESS (FCBAOPENACCESS)
DEFINE
ACCESSFIELD = <3:5>#,
FCBAACCESSFIELD = FCB.OPENACCESS.ACCESSFIELD#;
- DEVINFO.
DEFINE
FILETYPE = <0:3>#,
FCB.--.FILETYPE = FCB.DEVINFO.FILETYPE#;
LITERAL
UNSTR = O,
ESEQ = 1,
REL = 2,
KSEQ = 3,
EDIT = 4,
OD DUNS TR = 8;
DEFINE
STRUCTFILE = <2:3>#, ! <>O means structured file~
FCB"STRUCTFILE = FCBADEVINFO.STRUCTFILE#;
DEFINE!
DEVTYPE = <4:9>#,
FCBADEVTYPE = FCB.DEVINFO.DEVTYPE#;
LITERAL
PROCESS = O,
OPERATOR = 1,
RECEIVE = 2,
DISC = 3,
MAGTAPE = 4,
PRINTER = 5,
TERMINAL = 6,
DATACOMM = 7,
CARDRDR = 8;
DEFINE
DEVSUBTYPE = <10:15>#,
FCBADEVSUBTYPE = FCB.DEVINFO.DEVSUBTYPE#;
DEFINE
FILECREATED = <0>#, new file created.
FCBAFILECREATED = FCB.OPENFLAGSl.FILECREATED#;
DEFINE
ACCESS = <l: 3>#, ! access mode.
FCB"ACCESS = FCB.OPENFLAGSl.ACCESS#;
A-73
SIO: FILE CONTROL BLOCK (FCB) FORMAT
LITERAL
READACCESS = 1,
WRITEACCESS = 2,
READWRITEACCESS = 3;
DEFINE
ABORTONOPENERROR = <15>#, ! abend on fatal error during open.
FCBAABORTONOPENERROR = FCB.OPENFLAGS2.ABORTONOPENERROR#;
DEFINE
ABORTONXFERERROR = <14>#, ! abend on fatal error during data
! transfer.
FCBAABORTONXFERERROR = FCB.OPENFLAGS2.ABORTONXFERERROR#;
DEFINE
PRINTERRMSG = <13>#, ! print error message on fatal error.
FCBAPRINTERRMSG = FCB.OPENFLAGS2.PRINTERRMSG#;
DEFINE
AUTOCREATE = <12>#, ! ~reate a file if write access.
! 0 = don ... t.
! 1 = do.
FCBAAUTOCREATE = FCB.OPENFLAGS2.AUTOCREATEi;
DEFINE
FILEMUSTBENEW = <ll>#, if autocreate = 1, no such file may
currently exist.
! 0 = old file is allowed.
! 1 = file must be new.
FCBAFILEMUSTBENEW = FCB.OPENFLAGS2.FILEMUSTBENEW#;
DEFINE
WRITEPURGEDATA = <.10>#, ! purge existing data.
! 0 = APPEND.
! l = PURGEDATA.
FCBAWRITEPURGEDATA = FCB.OPENFLAGS2.WRITEPURGEDATA#;
DEFINE
AUTOTOF = <9>#, auto page eject on open for
printer/process.
! 0 = NO
! 1 = YES
FCBAAUTOTOF = FCB.OPENFLAGS2.AUTOTOF#;
DEFINE
NOWAITIO = <8>#, ! open with nowait depth of 1.
! 0 = WAIT.
! 1 = NOWAIT.
FCBANOWAITIO = FCB.OPENFLAGS2.NOWAITIO#;
DEFINE
BLOCKEDIO = <7>#, ! blocked io.
! 0 = NOT BLOCKED
! 1 = BLOCKED
FCBABLOCKEDIO = FCB.OPENFLAGS2.BLOCKEDIO#;
DEFINE
VARFORMAT = <6>#, ! variable length records.
! 0 = FIXED LENGTH
! 1 = VARIABLE LENGTH
FCBAVARFORMAT = FCB.OPENFLAGS2.VARFORMAT#;
A-74
SIO: FILE CONTROL BLOCK (FCB) FORMAT
DEFINE
READTRIM = <5>#, ! trim trailing blanks.
! 0 = NOTRIM
! 1 = TRIM
FCB"'READTRIM = FCB.OPENFLAGS2.READTRIM#;
DEFINE
WRITETRIM = <4>#, ! trim trailing blanks.
! 0 = NOTRIM
! 1 = TRIM
FCB"'WRITETRIM = FCB.OPENFLAGS2.WRITETRIM#;
DEFINE
WRITEFOLD = <3>#, ! fold write transfers greater than
! 0 = TRUNCATE write record length bytes into
! 1 = FOLD multiple records.
FCB"'WRITEFOLD = FCB.OPENFLAGS2.WRITEFOLD#;
DEFINE
WR I TEP AD = <2>#, ! pad record with trailing blanks.
FCB"'WRITEPAD = FCB.OPENFLAGS2.WRITEPAD#;
DEFINE
CRLFBREAK = <l>#, ! carriage return/line feed on break.
! 0 = NO CRLF ON BREAK.
! 1 = CRLF ON BREAK.
FCB"'CRLFBREAK = FCB.OPENFLAGS2.CRLFBREAK#;
DEFINE
READIOTYPE = <1:3>#,
0 = READ
l = HEADUPOATE/REPLY
2 = EDITREAD
3 = WRITEREAD
! 7 = INVALID
FCB"'READIOTYPE = FCB.XFERCNTLl.READIOTYPE#;
LITERAL
STANDARDTYPE = 0,
RECEIVETYPE = 1,
EDITTYPE = 2,
INTERACTIVETYPE = 3,
INVALIDTYPE = 7;
DEFINE
WRITEIOTYPE = <4:6>#,
0 = WRITE
! 1 = READUPDATE/REPLY
! 2 = EDITWRITE
! 7 = INVALID
FCB"'WRITEIOTYPE = FCB.XFERCNTLl.WRITEIOTYPE#;
DEFINE
SYSBUFLEN = <7:8>#, ! system buffer length / 1024.
FCB"'SYSBUFLEN = FCB.XFERCNTLl.SYSBUFLEN#;
DEFINE
PROMPT = <9:15>#, ! interactive prompt character.
FCB"'PROMPT = FCB.XFERCNTLl.PROMPT#;
A-75
SIO: FILE CONTROL BLOCK (FCB) FORMAT
DEFINE
PHYSIOOUT = <0>#, ! physical [read/write] io
! outstanding.
FCB"PHYSIOOUT = FCB.XFERCNTL2.PHYSIOOUT#,
READIOOUT = <l>#, ! logical read io outstanding.
FCB"READIOOUT = FCB.XFERCNTL2.READIOOUT#,
WRITEIOOUT = <2>#, ! logical write io outstanding.
FCB"WRITEIOOUT = FCB.XFERCNTL2.WRITEIOOUT#,
LOGIOOUT = <1:2>#, ! logical io outstanding.
FCB"LOGIOOUT = FCB.XFERCNTL2.LOGIOOUT#,
WRITEFLUSH = <3>#, ! block buffer flush operation in
! progress.
FCB"WRITEFLUSH = FCB.XFERCNTL2.WRITEFLUSH#,
RETRY COUNT = <4:5>#, ! i/o retry counter.
FCB"RETRYCOUNT = FCB.XFERCNTL2.RETRYCOUNT#,
NOPARTIALREC = <6>#, ! blocks contain only full records.
FCB"NOPARTIALREC = FCB.XFERCNTL2.NOPARTIALREC#;
DEFINE
~DDIRWIP = <7>#, ! directory write in progress.
FCB"EDDIRWIP = FCB.XFERCNTL2.EDDIRWIP#,
EDHALFSECTCNT = <8:11>#, ! number of half sectors written in
! current data page after next
! physical write.
FCB"EDHALFSECTCNT = FCB.XFERCNTL2.EDHALFSECTCNT#,
EDDATABUFLEN = <12:15>#, ! edit data buf size ~>>~
! EDDBUFSHIFT (8).
FCB"EDDATABUFLEN = FCB.XFERCNTL2.EDDATABUFLEN#,
EDREPOSITION = <7>#, ! user is repositioning edit file
! (read op).
FCB"EDREPOSITION = FCB.XFERCNTL2.EDREPOSITION#;
DEFINE
CNTLINPROGRESS = <0>#,
FCB"CNTLINPROGRESS = FCB.PHYSXFERCNT.CNTLINPROGRESS#,
FORMSCNTLOP = <1:15>#,
FCB"FORMSCNTLOP = FCB.PHYSXFERCNT.FORMSCNTLOP#;
BREAK CONTROL ( COMMFCB.BRKCNTL )
A-76
SIO: FILE CONTROL BLOCK (FCB) FORMAT
DEFINE
BRKLASTMODE = <O>#, ! last break mode from SETMODE.
COMMFCBABRKLASTMODE = COMMFCB.BRKCNTL.BRKLASTMODE#,
BRKHIT = <l>#, ! break key has been typed but not
! tested.
COMMFCBABRKHIT = COMMFCB.BRKCNTL.BRKHIT#,
BRKFLUSH = <2>#, ! flush $RECEIVE break message.
COMMFCBABRKFLUSH = COMMFCB.BRKCNTL.BRKFLUSH#,
BRKSTOLEN = <3>#, ! break stolen away by another
! process.
COMMFCBABRKSTOLEN = COMMFCB.BRKCNTL.BRKSTOLEN#,
BRKLDN = <8:15>#, ! logical device number of terminal.
COMMFCBABRKLDN = COMMFCB.BRKCNTL.BRKLDN#,
COMMFCBABRKARMED = ! break is armed.
COMMFCBABRKFCBADDR#;
A-77
SIO: FILE CONTROL BLOCK (FCB) FORMAT
A-78
Appendix B - ASCII CHARACTER SET
B-1
Appendix B - ASCII CHARACTER SET
B-2
Appendix B - ASCII CHARACTER SET
B-3
Appendix B - ASCII CHARACTER SET
B-4
ENSCRIBE STRUCTURED FILE BLOCK FORMAT
I
re,,
<record l>
I
I I
T T
l <record <num recs> - l>
1
I
,,... free space
I
byte <offset> from [0] to one word
free space
byte <offset> from [0] to one word
records <numrecs> - 1
C-1
ENSCRIBE STRUCTURED FILE BLOCK FORMAT
<rba>
A block is addressed by a doubleword relative byte addres9. In a
key-sequenced file, <rba> = OD points to the root (highest level)
index block; in a relative or entry-sequenced file, <rba> = OD
points to the first data block
To locate a given record in a key-sequenced file, the key value
supplied to KEYPOSITION is used to search to the block for a record
having a key field that matches
To locate a given record in a relative file, the <record number>
supplied to [KEY]POSITION is converted to a block address and record
number in the block as follows
<blocking factor> =
( <block length> - 22 ) / ( <create record length> + 2 )
<rba of block> =
<record number> / <blocking factor> * <block length>
<record in block> = <record number> ~,~ <blocking factor>
The format of a <record address> used to position to a record in an
entry-sequenced file is
C-2
ENSCRIBE STRUCTURED FILE BLOCK FORMAT
For key-sequenced files, if the entry = -20 then the block is in use
For relative files, if the entry = -20 then there are no free
records in the block
For entry-sequenced files, this entry is not used and is set to zero
<num recs>
is the number of records written in the block
<level>
is the tree level of the block. <level> = 0 means that the block is
a data block; <level> > 0 means that the block is an index block
<record>
is a data (if <level> 0) or index (if <level> > 0 record. For a
record "n",
<length n> = <offset to record n + l> - <offset to record n>
The format of an index record is
[O] [<length n - 4>] [<length n>]
I I I
key value { byte 0 I byte 1 : byte 2 I byte 3/I
<rba> of block at next level
C-3
ENSCRIBE STRUCTURED FILE BLOCK FORMAT
<off set>
is the offest, in bytes, to the beginning of "free space" or a
record. For relative files, the number of <offsets> is always the
same as the <blocking factor>
<block size>
is the block size in words. This is calculated as follows
<block size> = ( <create block length> + 1 ) I 2
C-4
APPENDIX D: FILE MANAGEMENT ERROR LIST
The table on the following pages lists the File Management System
errors individually by error number, giving a brief explanation of the
meaning of each.
The <device type> that is associated with an error, as returned by
the DEVICEINFO procedure is also given. The number corresponds to
devices as follows:
<device type>
0 = write to another process <process id>
1 = operator console ($0)
2 = $RECEIVE
3 = Disc
(3E = ENSCRIBE Structured File)
4 = Magnetic Tape
5 = Line Printer
6 = Terminal: Conversational or Page Mode
7 = Data Communications Line (ENVOY)
7.56 = Auto-Call Unit
8 = Punched Card Reader
9 = X.25 Access Method PTP Protocol
10 = Data Communications Line (AXCESS)
11 = Data Communications Line (ENVOY ACP)
12 = Tandem to IBM Link (TIL)
20-23 = Transaction Monitoring Facility (TMF)
26 = Tandem Hyper Link
0-1
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-2
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-3
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-4
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-5
APPENDIX D: FILE MANAGEMENT ERROR LIST
<error> description
l <device
type>
59 (%73) file is bad 3
code
I
I
D-6
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-7
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-8
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-9
APPENDIX D: FILE MANAGEMENT ERROR LIST
161 (%241) impossible event occurred for line state 7.*, 11.*
D-10
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-11
APPENDIX D: FILE MANAGEMENT ERROR LIST
1'-12
APPENDIX D: FILE MANAGEMENT ERROR LIST
D-13
APPENDIX D: FILE MANAGEMENT ERROR LIST
type>
250 (%372) all paths to the system are down any
251 (%373) a network protocol error occurred any
300-511 errors are reserved for process
application-dependent usage
D-14
APPENDIX E
E-1
APPENDIX E: ENSCRIBE CALL SYNTAX SUMMARY
E-2
APPENDIX E: ENSCRIBE CALL SYNTAX SUMMARY
E-3
APPENDIX E: ENSCRIBE CALL SYNTAX SUMMARY
E-4
APPENDIX E: ENSCRIBE CALL SYNTAX SUMMARY
E-5
INDEX
Access
completion order, with AWAITIO 3-17
description
structured files 2-8
unstructured files 2-18
mode
checking with OPEN 3-95
description 1-14, 3-8
setting with OPEN 3-89
path
description 2-9
setting with KEYPOSITION 3-76
setting with OPEN 3-97
setting with POSITION 3-100
positioning
by alternate key for structured files 3-72
by primary key for entry-sequenced 3-98
by primary key for key-sequenced 3-72
by primary key for relative 3-98
by rba for unstructured files 3-98
detailed description 4-43
random
for structured files 4-3
for unstructured files 4-16
relational, among structured files 1-11
rules
for structured files 4-2
for unstructured files 4-7
security
checking with OPEN 3-94
description 3-8
sequential
for structured files 4-2
for unstructured files 4-12
subsets, description 2-11
index-1
INDEX
Alternate key
attributes 2-14
CREATE parameter array 5-34
creation considerations
automatic update suppression 5-10
key length 5-9
key off set 5-9
key specifier 5-8
null value 5-9
uniqueness 5-10
description 2-8, 2-12, 5-11
file 2-13, 5-11
creation with CREATE 5-28
creation with FUP SET 5-14
loading 6-6
opening considerations 4-2
record description 5-11
for entry-sequenced files, description 2-15
for key-sequenced files, description 2-14
for relative files, description 2-14
illustration of 2-13
off set overlapping 5-9
update, automatic 1-12
suppression with CREATE 5-34
supression with FUP SET 5-14
Approximate, access subset 2-11
action during sequential reads 3-105
positioning mode, overview 1-10
ASCII character set B-1
Automatic
alternate key maintenance 1-12
supression 5-10
refresh, specification with CREATE 3-29
refresh, specification with FUP SET 5-14
AWAITIO procedure
completion chart 3-19
error recovery 3-17
FILEINFO response 3-18
flowchart 3-20
syntax description 3-14
index-2
INDEX
index-3
INDEX
CONTROL procedure
completion 3-4
operations 3-25
syntax description 3-24
CREATE procedure
completion 3-4
syntax description 5-28
Creating disc files 5-1
Current access path 2-9
after successful OPEN 3-97
Current key specifier 2-9
returned by FILERECINFO 3-56
Current key value
positioning action 2-10
returned by FILERECINFO 3-56
setting, description 4-4
specification with KEYPOSITION 2-10, 3-72
specification with POSITION 2-10, 3-98
Current position 2-10
after successful OPEN 3-97
change after READ, example 2-10
ENSCRIBE procedures that modify 4-4
update by KEYPOSITION 3-76
Current state indicators 3-8
status
after KEYPOSITION 3-76
after POSITION 3-100
after READ 3-106
after READUPDATE 3-114
after WRITE 3-134
after WRITEUPDATE 3-139
index-4
INDEX
DDL 1-22
Deadlock 4-26
Declarations, external
ENSCRIBE procedures 3-9
Deletion
file 3-101
DEVICEINFO procedure
completion 3-4
device types and subtypes 3-40
syntax description 3-39
Disc
device type 3-40
files: see File, disc
sectors 4-18
volume, finding filenames on 3-86 ..
EDITREAD procedure
syntax description 3-42
EDITREADINIT procedure
syntax description 3-46
End-of-file pointer
for structured files 4-5
for unstructured files 4-9
ENSCRIBE
disc files: see File, disc
file structures
structured files 1-3
unstructured files 1-13
list of features 1-1
procedure syntax summary E-1
relationship to GUARDIAN 1-1
structured file type comparison chart 2-15
syntactic conventions i-9
ENSCRIBE procedures
AWAITIO 3-14
CANCEL 3-21
CANCELREQ 3-22
CLOSE 3-23
CONTROL 3-24
CREATE 3-27
DEVICEINFO 3-39
EDITREAD 3-42
EDITREADINIT 3-46
FILEERROR 3-48
FILEINFO 3-51
FILERECINFO 3-56
FNAMECOLLAPSE 3-59
FNAMECOMPARE 3-61
FNAMEEXPAND 3-65
GETDEVNAME 3-70
index-5
INDEX
index-6
INDEX
index-7
INDEX
External declarations
ENSCRIBE procedures 3-9
Sequential I/O A-4
index-8
INDEX
index-9
INDEX
index-10
INDEX
FUP commands
BUILDKEYRECORDS 6-9
CREATE 5-24
functions described 5-12
INFO 5-26
LOAD 6-2
LOADALTFILE 6-6
RESET 5-25
SET 5-14
SHOW 5-23
FUP, running 5-13
Generic, access subset
action during sequential reads 3-106
positioning mode, overview 1-10
subset of a file, description 2-11
GETDEVNAME procedure
syntax description 3-70
GIVEABREAK Procedure, SIO A-16
Global declarations
ENSCRIBE procedures 3-9
GUARDIAN
file management error list D-1
relationship to ENSCRIBE 1-1
I/O device control operations 3-25
Index block 2-2
compression 2-3
description 5-6
specification with CREATE 5-28
specification with FUP SET 5-14
creation considerations 5-8
diagram 2-4
length, considerations 5-8
size, specification at creation
with CREATE 5-28
with FUP SET 5-14
Inserting records 1-23
considerations for structured files 4-3
with WRITE 3-132
Interface with INITIALIZER and
ASSIGN message, SIO A-48
considerations A-51
INITIALIZER-related defines A-48
setting file characteristics A-51
usage example A-52
index-11
INDEX
Key field
description 2-8
illustration 2-9
Key length
current, returned by FILERECINFO 3-56
description 5-9
specification at creation
with CREATE 5-28
with FUP SET 5-14
Key off set 5-9
specification at creation
with CREATE 5-28
with FUP SET 5-14
Key specifier 2-9
description 5-8
example 2-9
Key value, current 2-10
Key, alternate: see alternate key
Key, term defined 2-8
Key-sequenced file 1-4, 2-2
alternate key, description 2-14
creation
parameter array 5-33
with CREATE 5-28
with FUP 5-14
data block, illustration 2-4
data block: see data block
index block: see index block
number of reads per access 2-2
positioning 3-72
primary key, description 2-2
record
length, description 2-2
length, maximum 5-5
storage organization
data block 2-2
index block 2-2
KEYPOSITION procedure
completion 3-4
example
action of current postition 4-48
approx subset by alternate key 4-50
exact subset by non-unique altkey 4-53
exact subset by primary key 4-52
generic subset by primary key 4-51
random deletion with primary key 4-58
random update to non-existent record 4-56
random update, key-sequenced file 4-55
sequential read by pri-key w/delete 4-59
sequential read by pri-key w/update 4-57
index-12
INDEX
index-13
INDEX
ODDUNSTR
specifying with CREATE 5-28
specifying with FUP SET 5-14
Offset, key: see key offset
Open flags
returned from FILEINFO 3-54
setting with OPEN 3-88
OPEN procedure
by backup process 3-91
completion 3-4
condition code setting 3-92
example
approx subset by primary key 4-49
flags
returned by FILEINFO 3-54
setting 3-89
syntax description 3-88
OPENAFILE Procedure, SIO A-17
example A-22
flags A-20
Ownership, file
changing an existing file 3-127
current status returned by SETMODE 3-124
index-14
INDEX
index-15
INDEX
Procedures, ENSCRIBE
see ENSCRIBE procedures
Process
device type 3-40
suspension for file access 3-14
Purge
data within a file 3-25
file from system 3-101
PURGE procedure
completion 3-4
syntax description 3-101
Purge, security check 3-8
Random access
for structured files 4-3
for unstructured files 4-16
READ procedure
action following successful OPEN 3-97
completion 3-4
dependency on current position 2-10
example
approx subset by primary key 4-49
approximate subset by alternate key 4-50
exact subset by non-unique altkey 4-53
exact subset by primary key 4-52
generic subset by primary key 4-51
sequential read by pri-key w/delete 4-59
sequential read by pri-key w/update 4-57
syntax descriptiori 3-103
Read, security check 3-8
Reading records, general info 1-23
READLOCK procedure
completion 3-4
dependency on current position 2-10
example 3-109
setting lockmode 3-128
syntax description 3-108
READUPDATE procedure
completion 3-4
dependency on current position 2-10
example
random update to non-existent record 4-56
random update, key-sequenced file 4-55
syntax description 3-111
READUPDATELOCK procedure
completion 3-4
dependency on current position 2-10
setting lock mode 3-128
syntax description 3-115
index-16
INDEX
index-17
INDEX
SAVEPOSITION procedure
syntax description 3-121
Secondary extent size, specifying
with CREATE 5-28
with FUP SET 5-14
Secucity, file
changing of an existing file 3-127
checking 3-8
checking, access table 3-94
current status returned by SETMODE 3-124
Sequential access
for structured files 4-2
for unstructured files 4-12
Sequential access buffering option 1-20
example 4-6
specifying with OPEN 3-91
thorough description 4-6
Sequential I/O Procedures
call summary A-3
errors A-40
FCB Structure
description A-43
format A-70
Initializing the File FCB A-44
Interface with INITIALIZER and
ASSIGN messages A-48
index-18
INDEX
index-19
INDEX
UNLOCKFILE procedure
completion 3-4
syntax description 3-129
Unlocking
file 3-129
record
with UNLOCKREC 3-130
with WRITEUPDATEUNLOCK 3-140
UNLOCKREC procedure
completion 3-4
syntax description 3-130
Unstructured files
appending to end-of-file 4-16
characteristics 2-16
locking
with LOCKFILE 3-78
locking records
description 3-85
with LOCKREC 3-130
with READLOCK 3-108
with READUPDATELOCK 3-115
overview 1-13
positioning
description 2-18
with POSITION 3-98
random access to 4-16
relative byte addresses 2-18, 4-9
resident buffering 4-20
sequential access to 4-12
Updating records 1-23
procedure to accomplish 3-132
Usage Example, SIO
with INITIALIZER and ASSIGN message A-52
without INITIALIZER procedure A-56
index-20
INDEX
WRITEUPDATE procedure
dependency on current position 2-10
example
random deletion with primary key 4-58
random update, key-sequenced file 4-55
sequential read by pri-key w/delete 4-59
sequential read by pri-key w/update 4-57
syntax description 3-136
WRITEUPDATEUNLOCK procedure
completion 3-4
dependency on current position 2-10
syntax description 3-140
WRITEAFILE Procedure, SIO A-38
Writing records 1-23
considerations for structured files 4-3
with WRITE 3-132
index-21
READER'S COMMENTS
Tandem welcomes your feedback on the quality and usefulness of its publications. Please indicate
a specific section and page number when commenting on any manual. Does this manual have the
desired completeness and flow of organization? Are the examples clear and useful? Is it easily
understood? Does it have obvious errors? Are helpful additions needed?
Title of manual(s): _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __
FOLD~
FROM:
Name
Company
Address ~--------------------------------
City/State - - - - - - - - - - - - - - - - - - - Zip
NO POSTAGE
111111 NECESSARY
IF MAILED
INTHE
UNITED STATES
COMPUTERS, INC.
:.....c FOLD
STAPLE HERE
)Q TANDEM COMPUTERS INCORPORATED
1 9333 Vallco Parkway
Cupertino. CA 95014