Is A Advanced Pick
Is A Advanced Pick
Malcolm Bull
Malcolm Bull
Training & Consultancy Publications
© Malcolm Bull 1994
Telephone: +44-01484-713577
Fax: +44-01484-713577
ISBN: 1 873283 57 1
Whilst every care has been taken in the production of the book and all associated materials,
Malcolm Bull can assume no liability with respect to the document nor to the use of the
information presented therein.
The Pick system, Open Architecture and Advanced Pick are proprietary software products of
Pick Systems, Irvine, California, USA. This publication contains material whose use is
restricted to authorised users of the Pick system. Any other use of the descriptions and
information contained herein is improper.
The use in this book of the names PICK, ADVANCED PICK, OPEN ARCHITECTURE, ADDS
MENTOR, C.ITOH, FUJITSU, MCDONNELL DOUGLAS, PRIME INFORMATION, REALITY,
REVELATION and ADVANCED REVELATION, SANYO, UNIDATA, UNIVERSE, and all other
trademarks and registered marks is gratefully acknowledged and respected.
Contents i
Contents
Preface vii
Acknowledgements x
Conventions xi
17 Procs 17-1
17.1 Simple Procs 17-3
17.2 Buffers and stacks 17-8
17.3 Handling the buffers 17-10
17.4 P statements 17-12
17.5 Output: Displaying information 17-12
17.6 Control statements: GO / IF /X 17-14
Contents
23 Security 23-1
vi This is Advanced Pick
Appendix:
A Glossary Appendix-1
B Output processor commands Appendix-8
Runoff commands Appendix-9
D Heading / footing options Appendix-10
E Basic statements Appendix-12
F Basic functions Appendix-13
G Proc statements Appendix-14
H ASCII characters Appendix-15
I Advanced Pick <Ctri> keys Appendix-17
Index
Preface vii
Preface
For over two decades, the Pick system has been one of the leading
computer environments for commercial users. Since 1984, there have
been around 180,000 installations of the R83 Pick system in over 35
countries around the world. Since it was launched in 1988, there have
been around 150,000 installations of Advanced Pick, and with European
sales increasing at a rate of 18% per year and world-wide sales
increasing at a rate of 15% per year, the Pick system is surely the
foremost commercial computing system in use today and it is likely that
the Pick system which has been described as the greatest invention
-
There are Pick systems in almost every commercial and industrial field:
You can name any branch of commerce or industry, and there is sure to
be a Pick application system designed specifically for people working
there.
Surprisingly, you may not have heard about the Pick system until today.
So where did the Pick system come from? Where has it been hiding?
Why have you not heard of it? As you will see, the Pick system is a gentle
giant that has been working smoothly and quietly for a great many years
vill This is Advanced Pick
-
longer than almost any other computer system and has stayed with
-
to present the material in manner which is suitable for those who are
a
coming new to Pick and Advanced Pick systems, for those who are
migrating from R83 Pick systems to Advanced Pick, and for those who
have worked on Pick-like systems such as Reality, Ultimate, Prime
-
Pick.
The book starts with a brief look at the history of the Pick system. Then,
for those who have already used the R83 Pick system or Pick-like
systems, Chapter 2 is entitled:
and looks at individual aspects of the Pick system and summarises the
main differences which will be of interest to such readers. The rest of the
book takes a detailed look at the individual areas of Advanced Pick,
starting with the structure of the database and going on to look at each of
the tools of the system in turn.
As I'm writing this book, Advanced Pick is in a state of flux with many
features being added at each revision and each release -
including SQL
and GraPick and at the same time the scope and availability of various
-
tools are being changed. !t may well be that some of the features and
facilities described here are not available on your version of AP, it may be
that you have others not described here. For this reason, it is important
that you become familiar with Epick either the book or the on-line
-
Preface ix
system to ensure that you are using the full powers of your particular
-
You may be also interested in reading two other books which have |
written for use with Pick and Advanced Pick and similar systems:
© Access: the Pick enquiry language (Chapman & Hall 1991) ISBN 0-
412-37000-X
both of which look at their respective topics in more detail and depth than
we can go here.
Malcolm Bull
x This is Advanced Pick
Acknowledgements
|must thank several people for their help during the conception and the
gestation period of the present book:
Brian C Stone of Pick Systems in California, for giving me the idea and
for help in drawing up a list of contents, and for his support in keeping me
up-to-date with the latest AP releases.
Alan Pritchard of ALLM Systems and Marketing for keeping the idea
going.
Glyn Yarnall, Dawn Bowley and Derek Crosson of Pick Systems in the
United Kingdom for help and for answering my numerous questions.
Sam Anderson of Repfon Data for help and encouragement with the
production of the American edition of the book.
Then, there are a great many other people who have attended my training
courses, used my MB-Master self-tuition courses, read my books and
articles and my MB-Guide beginner's guides to various Pick and
Advanced Pick topics, people whose questions and suggestions have
indicated what interests them in their work and what areas of the system
need particular attention and explanation for beginners and newcomers
to the Advanced Pick system.
Conventions xi
Conventions
The following conventions have been used for the various paradigms and
examples presented in the text:
lower-case text
has been used to show the parameters which are to be supplied by the
user. The acceptable values for these parameters will be described
in the accompanying text.
UPPER-CASE TEXT
and any other characters, including parentheses and commas, are a
part of the TCL commands, Basic statements and keywords and must
be entered exactly as shown.
In order that the reader will recognise them as such, all commands and
statements are shown in upper-case even though Advanced Pick will
generally accept data and commands in upper- and/or lower-case.
<Ctri>
<Esc>
<Return>
<Break>
Many control keys and other characters are entered at the keyboard as
a combination of one or more of the above keys together with other
keyboard characters. In particular, the Update Processor and other
Advanced Pick tools use the <Ctrl> keys and sequences of <Ctrl> keys
for cursor movement and to invoke specific actions. Throughout the
book, have shown these <Ctrl> keys in forms such as:
|
"K
xil This is Advanced Pick
to represent the key which is entered by holding down the <Ctrl> key and
typing theK at the same time. have used this form in preference to the
|
underlined notation:
SORT STOCK BY PRICE WITH LOCATION "LN" AND WITH PRICE > "50.00"
DESCRIPTION PRICE LOCATION TOTAL VALUE
To identify the various roles played by those involved with the Advanced
Pick system, have used the following terms:
|
© System Manager: for the person who will be responsible for the
operational aspects of your Advanced Pick system. He/she will
perform duties such as carrying out file-save and file-restores, creating
new users and new accounts.
eo Userand End-user: for anyone who logs on to the system to carry out
his/her day to day work: inputting data, producing reports.
In a great many Advanced Pick installations, all these titles may overlap
with one or two users playing all roles.
Introduction ta Advanced Pick 1-1
By late 1965, Nelson and Pick had completed most of the enquiry
language elements of the system. It was then that the TRW project
expanded from a largely developmental system to a live, total systems
management capability for the US Army Cheyenne helicopter project.
In April 1969, Pick left TRW with the intention of implementing the
general-purpose computer model on a fairly low-cost computer, and after
a brief spell with a Califommian programming house, Syscom, he continued
the development work alone at the computer facilities of the University of
California-irvine using a Xerox Sigma-7.
In1972, Dick Pick set up Pick & Associates to apply the skills of a
number of people whom he had met at UCI, Syscom, and TRW.
Its ease of use and its power made the Pick system very attractive to
many companies who were trying to sell business solutions for use on
other hardware. In 1976, Pick Systems began to license other
organisations to use the Pick data model as a basis for their own systems.
The first of these was the Ultimate Corporation, selling the product for
use on Honeywell Computer Systems. Other licensees followed -
companies supplying systems which are based upon the Pick data model.
More recently, the major features of the Pick system have been made
available as software running within other operating systems; so you
might run Advanced Revelation on a DOS or OS/2 machine, or
UniVerse or UniData on a Unix machine. This portability means that, as
an organisation's hardware requirements expand, their Pick applications
can be ported to a vast range of hardware and computer systems.
o The Runoff text processing system for producing text, documents and
Introduction to Advanced Pick 1-3
The Pick system was to become one of the most powerful and attractive
means of performing commercial computing, and with its Access enquiry
language it resents a database management system whose power
was, and still is, almost unchallenged
Following the production and stabilisation of the R83 Pick release, Pick
Systems proposed a number of radical changes to the design of the
system. Indeed, so great were these changes, that they represented
more than just another version of R83 Pick, and this new system -
commands and invoke these just by typing the name by which they
-
user to pass from one file to another during file processing with the
Update Processor.
© Incremental file-save: to perform a file-save, saving only those items
which have changed since the last complete file-save was performed.
The items saved by an incremental file-save can then be loaded back
on to the system after a restore has been performed.
AP/DOS DG/UX
AP/Native Fujitsu DS 90
ATT NCR 3000 Hewlett Packard 9000
Bull DPX 20 HP-UX
Citrix IBM Power PC
Data General Aviion IBM AIX 3.2
DEC Alpha Windows NT IBM RS/6000
DEC OSF/1 ICL DRS 6000
Introduction to Advanced Pick 1-5
For almost thirty years, the Pick system has been one of the most
powerful and attractive computer systems for commercial and business
applications. In the 1980s, the R83 Pick system was extended to the
Open Architecture (OA) implementation, and later to the Advanced Pick
(AP) system.
Advanced Pick can be installed as a stand-alone system, of as DOS a
This Chapter is aimed at those who are migrating to Advanced Pick from
R83 Pick and similar systems. We shall first look at some of the
differences between R83 Pick and Advanced Pick, and then we present
some of the practical points to be considered when transferring your
systems to Advanced Pick.
2.1 Differences between R83 Pick and Advanced Pick
In Chapter 1, we saw that the major innovations of Advanced Pick
include:
File indexing
Level pushing
Macros
00000000000
Menus
The TCL stacker
The phantom processor
Incremental file saves
Transaction logging
The Output Processor
Additional processing codes
Sort Stock
and so on, are all equivalent. This is a potential mine-field and great
care should be taken when choosing file names and item-ids and
when deciding the nature of the data to be held on your files.
o Anull TCL command will display the time and date before the TCL
prompt. This can be enabled/disabled by the commands
TIMEDATE-ON / TIMEDATE-OFF.
o There are a number of commands which are provided to
enable/disable specific functions: TIMEDATE / BREAK-KEY / CASE
/ LEGEND / SPELLER / STACK / TCL-HDR / TYPE-AHEAD. In
general, these commands may be entered with N (on) and F (off)
options, or the explicit forms may be used:
TIMEDATE (N iS equivalent to rrmepaTz-on
and:
Timepate (F is equivalent to TIMEDATE-OFF
and, when used in conjunction with the <Caps Lock> key, this will
cause the system to behave very much like a standard R83 Pick
system.
© There are duplicate definitions and abbreviated forms for many verbs
and keywards both with and without hyphens. Thus, CREATE-FILE
may be entered as CREATEFILE. This is made possible by having
MD entries for both CREATE-FILE and CREATEFILE. However, the
alternate entries are not available for all hyphenated commands, so
it is probably better to stay with the full, standard and hyphenated
orms.
The format of the MD entries for the TCL verbs has changed.
Many TCL processes are now performed by Basic programs. This
means that the source code is gef-af-able and can be inspected to
see the true action of the activity, and in extreme circumstances
- -
2-4 This is Advanced Pick
the AP format.
Certain TCL commands assume the * if an item-list is omitted:
EDIT STOCK
COPY STOCK
CT STOCK
although care must be taken if the item-ids are ambiguous and could
be confused with datanames.
The TCL stacker is standard on Advanced Pick and will store an
unlimited number of TCL commands for recall and/or correction.
All the TCL commands issued by the users may be recorded on a file
for inspection. The commands including null commands when you
-
Any changes to the format are associated with the user-id and are
retained over LOGTO and TO commands and until the user logs off.
2.1.3 Access
For compatibility, the attribute definitions *AO, *A1 and so on, are siill
available, although they have been superseded by a new feature known
as temporary attribute items which allows you to use names such as
AO, A1, A2, A3 and so on (indefinitely), in Access sentences. These are
similar to the *A1, "A2 and *A3 names, except that the items A1, A2 and
A3 do not exist, they are constructed for temporary use by the Access
processor.
2.1.4 Select-lists / saved-lists
There are several changes to the ways in which select-lists and saved-
lists are handled.
Saved-lists may now be held on any file. Thus, the SAVE-LIST command
has the form:
SAVE-LIST {{file.name} list.name}
SAVE-LIST
%u
The other commands for handling saved-lists may also include the file-
name parameter. Note that, since DC-files are no longer required,
POINTER-FILE is a normal file.
An important feature is the concept of the primary select-list and the
secondary select-list. If a select-list is created in the familiar manner:
SELECT .
SSELECT .
GET-LIST ...
QSELECT ..
then this is considered to be the primary list. If the S option is included
in the command (or the SECONDARY keyword in an Access sentence),
then the list is; considered to be the secondary list. Certain TCL verbs
are able to use these two lists as the input list and the output list
respectively. For example, the sequence:
2-10 This is Advanced Pick
will select all items on FILEA starting with A and use these (the primary
list) as the item-list on the COPY command, and will then select all items
on FILEB starting with Z and use these (the secondary list) as the item-list
on the (FILEB destination line. Other commands which can use the
primary and secondary lists are:
COMPARE
COMPARE-LIST
thus allowing a program to pick up keys from the secondary list and
handle two select-lists at the same time.
There are several new verbs for handling select-lists and saved-lists:
COMPARE-LIST to compare the contents of two lists
o SORT-LIST to sort the keys in a saved-list.
FL to combine the keys in two saved-lists.
SELECT / ISSELECT to select all the items which are in the same
°o
The processing codes of R83 Pick are available as before, but Advanced
Pick introduces a number of additional codes. Many of these are used in
the familiar manner, as conversion codes and correlatives in attribute
definitions, and in the Basic CONV and OCONV functions, whilst others
are now encountered in file definitions and data-level identifiers, but
several are provided especially for use with the Update Processor to
control the nature and format of changes made to the data on the files.
The list of new processing codes is shown in Figure 2.2.
B FT MC/AN Mcs xc XR
CALL I MC/NA Mz Vv XD xs
cu ID MCAN MP x XI xT
DF IF MCNA MY XA xo XTx
There are many extensions and changes to the Basic language. Let's
look first at the physical program:
There are several new Basic statements and functions although some of
these -
such as the IN and OUT statements -
may be familiar to
programmers who have worked with Release 3.1 PC Pick.
The operators " and ** are available for exponentiation.
The operator is used to return the remainder after integer division.
\+
with an optional time-out specification for the time for which the
processor is to wait for the user's input. If data is entered within this
time limit, the THEN clause is taken; if no data is entered with the time
limit, the ELSE clause is taken.
© The KEY statement is used to search through a B-tree index to find
a key which matches (or is nearest to) a given search string.
© The LET keyword is optional on assignment statements:
LET A 100
The statements which handle the backing storage device may specify
the ONERR clause as an alternative to the ELSE clause. This is
clause is taken if there is an error during the execution of the
statement and returns a code via SYSTEM(0) indicating the nature of
the error.
The THEN/ELSE clauses may be omitted on the OPEN statement.
A form such as:
OPEN 'STOCK'
The READTL statement will read the label on the backing storage
device.
The READTX command will read a record from backing storage and
pass this to the program as a hexadecimal string. This means that
records which include Pick and Basic control characters such as -
The SORT function sorts the attributes (or values) of a dynamic array
into ascending, left-justified sequence.
The SOUNDEX function returns a four-digit code equivalent to a
specified string.
The SUM function will add together will add together all the adjacent
subvalues of a dynamic array and replace these with the result as a
single value; if there are no subvalues, then it will add together all the
adjacent values to produce a single attribute; if there are no adjacent
values, then it will add together all the attributes to return a single
numeric result.
The SYSTEM function has been extended.
The TCL statement executes a specific TCL command and,
optionally, returns the error-message numbers and parameters of the
messages generated by the command as the elements of a
dimensioned array. The format of the statement is:
TCL tcl.command {to dimensioned.array}
There are a number of changes to the ways in which accounts, files and
items are handled on Advanced Pick:
slightly.
o The nature of the POINTER-FILE has been demystified. It is now a
regular file and the items and saved-lists which are held there can be
handled just like items on any other file. The fist-handling commands
-
COPY-LIST, EDIT-LIST, and DELETE-LIST are still supported.
-
The values for the modulo and file size are unlimited.
The concept of separation has been discontinued. Ail files have an
implied separation of 1.
The item size is unlimited.
Each physical item is preceded by an 8-byte control field. This
indicates the length of the item, the nature of the item (whether itisa
D-pointer or not), whether it is held directly or indirectly, and whether
ithas been created, changed and/or deleted since the last file-save.
© Asitems are created / changed / deleted, a flag (called the dirty bits)
is set within the 8-byte control field to indicate this. When an
incremental file-save is performed, only these flagged items will be
saved. When a full file-save is performed, the dirty bits are cleared.
© Items less than 847 bytes in length are stored in the file space (as on
R83 Pick), but longer items are held indirectly in frames of virtual
memory with just a pointer to those frames being held in the file
space, much like items on DC files on R83 Pick.
o The structure of attribute definitions has been extended and more
attributes are available. Many of these are used by the Update
Processor to control the nature and format of the data which is
entered into a field. The general form of attribute definitions for use
with Access is unchanged.
o File synonyms, Q-pointers, are set by the familiar SET-FILE
command. This has a third element the local name by which the Q-
-
Moving to Advanced Pick 2-19
-
can be used to access files on other accounts.
It is now possible to have a Q-pointer which points to a Q-pointer.
This allows the System Manager to move files around much more
easily and more closely approaches the data transparency
requirement of a database.
2.1.8 Backing storage
There are several changes to the ways in which you can perform your
save and restore operations:
The general features and use of the spooler are essentially unchanged.
The following points are of interest:
o There is no limit to the number of jobs which can be handled by the
spooler.
Moving to Advanced Pick 2-21
Jobs are identified by the user-id instead of the name of the account
which submitted the job.
The L option has been discontinued with the STARTSPOOLER
command.
The ASSIGNFQ command:
ASSIGNFQ g p
A great many organisations will be moving from their existing R83 Pick
system to a new Advanced Pick system; others may be moving to
Advanced Pick from Pick-like systems ADDS, C.ltoh, Fujitsu, McDonnell
-
2-22 This is Advanced Pick
Douglas, Ultimate and so on. The actions to be taken are essentially the
same in all cases:
Step 1: Make magnetic copies of all the data and programs on your
existing system in a form which can be read by your Advanced Pick
system.
For R83 Pick systems, you can make a file-save, a set of account-saves
or T-DUMP copies of the files. For others, you may be able to use file-
save, account-saves. If in doubt, ask your supplier. In all cases, T-DUMP
files are compatible and can be used to transfer any data; this may be
tedious but it is fairly easy to automate the procedure by writing a simple
Basic program to produce the T-DUMPs and to read them back on to AP
ater.
Make sure that your magnetic copies are reliable. To be sure, make two
copies of everything.
If your old system is to be available alongside the Advanced Pick system,
it may be possible to use proprietary software, such as Mainlink, PK
Harmony, Termite, or Viaduct, or even the Advanced Pick IMPORT
command, to transfer the data.
Since your Basic programs will have to be recompiled when they have
been moved to Advanced Pick, there is no need to retain the object
programs of your old system.
Step 3: Load the data files from your old system on your Advanced Pick
system.
where nis the size of frames on the old system. The size option will
instruct AP to make the appropriate adjustments to the modulos of
the files as they are restored.
ACCOUNT-RESTORE aaaa (n
where aaaa is the name of the new account, and n is the size of
frames on the old system.
You may also need the C option if you are restoring from a
Compatible system (such as McDonnell Douglas or Ultimate).
© Restore individual files by performing SEL-RESTORE from a file-save
tape or an account-save tape, and/or ...
© Restore individual files by performing T-LOAD from a T-DUMP tape.
© You should not attempt to restore the system accounts or files such
as:
SYSTEM
ACC
BLOCK-CONVERT
EXECUTE-CONTROL
PROCLIB
SYSPROG
2-24 This is Advanced Pick
SYSTEM-ERRORS
and so on, as they already have their counterparts on Advanced Pick.
If these are inadvertently restored, you should delete them later.
This uses the contents of the Advanced Pick NEWAC file to convert the
verbs and other items on the MD of an account to the AP form. The
process is invoked from the DM account by a command of the form:
UPDATE-ACCOUNT aaaa
or:
UPDATE-MD aaaa
which will allow you to create a user-id equivalent to the account being
updated. The new user definition includes a standard setup sequence of
TCL commands:
SP-ASSIGN
BRK-DEBUG
ESC-DATA
SET-SYM GSYM
Step 5: For each account, produce a list of the CLASHES,aaaa file and
check whether any of the changes will affect your applications.
Moving to Advanced Pick 2-25
This is particularly important if you are migrating from a system other than
R83 Pick, on which you may have been using features and facilities which
are not available on generic Pick.
@(-n) functions
EXECUTE / PERFORM statements
INCLUDE statements
SYSTEM functions
and any functions such as GROUPSTORE, FIELDSTORE which are
not available on AP. Lists of the AP Basic functions and Basic
statements can be found in the Appendix.
When you recompile your programs, you should remember that the
BASIC verb is case-sensitive (recognising the names TOTALS, Tofals
and fofals as three distinct variables), whereas the COMPILE verb is
case-insensitive (regarding all three names as the same variable). If
your programs use lower-case variable names for any special
purposes, you should use the BASIC verb.
© R83 Pick Procs are completely compatible with Advanced Pick.
Procs for systems such as McDonnell Douglas and RPL will have to
be rewritten if they use features and facilities which are not available
on generic Pick. A list of AP Proc statements can be found in the
Appendix.
© Assembly language routines. These will have to be rewritten in
almost all cases. On Advanced Pick, the Assembler and Assembly
language is now offered as a separate product.
© User-exits are also included under this heading and you should check
2-26 This Is Advanced Pick
low-level interfacing with the hardware and the disk are no longer
-
supported.
o If you are using software such as Jef, CompuSheef+, Accu/Plot,
System Builder, SB+ and so on, you will have to contact your supplier
about the compatibility with Advanced Pick.
\f you are migrating from a system other than R83 Pick, you should check
the CLASHES file for any TCL commands, Access features, and verbs
which are not available on Advanced Pick. Any such verbs should be
rewritten using the AP equivalents.
2.3 Summary
System architecture
Dos / Unix
Advanced Backing storage
Pick
Terminal
Printers
Terminal
illustrated in Figure 3.2. Here, Advanced Pick runs just like any other
DOS or Unix program, alongside other DOS and Unix programs, and ~
through the native operating system has full access to the range of
-
Whatever its nature and whatever its size, every Advanced Pick system
is made up of the same basic components:
1) The CPU: the central processor unit and the system itself.
2) The memory or RAM: this holds all the data and programs which are
being processed by the various users at any moment.
5) The backing storage device: this is used to pass data from one
system to another and to produce back-up copies of the system and
its files for security purposes. The backing storage devices may be
any combination of magnetic tape(s) and/or floppy diskette(s).
6) The hard disk / fixed disk: all the programs and the data files which
are created and processed by the individual users and those used by
Advanced Pick itself are held permanently on a hard disk. This disk
storage space is shared by all users of the system, and the actual
nature and size of the available disk space depends upon the
configuration of your particular system. The virtual memory feature of
Advanced Pick means that this disk space is regarded as an extension
of the memory space.
3.1 Ports
System Architecture 3-3
When you buy an Advanced Pick system, you specify the number of ports
which you need. A 1-port system (sometimes called a 1-user system)
can only have one user at a time, a 6-port system may have up to six
simultaneous users, and so on.
Although not exactly equivalent, the terms line and PIB are often used
with the same meaning as port.
Advanced Pick will work with virtually any sort of terminal device, and you
will find dumb terminals such as Wyse 30 and intelligent terminals
- - -
such as PCs, and although most equipment now comprises screen and
keyboard, you may even find old printing terminals. It is also possible to
link specialised equipment, such as point-of-sales cash registers, to your
Advanced Pick system.
3.2 Printers
Two types of printer interface are used: serial and parallel, Any printer
can be attached to any suitable port on the Pick system, and any number
of printers may be linked to the system, provided that there are ports
available. The STARTPTR command is used to declare a particular port
as a printer and to associate a specific output queue with that printer.
The most important part of the hardware on the Advanced Pick system
is the hard disk. The virtual memory feature of the system views the
hard disk as an extension of memory (or RAM), and allows the users to
access any part of the database as and when required.
In physical terms, the hard disk comprises one or more circular metal
plates mounted on a central axis and sealed inside an airtight unit. Each
surface of these plates is viewed as a series of concentric tracks. Each
track is divided into a number of sectors. When you buy your hardware,
you will specify how much disk space you require. When you are
installing the system, you can specify exactly how much of this disk space
is to be made available to Advanced Pick.
1 2 3 4
5 6 7 8 9
10 11 12 13 14
3.3.1 Frames
disk with DOS, or there may be faulty tracks on your disk and Advanced
Pick would skip these when drawing up its map of the frames of the disk.
© System frames: this is the area in which the programs for all the
standard Advanced Pick software are held; these are usually known
as the ABS frames (absolufe, because they are always held in the
same position). Special PICKWARE products, such as Accu/Plot,
CompuSheef+, and Jet, may also use these frames for their own
special routines, and a number of frames are set aside for users to
load their own assembly language processing routines. This system
area typically occupies about 2048 frames.
PCBs and work space: the primary control blocks and the work
space for each available port hold registers and other control
information relating to each individual port on the system. Each user
has control of the system for a short period of time (a time-slice)
during which he/she can do whatever work they wish. At the end of
the time-slice, that user's work is suspended and the next user is given
a time-slice. The PCBs and the work space store information about
what each port is doing and enable each user to continue his/her work
when their next time-slice comes around. In Figure 3.5 (a), we see
that the PCB for port 0 starts at FID 2048.
© User-files: next comes that area of disk which holds the data files
used by the system and the users. The MDS file holds details about
all accounts on the system and is normally the first file in this area,
and is followed by the MD for the individual accounts and their files.
The start of this area is known by the symbolic name SYSBASE and
this is where the MDS file begins. In Figure 3.5 (a), we see that the
MDS file starts at FID 2394.
3-6 This is Advanced Pick
© Overflow space: beyond the area occupied by the files comes the (as
yet) free and unused area of disk which will be used whenever new
files are to be created and when an existing file requires more frames
to accommodate additional items and as files and items grow in size.
Look at the report shown in Figure 3.5 (a); here, we see that, when
this report was produced, there were 8234 frames available for
overflow out of a total 28537 frames.
There is no fixed boundary between the user-files area and the overflow
space. When a file-restore operation has been performed, the disk is
fairly tidy with all the user-files grouped together and one large chunk of
overflow space following. However, in time, the user-files take over parts
of the overflow space as new files are created and as existing files
expand, and overflow frames occur in the user-file space as existing files
and items are deleted.
There are several commands for monitoring disk usage and the
fragmentation of the disk space, and for interrogating other details about
your system. One of these, the WHAT command, will produce a report
such as that illustrated in Figure 3.5 (a). This tells us that on this
particular system:
file or if an existing file grows, the five frames 6401 to 6495 are not used,
and so on.
When looking for disk space to create a new file, the system will scan the
table of available frames, looking for the smallest gap into which the file
can be placed, and then allocate these frames to the file and remove
them from the table. As an existing file grows and needs more disk
space, this will be grabbed, frame by frame, from the pool of available
frames.
available disk space becomes too fragmented and there are a great
If the
number of small blocks available, it may prevent the creation of new files
and may make overflow of existing files inefficient. In such
circumstances, a file-save and file-restore should be carried out.
All data and programs are held on the hard disk. This includes the
standard files and the software provided with your Advanced Pick system,
and also the data and programs which the users create for their own use.
Whenever you wish to execute a program, change a data record or
simply inspect a data record each program and each piece of data must
-
3-8 This is Advanced Pick
Let us imagine that you wish to carry out the wages calculations for your
company. You, the user, simply type in a command indicating the name
of the file of programs and the name of the particular program which you
wish to use:
Advanced Pick then consults its files to discover the disk location of the
PROGRAMS file, then it does a calculation to determine the frame at
which the WAGES program is to be found; finally, the required frame(s)
are read from disk and copied into memory, and the WAGES program
can then be called into action. The same thing happens if you give a
command such as:
CT STAFF 1234
to inspect the record for employee number 1234 on the STAFF file (we'll
see later that the CT command copies a record to the terminal screen):
Advanced Pick consults its files to discover the disk location of the STAFF
file, then it does a calculation to determine the frame at which the record
for employee 1234 is to be found; finally, the required frames are read
from disk and copied into memory, and from there the required record
can be picked out and displayed on the screen.
As you and the other users carry out their work, frames of information are
continually being read into memory and held there for inspection and
amendment by the users.
In order to improve the speed of the system, frames are not written back
to disk each time they are changed or when they are no longer required;
instead, only updated frames are written to disk, and this is done only
when memory becomes filled with changed frames and space must be
made for new frames of data to be brought into memory from the hard
disk. All updated frames are also written to disk when the system is
closed down.
but the original frames on disk would not. To minimise the risk of losing
data in the event of a power failure, when there is a quiet period with no
user activity, Advanced Pick utilises the time by copying any changed
frames back to disk.
To represent more closely the true Pick situation, our analogy must be
modified slightly: instead of bringing the actual page from the shelf to the
desk, the monk makes a copy of the page (leaving the original on the
shelf) and brings the copy to his desk [he reads the frame from disk into
memory]. Now, he need only return an old page to the shelf [write a
frame back from memory to disk] if he has made any corrections to it
whilst it was on his desk top.
In practice, there will be several monks studying at the same time [several
users processing simultaneously]. They all share the same desk top and
all have access to the pages which they and the other monks have
fetched from the shelves. Throughout their study, the pages on the desk
[the frames in memory] are continually being swapped between the
shelves and the desk.
1) The system must check to see whether the required frame is already
in memory.
3) If the frame is not in memory, the system must fetch the frame from
disk. This is a time-consuming activity.
4) The system must then choose a memory buffer where the new frame
can be loaded into memory. The first choice will be to use a memory
buffer which has not been changed.
6) Finally, the system will copy the new frame into the chosen memory
buffer.
This act of fetching a new frame from disk is known as a frame fault. As
you see, a frame fault involves a complex sequence of events and can
take an appreciable time to perform. The Systems Analyst who is
designing files and programs will attempt to minimise the number of
frame faults which are required and thereby speed up the processing.
You can see this process for yourself if you issue a command such as:
COUNT STOCK
to look at a file which you have not used today. The light on the disk drive
will flash furiously and you will have to wait moment as the frames
a
which hold the STOCK file are read into memory. If you then issue the
same command again, there will be very little disk activity and you will get
the answer almost immediately, since the frames which hold the data of
the STOCK file are already in memory.
All those who are using the Advanced Pick system at any one time are
placed in a queue, first come, first served; the user at the head of the
queue is allowed full control of the system when his/her turn comes
around. Typically, each user gets a time-slice or quantum of a few
milliseconds in which to carry out some of his/her work. This is the
maximum time which is allowed for each process before it is interrupted
and placed at the end of the queue of users waiting for their turn. A time-
slice may be interrupted and the user placed at the end of the queue in
other circumstances:
o A frame fault may occur in which the user's process has requested
data which has to be read from disk. The process can only continue
when the required data is in memory and the time-slice is abandoned
-
allowing some other user to have a go until that time.
-
© The process may have issued a SLEEP command to give p its time-
up
slice.
o The process may have executed a command which expects the user
to enter data at the keyboard and can only continue when the user
has entered that data.
We use the term backing storage to refer to these devices because they
are primarily used to make backup copies of the contents of the hard
disk; you'll make these copies by means of the file-save and the account-
save utilities. Magnetic tape and diskette can also be used to archive data
-
such as last year's invoices which are no longer required on the live
-
system, and to transfer data between one Pick system and another.
There are a number of TCL commands and other facilities for handling
the backing storage devices, as we shall see in Chapter 20.
3.5 Summary
The hard disk is used to hold all the data and files which are needed by
Advanced Pick and the users. The sectors on the hard disk are
interpreted as frames on the Pick virtual memory system, and are brought
into memory as and when required.
The backing storage devices are used to make backup copies of the
system, to hold data which is not required on the live system, and to
transfer data to other Pick systems.
File structure 4-1
File structure
All the information which you and your users will process on Advanced
Pick is organised as a set of files. You will use several files in your work:
there may be a STAFF file to hold details of the company's employees;
a CLIENT file to hold details of the company's customers, a
SALES-LEDGER file to hold details of the orders which your clients have
placed for your company's products and services, BOUGHT-LEDGER
file, SUPPLIER file, and many more. There may be any number of files
on your system.
Each file holds a number of individual items or records. Each item can
be created, looked at, changed, and/or deleted quite independently of
the other items on the file. Thus, the STAFF file may have one item for
employee number 1234 (John Dark), one for employee 2009 (Naren
Josh), another for employee 2531 (Mary Wilkinson), and so on. There
may be any number of items on a file. Figure 4.1 shows how we might
visualise a file as a set of items.
Within each file, each item is uniquely identified by its item-id. So, if want
to look at John Dark's record,
would ask for the item which is
identified by item-id 1234. The -
STAFF
item-id is a unique identifier for that -1234
item. Typically, the items on the DARK
STAFF file would use the JOHN
employee number as their item-id, -2009
and the items on the CLIENT file JOSH
might use the client account NAREN
number as their item-id. The -2531
Systems Analyst who designs the LODGE
file will decide what information is MARY
to be used as the item-id of each 34 GLEBE CLOSE
file. LASHLEY
wv3 5GK
2734
Each item is made up of a number
ADMIN
of attributes or fields. Thus, the
WALKING] READING
STAFF file items in Figure 4.1 WILLIAM
contain one attribute for the JOANNA ] MICHAEL ] NATHAN
sumame, one attribute for the
given names, one for the data of
birth, and so on. The Systems
Analyst who designs the file will Figure 4.1: A file of staff information
decide what attributes will be held,
and how these attributes are to be
organised within each item. In
Figure 4.1 and Figure 4.2, the first attribute of the STAFF file is the
4-2 This is Advanced Pick
employee's surname, the second holds the employee's given names, and
so on. There may be any number of attributes in an item. All the items
on any particular file will have the same number of attributes and these
will always be in the same sequence.
Now, let's see how this information is recorded physically on the hard
disk.
Figure 4.2 shows two items on the STAFF file. Figure 4.2 (b) shows how
these would be held, each as a string of characters on the disk.
null. Note that there is still an attribute-mark for this null attribute.
Some attributes, such as the hobbies (attribute 8) and the names of the
File structure 4-3
children (attribute 10), may have more than one value. Such an attribute
is said to be a multivalued attribute. The individual values which make
up the attribute are separated by the value-mark, shown here as the ]
character.
of-item marker -
consisting of the attribute-mark followed by the
segment-mark (character 255) indicates the end of each physical item.
As a double-check on the consistency of the data, each item is preceded
by a control field which records the length of the item, as we shall see
later.
-
STAFF file Frame: 6298 -
1234
3045 222222
RR SESS STRESS
0079
1034
When the System Analyst creates the STAFF file, he/she will indicate how
much space is required for the file on the disk; a file may occupy one or
more frames of disk space. Advanced Pick will then search for a block
of disk space of the required size, and set these frames aside for sole use
by the STAFF file. Let's imagine that the analyst has asked for just one
frame of disk space, and that Advanced Pick has looked through the list
of available frames like that in Figure 3.5 (b) and allocated the frame
- -
6298 for the STAFF file. The system will then create an item on the MD
-
the master dictionary which indicates that the STAFF file is to be
-
found at frame 6298. The STAFF items may then be created and added
to the STAFF file; this will normally be done by an application program or
by the Update Processor. We can think of the items as separate strings
of data held in the frame of disk space which has been allocated to the
file, as in Figure 4.3; the shaded area represents the data in that item.
A technical note: If we were to represent the control field mentioned
4-4 This is Advanced Pick
earlier by c, then we might find that the frame which holds the STAFF file
looks more like that in Figure 4.4. As you see, the items are not held in
any particular sequence. As new items are created on the file, they are
added on at the end of the file. When an existing item is changed, it is
moved to the end of the file.
and, in order to find this particular item, Advanced Pick must first go to the
MD to find the frame where the STAFF file starts (this is frame 6298), and
then go to frame 6298 and scan through the contents, looking first at item
1234, then item 2009, then item 2531 and so on uniil it finds item 0079.
The string of characters which represent this item will then be copied from
the frame and passed to me so that can change it; when tell the
| |
Update Processor that have made all the changes want, Advanced
| |
Pick will look at frame 6298 again and remove the original string of data
from the frame, write the new string back (at the end of the file), and the
whole file will then be written back to disk.
Each frame can hold 1000 bytes of information (or 2000 on some
systems), and it is quite likely that, as we add more and more items to the
file, the original frame will overflow. In this situation, Advanced Pick will
look around the disk for another unused frame (let's imagine that it
chooses frame 6414) and it will then associate this with the original frame
6298. The situation might then look like Figure 4.5.
STAFF file Frame: 6298
1234
File structure 4-5
Go to frame 6414 4
Frame: 6414
4532
4300 38
As we add more and more items to our file, this overflowing can continue
indefinitely, as illustrated in Figure 4.6 (c) of the next section. This means
that, if we have a large number of items on the file, it will require a large
number of frames to hold the data, and each one of these will have to be
brought into memory and scanned when we are looking for an item and
when we are changing an item; as we saw when we were talking about
frame faults, this could take a long time.
Although the physical frame is actually 1024 bytes in size (or 2048 bytes
on some systems), on ly 1000 (or 2000) bytes of each frame are used to
record the user's data. The final 24 (or 48) bytes of each frame are used
by Advanced Pick, as we shall see in moment.
a
As items are added to the file and the items themselves increase in size,
the data will take up more and more of the available space, and there
may not be sufficient space in the frame to accommodate the data.
When this happens, Advanced Pick looks around for an unused frame
and writes the remainder of the data in this overflow frame, setting links
or pointers which enable the system to navigate from the base frame to
the overflow frame. This is illustrated in Figure 4.6 (b).
As the file grows further, more and more overflow frames will be added
to the end, each pointing to the next, as you can see in Figure 4.6 (c).
4-6 This is Advanced Pick
backward links in these diagrams, but we shall see them later when we
look at the actual frames which hold the items.
show which items are held in which particular frame each time you need
-
to find an item, you have to start at the base frame and read all the way
through all the intervening frames until you find the item you need. So on
average, you have to scan half the items on the file to find any specific
item, and if you are creating a new item, then you have to read all the way
through the file, just to be sure that the item doesn't already exist, and
then to append the new item to the end of the file.
Each time Advanced Pick has to move through a file, it has to read the
first frame, pick up the linkage information, move to the next overflow
frame and so on until the frame holding the required item is found. Since
itis only possible to read one frame at a time, this is very time-consuming.
The more items there are, the longer it takes.
To minimise this problem, Advanced Pick extends this model for a file.
Instead of having just a single frame or a single group of frames as we
have in Figure 4.6, a file may consist of several groups of frames. A file
may be created with any number of groups. The file in Figure 4.7
consists of three groups. The number of groups in the file is known as the
modulo of the file; so Figure 4.7 shows a file with modulo of 3. The
a
5r-
0
-8998 -
r- 8998 -
-9564 -10634
2 2
(a) (b)
How does Advanced Pick decide where to hold each item? When an
item has to be written to the file, Advanced Pick takes the item-id and
performs an arithmetic calculation on it. The process is called hashing,
and the result of the calculation will be 0 or 1 or 2. According to this
result, that particular item will be written into group 0 or group 1 or group
2 of the file; each item is allocated into one of the three groups. When an
item has to be read from the file, the same hashing calculation is
performed and the contents of the appropriate group (0 or 1 or 2) are
scanned for the required item, as in the earlier single-group model.
All Advanced Pick files are organised in this way, the single-group model
wnich we discussed first is simply a special case of a file with a modulo
off1 1.
As more items are added to the file in Figure 4.7, and as existing items
grow, each group will overflow as necessary to accommodate the items
which hash into that group. Each group behaves rather like a separate,
independent physical file, and more overflow frames are tacked on to
each group as the space occupied by the items in the group increases.
The overflow behaviour of one group in quite independent of that of the
other groups in the same file. Indeed, in any particular file, some groups
may have many overflow frames whilst other groups - in the same file -
may have no overflow at all and some groups may even be empty! In
Figure 4.7 (b), we see that the first group of the file overflows into one
more frame (FID 6401), the second group doesn't overflow at all, and the
third group overflows first into frame 9564, and this overflows further into
4-8 This is Advanced Pick
frame 10634. Do you see how the overflow frames are scattered about
the disk? It's just a matter of whereabouts on disk Advanced Pick can find
a single, unused frame when it needs an overflow frame.
For the reasons mentioned above, the ideal situation is that there should
be no overflow in the file and that Advanced Pick only has to read one
frame in order to find a particular item; this means that the items can be
accessed as quickly as possible. One solution to this is to create the file
with a suitably large modulo. In general, the more items there are in the
file, the larger will be the modulo. We discuss the process of choosing
modulos for files in Chapter 5.
52 0 52
[| L 3 51 x 10 510
-2 50 x 100 5000
-1 49 x 1000 49000 +
Divide this by 3 3 |
54562
18187 remainder 1
File structure 4-9
Advanced Pick will first look to the MD for the item relating to the STAFF
file. Let's imagine that this shows that the STAFF file begins at frame
8996 and that it has a modulo of 3, as in Figure 4.7. Having found the
modulo, the system can carry out the hashing algorithm, as above, and
find that the item 1234 should be in group 1. Adding this 1 to the base
frame FID (8996), Advanced Pick knows that it must then read frame
8997 and scan through the group of frames starting there to find item
1234.
On Advanced Pick, the algorithm always works in the manner described
here; it is unchanging and unchangeable. This means that you cannot
modify, say, the weighting factor of 10, nor can you make any other
changes to the algorithm, either for a particular file or for all your files.
Incidentally, although my examples use item-ids 1234 and AB/9000, it is
most likely that all the item-ids on a file will be of the same form. Thus,
the STAFF f le may have item-ids such as 1234, 0079. 4300; a
on.
On all Pick systems, a file is more than just a section of disk which holds
the data. There are other entities and concepts which are associated with
the file space itself.
4.2.1 Dictionaries
In most cases, a file will consist of two parts: the dictionary section and
the data section. To the user, the more important of these is the data
section which holds the true data of the file. The other part of the file is
the dictionary section usually known as the DICT. The DICT section of
-
a file normally holds the items which define the vocabulary and the
datanames which will be used in Access sentences which handle the data
section of the file.
] CLIENT
4-10 This is Advanced Pick
Both the DICT section and the data section are set up when the Systems
Analyst creates the file. This might be done with a command such as:
CREATE-FILE CLIENT 1 3
showing that the DICT section of the CLIENT file is to have a modulo of
1, and the data section is to have a modulo of 3. Since there will probably
be fewer items on the DICT section of the file, this will normally have a
smaller modulo than the data section.
The two parts of the file the DICT and the data section are physically
- -
quite separate sets of frames on disk; they may be quite close together
or they may be some distance apart. When a file is created, both
sections are completely empty, except for a pointer which is set up on the
DICT; this is the CLIENT item which I've shown in Figure 4.9. Let me
explain why this is needed.
to create the CLIENT file, Advanced Pick will look around for a single
unused frame which can be used for the DICT section (let's imagine that
it allocates frame 54321 for this), and then it will look for a block of three
contiguous frames for the data section (let's imagine that these start at
frame 87654). It will then set up pointer items shown in Figure 4.10.
MD
File structure 4-11
CLIENT D*54321°1
-
DICT section of CLIENT file FID: 54321 -
CLIENT D°87654°3
-
Data section of CLIENT file FID: 87654 -
FID: 87655 -
-
Because the first attribute of these MD
items contains the letter D, these
items are often called D-pointers.
c-
item-id CLIENT and points to the - an of
pict section of CLIENT file
CLIENT file
DICT section of the file; the D-
pointer on the DICT of the
CLIENT file has the item-id
CLIENT and points to the data
section of the file. Each D-pointer af CLIENT
Data section of CTTENT
holds the FID of the base frame
and the modulo of the file to
which it points. A simplified
version of Figure 4.10 is shown in
Figure 4.11: Linkage to find a file
Figure 4.11; here, each large box
represents a file, and each small,
open box represents a D-pointer
which identifies (points to) a file section.
You may handle the information held on either section of a file. If issue
an Access sentence such as:
4-12 This is Advanced Pick
using the word DICT before the name of the file, this will produce a list of
the items (including the data-level identifier and any Access attribute
definitions) which are held on the DICT section of the CLIENT file, and
if issue a sentence such as:
|
LIST CLIENT
this will produce a list of the items (the data records) on the data section
of the CLIENT file.
For most purposes, the DICT section of a file and the data section of the
same file are two separate and distinct areas; the only connection
between them is the logical linkage which is implied by the D-pointer.
C-
data or CLIENT data in which all
the items have the same form;
some files will contain
miscellaneous collections of
unstructured and free-format
information such as text DICT section of myYfyrs file
af MYDOCS fila
documents, Procs and other
information which it might not be
appropriate to use with Access. If
you did not wish to use the full Figure 4.12: A DICT-only file
facilities of Access with such a file
then you probably wouldn't need a
separate dictionary section (to
hold the Access dictionary definitions) and you could create the file with
just one section, using a command such as:
CREATE-FILE DICT MYDOCS 7
This would create a file organised like that in Figure 4.12. Note that the
single section is considered to be a DICT section because, like all DICT
sections, it hangs directly from the MD. | could then process the
MYDOCS file with commands such as:
LIST DICT MYDOCS
or:
LIST MYDOCS
Such DICT-only files are not very common. The only advantage of
having a DICT-only file is that you save the space which would be
required for a dictionary which you would not use. | could have created
the file in the normal manner:
File structure 4-13
CREATE-FILE Mypocs 1 7
Just as it is possible to have a file without a data section and files with a
data section, it is also possible to have a file with several data sections.
This might be useful in situations where you have several distinct sets of
data which must be kept separate but which can all use the same
dictionary. For example, once worked on a system for a client who
|
needed to hold the data concerning the prices and other details of cars.
Each month, the client received a diskette with the current prices for all
models of new and used cars on the market. When he received
February's prices, he wanted to hold these on the system but he still
needed to retain January's prices.
MD
CARS
DICT of CARS
JANUARY
FEBRUARY
][
Figure 4.13: Several distinct files
Itwould have been perfectly realistic to create a new file to hold each
month's figures, but in order to avoid the maintenance problems of
-
having two (or 12 or more) identical copies of the dictionary of the file -
|decided to have a single file called CARS which had a separate data
section to hold each month's figures. In this situation, the files were
organised as in Figure 4.13. To create these files first created the DICT-
|
as each new monthly figures were loaded. The contents of the DICT
could be handled by sentences of the form:
and the contents of any particular data section by references of the form:
CARS, month
synonym called CURRENT which was changed to refer to the latest file
and could be used in sentences such as:
4.3 Accounts
|have mentioned that there may be any number of files on your system.
However, for security reasons, it is unwise to let every user have access
to every file. Therefore, the files of any Advanced Pick system are
grouped into accounts, and each account holds just the files that its
users need. Thus, the STAFF file, the PAY-RATES file and the
TAX.CODES file may be held by the WAGES account; the CLIENT file,
the ORDER file, the PRICES file and the STOCK file may be held on the
SALES account, and so on. To use the STAFF file, you must log on to
the WAGES account, and to use the CLIENT file, you must log on to the
SALES account.
Each account is identified by its MD, its master dictionary. When you log
on to Advanced Pick, you will first be asked for your user-id (to make sure
that you are an authorised user), and then you will be asked which MD
you want to use; in other words, which set of files you want to use.
MDS
WAGES
DM
i]
File structure 4-15
The information about each account that is, each master dictionary is
- -
held on a file called MDS. For each account, the MDS file holds an item
which has the account name asSs ts item-id and which contains information
about that account: the password, security codes, and most important
-
of all the FID and the modulo of the master dictionary of the account.
-
Figure 4.14 shows how we might visualise the MDS file and the way in
which the individual items there point to each MD. There are just two
accounts on this system: WAGES and DM.
The D-pointers on the MDS file which point to each MD are known as
account definitions or file defining items. We shall have more to say
about the structure of account definitions when we see how accounts are
created and maintained.
Anyone who has worked with R83 Pick will know that the system comes
with a number of standard accounts: SYSPROG, ACC, BLOCK-
CONVERT, SYSTEM-ERRORS and others. This is not the case on
Advanced Pick which comes with just one account: DM, the Data
Manager account. This account owns all the standard files which were
-
MDS
MD
Each box in Figure 4.15 represents a file, and the lines connecting the
boxes represent the linkage by which an item (a D-pointer) on one file
enables Advanced Pick to locate a file ower down the diagram. Each D-
pointer holds the base FID and the modulo of the file to which it points.
The dotted links without boxes remind us that there may be any number
of accounts (MDs) on the system, and any number of files on an account,
and any number of data sections for a file.
The file called MDS is the most important file on any Pick system, and
holds one item for each account on the system. This is a D-pointer and
identifies the MD, the master dictionary, for that account.
A file may have one data section (as file A in Figure 4.15), it may be
DICT-only file with no data section (file B), or it may have several data
sections (file C).
There are some esoteric technical points which you might appreciate
from Figure 4.15:
o AD-pointer whether account definition or file definition or data-level
-
STAFF
Note that the USERS file is not an integral part of Advanced Pick structure
in theway that the MDS file and the individuals MDs are. The USERS file
is merely a data file belonging to the DM account which is used when a
user logs on, and which holds identification and security information.
4-18 This is Advanced Pick
BBBB
Let us look more closely at the way in which items are actually held on
disk. have created a file with two items:
|
1) Item AAAA contains just one attribute: This is item AAAA and it will be
held directly within the file space.
2) Item BBBB contains just one (very long) attribute: This is item BBBB
and the data is 900 bytes long and, since it exceeds 847 bytes in
length, it will be held indirectly, that is, with just a pointer in the file
space. This pointer holds the frame address where the true data is to
be found.
Figure 4.17 (a) shows the logical view of two items as would have |
In the rest of the display, we see that, for each item, there is:
© An 8-byte control field which is held immediately before each item-id:
this tells us the length of the item, how the item is held (that is,
whether it is a direct item or an indirect item), and whether the item
has been changed or deleted since the last file-save. For item AAAA,
this control fieldisshownas s (because some of the characters
have no printed form, and are shown as dots; in hexadecimal, they
appear as 0000000053001000).
© The item-id: this may be as long as necessary and is terminated by
an attribute-mark. The attribute-mark is shown as " and FF in the two
parts of the display.
© The data of the item for direct items, or the frame address for indirect
items. Here we see the exact contents of item AAAA (a direct item),
but we cannot see the contents of item BBBB (an indirect item).
A final attribute-mark at the end of each item.
© The end-of-item marker (shown here as and FF) after each item,
_
and, following the final item in the group, the end-of-group marker
(shown here as and FF). _
00 00 00 00 53 00 10 00
where xxyy is the hexadecimal length of the item (this represents the sum
of the 8-byte control field itself, plus the length of the item-id, plus one
attribute-mark, plus the length of the true data and field separators, plus
1 for the final attribute mark). Thus, item AAAA is 0053 bytes (that is, 83
decimal bytes) in length; note the way in which the xxyy field is held. The
character zz is 00 or 10 or 01 and indicates that this is a direct item held
in the file space; 00 denotes that the item has not changed since the last
full file-save, 10 denotes that it has changed, and 01 would indicate that
it had been deleted; we'll look at these codes later.
Items such as AAAA of which the data is 847 bytes in length or shorter
are held in the file space (as on R83 Pick). This figure of 847 bytes refers
to the length of data in the item and excludes the field-length count, the
item-id and the final end-of-item marker. Longer items (848 bytes or
4-20 This is Advanced Pick
more), such as BBBB, are held indirectly, with the actual data being
written to one or more frames of disk and only a pointer being held in the
file space. On those systems which use 2048-byte frames, the size limit
for direct items is 1696 bytes.
00 00 7¢ 03 15 00 90 00
where the length of the true data item, xxyy is the length
of the pointer itself, the character zz being 80 (not changed since the last
full file-save) or 90 (changed), or 01 (deleted), all implying that the item
is held indirectly.
In Figure 4.17, we see that the pointer for item BBBB is 21 bytes long (=
0015 hexadecimal) and directs us to frame 2294 (= 8F6 hexadecimal)
where we shall find an item which is 892 bytes long (= 0000037C
hexadecimal), as indicated by the first part of the 8-byte control field held
in the file space. Figure 4.18 shows frame 2294 to which the pointer for
item BBBB directs, and we see the full 892 bytes of the item, up to and
including the final attribute-mark.
800 2 XXXXXXXXXXXXXXXXXXXXXAXXXXXXXXXXXXXXAXXXAXAXXXXXXXKX ?
850 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXKXK*
900 :
$50
After a full file-save has been performed, the system resets the character
File structure 4-21
zindicators to the clean states of 00, 80, AO and CO during the process
of clearing the dirty bits.
The Advanced Pick literature also uses the terms in-line item where |
have used direct item, and out-of-line item where have used indirect
|
item.
D*
or, in hexadecimal:
000000000B00010044FEFFFF
that is, an empty-pointer still remains, and the dirty bits show that the
item has been deleted. If we list the file, item D will not appear and if we
create a new item D this empty-pointer will be re-used and the dirty bits
will show that the item has been changed since the last file-save.
to create new data section on the DICT of the CARS file; the new data
section is called DECEMBER and has a modulo of 133.
In all cases, these add extra letters to the D in all the D-pointers which are
established by the command, and this affects the way in which the file is
handled. The available options are L (to indicate that any changes made
to the file are to be logged by the transaction logger), P (to indicate that
the primary file space is to contain only pointer (indirect) items regardless
of the size of the items), S (to indicate that the item-ids on the file are to
be case-sensitive), X (to indicate that the file is to be ignored during file-
save / account-saves), and/or Y (to indicate that the contents of the file
are to be ignored during file-save and account-saves). We met these
earlier.
If you wish to change any fields in the D-pointers after you have created
the file, you can do this by means of the commands:
UD MD PAYROLL
to change the file definition on the MD, or
UD PAYROLL PAYROLL
to change the data-level identifier on the DICT of the file.
Ingeneral, D-pointers are rarely changed in this manner, although the
System Manager may wish to set the lock-codes in attributes 5 and 6.
The codes in attribute 1 of D-pointer may also be set by the SET-DPTR
a
verb.
The LISTFILES command is used to produce a list of all the files which
belong to an account and all the file synonyms which are available to the
account. The command has the form:
LISTFILES
to print the same report. The report shows the name, base FID and
modulo of the files, and the entries are grouped by the CODE: D-pointers
coming first, then DL-pointers, and so on, with Q-pointers (the file
synonyms) coming last). If the (C option is used:
LISTFILES (C
LISTFILES (PC
File structure 4-23
Page 1 *** DICT DM,MD, *** File Defining Items 29 Jul 1994
ABS D 3348 1
WORDS D 5999 1
kkk
ADMIN. BP BP.QA,ADMIN
:
SYSPROG-PL DM BP
SYSTEM-ERRORSQ DM ERRORS
LISTFILES WAGES,,
to produce a list of the files (and file synonyms) which are present
on the MD of the WAGES account.
LISTFILES WAGES,, (C
to produce a four-column list of the files which are present on the MD
of the WAGES account.
LISTFILES MDS,, (P
to print a list of all the accounts (and account synonyms) on the
system.
LISTFILES MDS,, (C
to produce a four-column list of the accounts which are present on the
system.
The options can be used in ail instances.
4.6.3 Inspecting the files
As Figure 4.20 illustrates, there are several commands which will allow
you to look at the layout of your files.
sISTAT STOCK
file= stock modulo= 1
Hash-Test/Istat Statistics
sHASH-TEST STOCK
test modulo: 3
1 808 12 *>>>>>>>>>>9>
1 852 12 *>>>>>>>>>>>9
4
File structure 4-25
Hash-Test/Istat Statistics
sGROUP STOCK
3000
HASH-TEST STOCK
display the same information as ISTAT but using a hypothetical
modulo entered by the user in response to the TEST MODULO
prompt. This is useful for assessing the impact of changing the
modulo of a file. Here, we see the bar chart showing the distribution
of the 39 items if we had created the file with modulo of 3. The
a
HASH-TEST command does not change the physical file in any way.
but simply carries out a what-if investigation.
GROUP STOCK
display the details of the items in each group of the file. Here, we see
that the file starts in frame 20010 and the first (and only) group
4-26 This is Advanced Pick
contains 39 items occupying 2748 bytes, that is, 2 full frames and 748
bytes of a third frame.
ITEM STOCK 1000
display the details of the items in the group which contains (or should
contain) item 1000.
It is possible to delete aif the items on a file by one of the forms of the
CLEAR-FILE command:
CLEAR-FILE STAFF
CLEAR~FILE DATA STAFF
either of these commands will delete all the items from the data
section of the STAFF file. The contents of the DICT section are not
affected by this command.
You might need to clear a file in this manner so as to get rid of all the old
data prior to copying items from another file or before restoring data from
a diskette/tape. In practice, you may find that you seldom use the
CLEAR-FILE command.
\f you use any of the forms of the CLEAR-FILE command shown above,
Advanced Pick places a segment-mark at the front of the first frame in
each group; the data can still be inspected by means of the DUMP
command but itis otherwise gone and inaccessible. If you clear a file with
the command:
CLEAR-FILE TESTD (C
the C option scrubs the frames occupied by the file, filling them with
segment-marks, thereby obliterating all traces of the data which was held
there.
In all cases, when a file is cleared, any overflow frames which were linked
on to the primary space will be released and returned to the pool of
unused frames.
File structure 4-27
When a file is no longer required, it may be removed from the system and
the frames which it occupied returned to the pool of unused frames. This
is done by one of the forms of the DELETE-FILE command:
DELETE-FILE MYDOCS
to delete both the DICT section and the data section of the file
MYDOCS. The contents of both sections will be lost.
DELETE-FILE DATA CARS, JANUARY
to delete the data section JANUARY from theDICT of the CARS file.
The DICT section itself and all other data sections (other than
JANUARY) are not affected by this command.
DELETE-FILE CARS
to delete the DICT section of the CARS file and aif the data sections.
Once an application system has stabilised, it is unlikely that much use will
be made of the CREATE-FILE / CLEAR-FILE / DELETE-FILE
commands.
The MDS file and USERS file are important to the running of your
Advanced Pick system. Another important file
is the FILE-OF-FILES file.
2) Attribute 2: The base FID, that is the FID of the first frame of the primary
space allocated for the file.
4) Attribute 4: This is null. R83 Pick systems used this to hold the separation
of the file, but the concept of separation has been discontinued on AP.
5) Attribute 5: The RET-LOCK lock-code of the file. This code must match
the equivalent KEYS attribute of the user definition if that user is to be
allowed to read from the file.
6) Attribute 6: The UPD-LOCK lock-code of the file. This code must match
the equivalent KEYS attribute of the user definition if that user is to be
allowed to write to the file.
10) Attribute 10: The column width for the item-ids of the file.
13) Attribute 13: This is the file reallocation parameter. If the System
File structure 4-29
(117)
this would indicate that, when this file is next restored during a file-
restore or an account-restore operation, it is to have a modulo of 117.
This value will then appear in attribute 3.
15) Attribute 15: This specifies the macro, a list of datanames which are
to be used when zooming to another item with the Update Processor.
17) Attribute 17: This is the description, a free-format text field for any
comments concerning the usage and nature of the file.
All fields of D-pointer items (except attributes 2 amd 3) may be set and/or
changed by the System Manager and/or the Systems Analyst, as we shall
see in the following section.
We shall look more closely at attributes 9, 14, 15, 16 and 17 later in our
discussion of attribute definitions. We discuss hotkeys in Chapter 10.
The D-pointers for a file are established when the file is created.
Subsequently, the System Manager or the Systems Analyst may wish to
make certain changes to a D-pointer ...
UD STAFF STAFF
to change the data-level identifier D-pointer which defines the data
section of the STAFF file and is held on the DICT of the STAFF file.
UD CARS DECEMBER
to change the data-level identifier D-pointer which defines the
DECEMBER data section on the DICT of the CARS file.
The UD macro allows you to change certain parts of the D-pointer, but
not others (such as the base FID or the modulo); and of those fields
which are changed, the macro checks that your changes are consistent
and will not upset the vital linkage which the D-pointer represents.
File structure 4-31
4.6.9 SET-DPTR
to DY, then you can use the SET-DPTR command. This has the general
form:
to add (+) or remove (-) the letter (or letters) xxxx to the D-pointer for
dddd. The string of letters xxxx will be one or more of X and Y and L and
P and S.
Currently, it is not possible to change just the D-pointer for the DICT
section of a file. However, this can be achieved by first changing all the
D-pointers for the file, and then undoing the changes to the data section:
SET-DPTR +X WAGES
SET-DPTR -X WAGES, WAGES
Some forms of SET-DPTR are equivalent to the : SWX, : SWY and other
verbs of R83 Pick.
where md.name is the name of the file (typically, the MD) which holds the
D-pointer to the file filename, and file.name is the name of the D-pointer
which is to be moved. The process will then ask for the destination of the
D-pointer:
TO:
to which you will enter the destination response. This will have one of the
forms:
(dest.md.name dest.file.name
or:
(dest.md. name
or.
dest.file.name
location and moved to the new location. In none of these instances will
any Q-pointers which refer to the old and/or the new files be set up or
changed. Here are some complete examples:
MOVE-FILE MD STAFF
TO: (DM,,
to move the D-pointer for the (DICT of the) STAFF file from the MD of
the current account to the MD of the DM account, thereby making DM
the owner of the STAFF file.
4.22 (a) is created on your WAGES MD and known only to you; other
-
accounts do not have any means of reaching the D-pointers and cannot
therefore reach your PAY-RATE file.
and these commands would actually process the PAY-RATE file which
belongs to the WAGES account.
You can create your own Q-pointers by using the EDITor or the Update
Processor to set up an item like that in Figure 4.22 (b) on your MD;
- -
such a Q-pointer may have any item-id where used XXXXX. The format
|
of the item is as shown here: attribute 1 contains just the letter Q, attribute
2 contains the name of the account, and attribute 3 contains the name of
the file on that account. If attribute 2 is null, the current account is
assumed, and if attribute 3 is null, the MD of the account is assumed.
itis possible to set up a Q-pointer to point to a file on your own account.
You might do this so that a file can be called by more than one name; for
example, during development work, you might have created a file called
INVENTORY.DEV.1200A and carried this over to the live system, but you
might prefer to provide a Q-pointer with a more friendly name such as
-
and then copy this to create a new Q-pointer called PROGS (the
original file name) which will refer to the PROGS file owned by the
DEVELOPMENT account. If PROGS already exists on this MD, then
the new PROGS Q-pointer will not be created.
¥ou may have several different Q-pointers all referring to the same file,
and you may have a Q-pointer which points to another Q-pointer. This is
convenient if you have set a Q-pointer to a file and the owner later moves
the file to another account and replaces the D-pointer by another Q-
pointer. R83 Pick users may remember that this was not possible on
earlier systems.
where their files are physically held. This concept of data transparency
is an important characteristic of database theory.
Whenever you try to use a Q-pointer to reach someone else's files, the
access path will be checked and any non-matching lock-codes will cause
the process to terminate.
4.6.12 Pathnames
WAGES , PAY~RATES,
to identify the data section of the file PAY-RATES which belongs to the
account WAGES, or the equivalent...
WAGES , FPAY-RATES, PAY-RATES
to identify the data section of the file PAY-RATES which belongs to the
account WAGES.
As with Q-pointers, the access path to the file will be checked and if any
non-matching lock-codes are encountered, the process will terminate.
4.7 Standard files
In addition to the MDS file and the USERS file, there are a number of
other files which support Advanced Pick and which are available to all
accounts. We shall discuss many of these later in the book. The list of
such standard files includes:
© ABS: holds information about the executable object code used by the
Advanced Pick system.
o ACCOUNTS: holds a history of the log on and log off dates and times,
the connection time, and the computer usage for each user. We shall
look at the ACCOUNTS file in moment. a
cursor positioning and special effects at the user's terminal, and other
item on this file are used to control the printer characteristics to each
form-queue. A number of standard terminal / printer definitions are
provided, and new items may be set up by the DEFINE-TERMINAL
command
o ERRORS: holds any system error messages reported by AP. The
System Manager will inspect this file from time to time in order to
monitor how the system is functioning. There is a separate data
section ~ ERRORS,GFE which is used to hold dumps of any frames
-
4.7.1 ACCOUNTS
ACCOUNTS is a system-wide file which holds a history of the dates and
times when each user logged on and off the system, the connection time,
the computer usage during the session, and the number of pages printed.
Only those users who have A in attribute 9, the OPTIONS field, of their
item on the USERS file will be logged on the ACCOUNTS; other users
will be ignored.
command.
4-38 This is Advanced Pick
4.7.2 FILE-OF-FILES
The following datanames are amongst those which are available when
producing reports on the FILE-OF-FILES file:
o FILE# the sequential item.id assigned in the order in which the file was
created / restored to the system.
MD name of the MD (account) owning the file.
FILE-NAME name of the file in MD of the account.
80
80 89
4.7.3 MESSAGES
MESSAGES is a system-wide file and holds definitions for all the error-
and warning-messages which are displayed by the system processes.
The messages held here may also be output directly by the Basic STOP
statement, the ERROR statement and by the PRINT-ERR command.
The messages are not all error-messages, many are warning messages
and general information messages:
The SEQ item which controls the sort sequence used by the MS
processing code.
The VERSION item which holds details of the current version of your
Advanced Pick system.
535
MYERR1
01.HThe file
02 A
03 H' cannot be opened
then the word STOCK would be slotted into the text of the message (at
the A instruction) and the program would display the message:
The file 'STOCK' cannot be opened
A output a parameter.
x skip a parameter.
Figure 4.24 shows the codes which are used in constructing MESSAGES
items. One of these codes must appear in the first position of each
instruction of the message item. The items are created manually by
means of the Update Processor or the Editor.
File structure 4-43
In most situations, the items on your data files will be created, changed,
inspected, reported and deleted by means of a suite of applications
programs. For example, when you wish to add the details of a new
employee on the STAFF file, you will probably run the specially-written
ADD.NEW.EMPLOYEES program rather than using the Pick EDITor.
This ensures the integrity of the data on the files, and enables adequate
audit trails and other security procedures to be implemented. There are,
however, many items for which it is not appropriate to use such
applications software. These include:
Basic programs,
Procs, menus, and macros,
Attribute definitions, and phrases,
Test data items,
and such items will generally be created and maintained by the standard
system software:
© The Update Processor or the EDITor to create, change and delete the
items,
© Access and other TCL verbs to inspect and produce reports on the
items.
Let's look at some of the ways in which you can handle these non-data
items. In general, each item is handled individually, but many verbs will
process a sequence of ifems, one after another. In such cases, the list of
item-ids may be specified on the command which invokes the action, or
a select-list may be produced immediately prior to invoking the action and
the item-ids in that select-list will be processed.
Such sentences will produce a listing of the item-ids of the items on the
file, as shown in Figure 4.25, and the report may include particular
attributes
In all these commands, the reports can be sent to the printer by adding
the (P option:
LIST MBPROGS (P
SORT MBPROGS = "SET.]" (P"
LIST MBPROGS ( FLOPPY] Al (P
CT TESTDATA 1000 1100A 2300 (P
LIST-ITEM MBPROCS (P
SORT-ITEM MBPROGS WITH Al "[SUBROUTINE]" (P
MBPROGS...
SET
SET.ATTRIBUTE
SET.BOX.CHARS
MBPROGS... Al
CRT.DOT.LINE
ool SUB CRT.DOT.LINE(PART1, PART2)
002 DOTS2STR('.',SYSTEM(2)~-LEN(PART1)-LEN(PART2)~2)
ems can be deleted from a file by means of the Update Processor, using
the:
UPDATE MBPROGS TESTPROG
xo
can be used to recover a single item which you have deleted by means
of the Editor or the Update Processor (but not the DELETE command).
This must be the next command you give and the process will ask you to
confirm
The item will then be reinstated as it was immediately prior to the EDIT or
UPDATE command which deleted it. If you have deleted several items
during one Editor or Update Processor session, only the last one will be
recoverable.
As we have seen, all the items can be removed from a file by means of
the CLEAR-FILE command.
The COPY verb allows you to copy items from one file to another and to
display or print the contents of items.
The general form of the COPY command is:
COPY file.namel {item.list1} {(options}
where file.name7 is the name of the file from which the items are to be
taken, and item.list? is a list of itern-ids of the items which are to be
copied. If file.name7 is omitted, then the process will abandon: if item. list?
is omitted (or if an asterisk is used), then all items on file.namef will be
copied; if item.list1 is omitted and a select-list is available, the selected
item-ids will be used.
Figure 4.26 shows some of the options which are available with the COPY
verb, P and T are of special interest and print/display the contents of the
items without performing any physical copy. If no P or T option is
File structure 4-47
D delete the source items after a successful copy. Not used with the T
or P options.
F skip to a new page for each item. Used with the T or P options.
N This option has two distinct actions: when used with the T option, it will
suppress the pause at the end-of-page; when copying items to
another file with the O option, it will only copy items which already
exist on the target file.
overwrite an existing item on the target file with the same item-id. Not
used with the T or P options.
Unless the T and P options are used, the process assumes that the items
are to be copied to a file, and asks for the name of the file and the item-
ids of the new items on that file:
T0:
You must then type in the destination of the items. There are several
possible responses:
Response 1: <Return>
COPY FILE1 A BC
TO: <== hit <Return> here
If you just hit <Return>, the items will be displayed on the terminal, exactly
like the effect of the T option.
Response 2: enter the name of the file to which the items are to be
copied:
Response 3: enter the name of the file and the item-ids to which the
items are to be copied:
Note that the open parenthesis indicates that a file name follows.
Response 4: enter a list of item-ids with which the items are to be saved
on the same file:
Take care! Note that only the open parenthesis distinguishes the
Response 3 form:
(PILE2 ITEMA ITEMB ITEMC
which will select all the items on SFILE whose item-ids start with ORIG
(selected as the primary select-list) and copy them to TFILE where they
will overwrite all the items whose item-ids start with OLD (selected as the
secondary select-list). This assumes that SFILE holds items such as
ORIG01, ORIG02, ORIG03 and so on, and TFILE holds items OLD01,
pune, OLD03 and so on, and that there are equal numbers of items in
the twtwo sets.
The COMPARE verb will let you compare the contents of two sets of
items, attribute by attribute. The items may be on the same file or on two
different files. The format of the command is:
specifying the name of the file and the list of items to be compared. Ifa
select-list is available, then you can omit the item-list, and if you want to
compare aif the items on the file, then you can omit the item-list or use an
asterisk in place of the item-list.
The output display comprises two columns, one for each file, showing the
results for each item. Alongside each attribute, the code indicates an
extra attribute, and D indicates a missing attribute.
The options control the manner in which the comparison is carried out
and the format of the output, and include:
A compare the whole of each attribute. Without this option, only the
first three words of each attribute are compared.
C combine the output into a single column format.
S$suppress the output of the item-ids.
Z output only those attributes which differ..
Like the COPY verb, COMPARE requires the name of a second file and
a second list of items. Here are some examples:
COMPARE FILE] A BC
WITH: (FILE2
will compare item A on FILE1 with item A on FILE2, item B on FILE1
with item B on FILE2, and so on. Note that the open parenthesis
indicates that a file name follows.
COMPARE FILE] A BC
WITH: (FILE2 AAA BBB CCC
will compare item A on FILE1 with item AAA on FILE2, item BBB on
FILE1 with item B on FILE2, and so on. Note that the open
parenthesis indicates that a file name follows.
File structure 4-51
Like the COPY verb, COMPARE is able to exploit the primary and
secondary select-lists. A primary select-list may be used instead of
item.list1, and a secondary select-list instead of item.list2. For example,
the sequence:
will select all the items on SFILE whose item-ids start with OLD and
their contents with all those items on TFILE whose item-ids start
compare
4.8.7 SEARCH-FILE / SEARCH-SYSTEM: finding strings
The SEARCH-FILE command (or the FIND equivalent command) will
scan all the items on a file and produce a saved-list of the item-ids of
those items which contain any of a number of strings. The process is
invoked by either the SEARCH-FILE or the FIND command, and the
process will ask a number of questions:
© Source file to search: enter the name of the file to be searched.
© String to search for: enter, one at a time, the strings which you are
looking for, entering null when there are no further strings. The
process will accept up to 15 strings.
° Enter list item name: enter the name by which the list of item-ids is
to be saved on the POINTER-FILE.
4.9 Summary
section only, or a DICT section and several data sections. The files on the
system are organised into accounts.
When an account is created, a D-pointer is set up on the MDS file. This
item records the name of the account, the location and the modulo of the
MD of the account, and enables Advanced Pick to locate the account and
its MD. When a file is created, a D-pointer is set up on the MD of the
account. This item records the name, the location and the modulo of the
file, and enables Advanced Pick to locate the file. For each data section,
the DICT section holds a D-pointer which enables AP to locate that data
section. Details of all files on the system are recorded on the
FILE-OF-FILES file.
There are a large number of standard files owned by the DM account and
these are made available to other accounts through pathnames or via a
set of file-synonyms.
File design
The tasks which face the Systems Analyst when designing an application
for an Advanced Pick system are no different from those encountered
when working in any other environment. The gathering, assembly and
analysis of information, and the development of data models and process
models are virtually identical on all computer systems. In this Chapter,
we are concerned with the special points of interest which are relevant
when the analyst is transforming the logical entities and datastores of
the design into the physical files which will be used by the system.
which is clear and explicit but can lead to typing errors if these are
carried over to the live system. Non-technical users or indeed -
© The file name must not include spaces, but any other characters may
be used, however ...
The modulo of a file has a profound effect on the speed and efficiency of
the processes which handle the file. In almost every situation, it is the
actual physical read getting the frame from disk which determines the
- -
efficiency of the process: the fewer the reads, the faster the process.
There are two main methods of accessing the items on a file: sequential
access and direct access.
If you are using Access sentences such as:
LIST MD SORT STOCK WITH MATERIAL "PINE"
or the Basic SELECT statement, then these activities process aif the items
on the file sequentially. In order to be efficient, you need to be able to
process as many items as possible in as few reads as possible. This
File design 5-3
implies that it is important to have each frame filled so that each read
gives the best possible value in terms of number of items read in, as
illustrated in Figure 5.1.
m)> =>
GET-LIST REDS
SORT STOCK
-
modes of using the file is the more important to you. In general, it is
likely that a compromise will be made, satisfying both demands as far as
possible. For efficient file organisation, therefore, the requirements are:
© Have each frame filled with items; this gets the greatest benefit from
each disk-read and makes best use of the disk space.
© Have no empty groups in the file; this avoids useless reads when
processing sequentially.
© Have no overfiow in any group; this makes direct access more
efficient.
If the items are larger than 847 bytes (or 1694 on some systems), they
will be held indirectly. As a consequence of this:
© Very large items are only represented by the pointer, and behave like
5-4 This is Advanced Pick
These factors should be borne in mind throughout the file design activity.
The ideal for any file is that all groups should be filled but not overflowing.
This suggests a possible algorithm for determining the best modulo for a
file:
2) Use the results of your analysis to determine the average size of the
items on the file; let us call this ITEM.SIZE.
When working out the item size, remember that a direct item
comprises the 8-byte control field, the item-id and the data (and
separators) of the item. This is padded with characters so that the
_
entire string is an even number of bytes long. You may use the
'ormula:
ITEM.SIZE 11+i+dtn
where jis the length of the item-id, dis the length of the data in the
item, and nis an integer (0 or 1) such that the total is a multiple of 2.
An indirect item comprises the 8-byte control field, the item-id and the
6-byte pointer (and separators). You may use the formula:
ITEM.SIZE 17+ deden
where /is the length of the item-id, dis the length of the data in the
item, and nis an integer (0 or 1) such that the total is a multiple of 2.
) Calculate the number of items which can be packed into one frame; let
us call this PACKING:
PACKING FRAME.SIZE / ITEM.SIZE
You may care to adjust the calculated value of MOD, making it an odd
number or a prime number, as discussed later.
You now have the modulo for the file. Two examples of the calculation
are illustrated in Figure 5.3
This modulo may then be used when creating a new file, or when setting
the reallocation value, as described in Chapter 21. !f the file already
exists, the modulo can be used as a starting value for HASH-TEST a
Many Pick users believe that the modulo must be a prime number; this is
not true on Advanced Pick. You may have any modulo for a file. Indeed,
if the item-ids are all numeric, sequential and of the same Jength, virtually
any modulo will give even distribution of the items across the groups of
the file.
:PRIME 173
173 is a prime number
The next highest prime number is = 179
The next lowest prime number is 167
:PRIME 200
The next highest prime number is = 211
The next lowest prime number is 199
PRIME
PRIME . computes the next greater prime number
follow this rule, then you would choose the nearest prime number which
is equal to or greater than the value for MOD derived from the above
algorithm. Advanced Pick offer the PRIME utility for determining prime
numbers, as illustrated in Figure 5.4
When you are using the Access enquiry language, the vocabulary of the
sentences is made up of datanames located on the dictionary the DICT
-
section of the file. The following points relate to the contents and nature
of the items held on the dictionaries:
There are a few points to bear in mind when you are designing the item-
ids for the items on your files.
Numeric,
04
Sequential,
No item-ids missing from the sequence,
All of the same length (and padded with leading zeroes where
necessary).
You may hold meaningful data within your item-id. This has two
advantages: firstly, the information which makes up the item-id need
not be held within the item, and secondly, you can determine a
5-8 This is Advanced Pick
particular item-id more easily. For example, we might have the item-
ids of a financial transaction file based upon the account and the date.
This method exploits the uniqueness of the item-id to advantage.
© l|tem-ids may be up to 51 bytes in length. Longer item-ids are
truncated at the 51st character.
© Only the left-most 32-bytes of the item-id are used in the hashing
algorithm. If you have item-ids longer than this (and it is quite possible
if you exploit the ability to use meaningful item-ids), then the
distinguishing elements should be placed at the right-hand end of the
item-id.
© Avoid the characters:
The main criterion in the design points laid out here is that the items on
the file should be as small as possible. In this way, you will have the
benefit of improved file-access time as well as the reduced file-space.
The points to note when deciding the format and sequence of the data
attributes within the items include:
(a) (b)
This also applies to YES/NO indicators and flags, and may even be
used in situations where an attribute may have one of a range of
values. For example, let us suppose that attribute 7 of an item
contains a code which may take any one of the values 0, 1,2 or 3, and
that the value 2 is the most common; then the actual values held on
file should be 0, 1, null and 3, respectively, with the associated
program, and Access conversions and correlatives, using logic such
as:
ADDRESSES
IF 7="" THEN "2" 100°GLEDHILL*34 HIGH ST
ELSE 7 101°REECE*76 HIGH ST
IF N(CODE)
""
THEN
102°MALLINDER*42 FLORAL AVE
"2" ELSE N(CODE)
103° JAGGER*9 FLORAL AVE
© If an attribute may have
one of several known (a) Explicit addresses
data values, it is more
efficient to hold a code ADDRESSES
which cross-refers to a 101 °GLEDHILL* 34°HOOL
file containing the table 102°REECE*65°HO01
of possible values, as 103°MALLINDER*42°F910
illustrated by the street 104°JAGGER*9°F910
names in Figure 5.6.
system might decide to hold the address explicitly, as in Figure 5.6 (a).
But a better technique might be to represent the addresses by the
street number and then a street code, as illustrated in (b), and using
a separate cross-reference file which has items as in (c), and so on.
This offers advantages of space and also of data consistency, in
return for relatively small overheads on file-access times.
You may even wish to use packed decimal or hexadecimal values for
certain numeric attributes. This offers advantages of security, protecting
data such as salaries and telephone numbers from casual browsers.
© Dates and times will be held in the Pick internal format. Thus, the
internal date 1234 takes up less space than any of the equivalent
external formats 18 MAY 1971 or 18/05/71 or 18/5/71. Furthermore,
the internal form is more convenient for sorting and for performing
date calculations. With the conversion codes of Access and Basic, all
of these external forms and many more can easily be reproduced
-
o Give some thought to the format of any textual data on your files. If in
doubt, hold all your data in UPPER-CASE. We look at this again in
Chapter 8 when we discuss the topic of case-sensitivity.
© Information held in the item-id should not be repeated within the body
of the item. Within an attribute definition, the item-id is identified as
attribute 0 and quite accessible for processing.
The security aspects of Advanced Pick allow you to control access to your
files by means of the Ret-lock and Upd-lock lock-codes. If any of the D-
pointers along the path to the data (from the SYSTEM file to the MD to the
DICT section and on to the data section) contains a Ret-lock or Upd-lock
lock-code, then any user attempting to access that file must have a
matching value in the KEYS field of their USERS item. We discuss this
in Chapter 23.
§.8 Summary
All your work on Advanced Pick will be done via the terminal: you will
enter your information by typing on the keyboard, and the results will be
displayed on the screen. There will also be one or more printers which
you will use to produce printed reports. In this Chapter, want to look at
|
the ways in which a typical, non-technical user will work with these pieces
of equipment.
6.2 Logging on
6-2 This is Advanced Pick
Before you can carry out any work on the Advanced Pick system, you
must log on. In order to log on to Advanced Pick, you will need several
pieces of information:
Insome cases, your system may have been organised differently; it may
be that when you enter your user-id Advanced Pick automatically logs
- -
you to the correct account, or you may asked for further identification, or
you may be presented with a menu asking you what you want to do.
in all cases, your System Manager or your supervisor will provide you with
the information you'll need.
Your user-id, the account names and the passwords are an important part
of the security of the system, so it is good practice not to write such
information down where anyone can see it.
When you log on to Advanced Pick, any one of several things may
happen:
symbol and wait for you to issue a command. When the system is in this
state, itis said to be at TCL. This means that Advanced Pick is waiting for
you to type in an instruction in the Terminal Control Language, TCL.
We shall discuss TCL in more detail later.
Using your Advanced Pick system 6-3
2) There may be a request for some further identification. This may be a part
of the security protection on your particular system.
3) You may be thrown straight into the business system for your
organisation.
6.3.1 TCL
TCL, the terminal control language, is the most fundamental means of
using the system's facilities. The TCL language is made up a number of
commands which are typed in, one at a time, whenever Advanced Pick
displays the:
The TCL stacker is a part of the TCL processor which allows you to
recall the last TCL command which you entered and issue it again. You
may use the stacker to repeat a particular command, or you may recall
a command which you typed incorrectly and then correct it before issuing
it again. This reduces the amount of typing which you have to do and
makes it easier and faster to issue TCL commands and Access
sentences.
The stacker holds the commands in a stack, hence the name. The most
recent command is placed at the top of the stack. As you type another
command, this is added to the top of the stack, pushing the others down.
There is no limit to the number of commands which can be held in your
6-4 This is Advanced Pick
stack, and you can recall a command from anywhere in the stack.
stacker is in operation, you can use the keys shown in Figure 6.2 to
If the
recall, change and reissue your commands. Most useful are:
"D
to move down the stack starting with the most recent command, and:
"F
to move back up the stack. Keys such as these - and the other keys
which we shall meet later are typed by holding down the <Ctrl> key and
-
pressing D (or F) at the same time. As you browse through the stack,
each command will be displayed in turn; when the command you want is
displayed, you simply press <Return> and that command will be
executed, or you may use the other commands to change and correct the
command before pressing <Return> and issuing the amended version.
The contents of the stack are held indefinitely and Advanced Pick uses
your user-id to save your stack for future use and to remember what you
were doing when you last logged on.
6.3.4 In difficulties
Rarely, there may be occasions when you get into difficulty. The work you
are doing may appear to run into trouble and stop with the system
displaying something like:
Using your Advanced Pick system 6-5
1123
®
in which case your processing is said to have gone into the Basic
debugger, or it might display something like:
I 123.45
1
or:
Icntrlnp: 095
1
over and over again indefinitely. In this case, your supervisor or the
System Manager may tell you to press the:
<Break>
key. The system will then respond with a prompt such as:
or with one of the two sequences shown above. In all situations, your
supervisor or the System Manager will tell you what to do next. Typically,
you may be told to type:
OFF to abandon your work and log off the system completely, or ...
END to terminate the work you were doing and go back to TCL or to
the start of your application system.
You should always consult your supervisor or the System Manager before
using either of these commands, otherwise you may lose some of your
data or you may undo a lot of work which you or someone else has
performed.
6.4 Logging off
When you have finished all your work and you no longer need to use the
Advanced Pick system, you will log off. This instructs the computer to
ignore you and your terminal until you (or someone else) logs on again.
If you are working within an application system, then there will probably
be some formal way of finishing your processing and logging off. If you
are using TCL, then you will log off by entering the:
OFF
command. You may then switch off your terminal, or you may wish to log
on again later.
6-6 This is Advanced Pick
if you are working at TCL and want to log on to another account, you may
do this directly by entering a command such as:
LOGTO WAGES
either of which will terminate the work on the current account and then log
you on to the WAGES account. If there is password on the WAGES
a
account, you will be asked to enter this. Your user-id will be unchanged.
If you have finished using your terminal you may have finished work for
-
the time being, you may be going to lunch, or you may be going home at
the end of the day then you will:
-
Your supervisor or the System Manager will tell you of any other security
measures which apply to you.
The work which you do between logging on and logging off obviously
depends upon your particular circumstances: yours may be sales
organisation selling tables and chairs, you may work in a hospital handling
patients and doctors, yours may be a public service company ... the range
of Advanced Pick systems is limitless. For this reason, it is impossible to
discuss your precise application in any detail, but in this and the following
sections, shall present some of the questions which you should ask of
|
What is my user-id?
0
Here are some questions which you should ask so that you will be
equipped to use the menu structure of your business application system.
How dol start up the menu system? Is the menu system called up
automatically when log on? |
| If so,
Here are some questions which you should ask so that you will be
equipped to use the printers on your system.
© How many printers are there?
6-8 This Is Advanced Pick
Are there any other points or procedures that should know about
|
6.7 Summary
All work on Advanced Pick is done by typing commands and data at the
keyboard and by reading messages and results displayed on the screen
or printed on the printer.
© The function keys and the cursor control (arrow) keys may be
used within application systems but they are not used by Advanced
Pick itself nor by the standard tools, such as the Update Processor or
the TCL stacker.
© The numeric keypad may be used to enter numbers when the <Num
Lock> key is set on.
© The special keys, such as <Page Up> and <Page Down> are not
used by Advanced Pick.
© The TCL stacker. You will use the extended keyboard facilities to
browse through the stack of commands issued earlier and to recall
and to amend the commands.
© The Update Processor and all the system tools such as CREATE-
-
ACCOUNT -
which use the Update Processor. You will use the
extended keyboard to invoke the various actions, to create, change,
maintain and/or delete the items and the data fields on your files.
This means that the functions of the TCL stacker and the Update
Processor are invoked and controlled by typing <Ctrl> key sequences,
and not by explicit commands (such as are used by the Pick Editor).
Typically, these control sequences consist of the <Ctrl> key followed by
one or more letters, and it is not possible to use these Advanced Pick
tools other than by means of these <Ctri> keys.
The <Ctri> keys and keyboard sequences allow you to move through a
data item and to perform a large number of editing and manipulating
actions. For example, the key which is shown in this book as:
7-2 This is Advanced Pick
"K
is typed by holding down the <Ctrl> key and, at the same time, pressing
the K key; this particular key will move the cursor one place to the right.
Another example is the key sequence:
"XF
which is typed by holding down the <Ctri> key and then pressing the X
key and then releasing the <Ctrl> key and pressing the F key, or you may
hold down the <Ctri> key whilst both X and F are pressed. This particular
sequence will instruct the Update Processor to file the item which is being
edited.
Note that:
o You do not press the <Return> key or the <Enter> key when using
these <Ctrl> keys and <Ctri> key sequences.
"J
will move the cursor one place to the left.
"L
will delete a single character.
will toggle between insert and overwrite when you are entering text.
*xo
will delete the item.
There are a great many such keys and key sequences. A table of the
<Ctri> keys is shown in the Appendix at the end of the book. At this stage,
you should not worry if all these keys seems confusing ... take it from me,
The Advanced Pick keyboard 7-3
with a little practice, they will all become second nature to you.
7.1 <Ctr>s
It is worth reminding ourselves that, if you hit the:
key, your terminal may apparently lock out, ignoring anything that you
type in. This can be cancelled by typing the:
"a
key. Advanced Pick does not use the "S key but it may be typed by
accident when entering other keys and sequences such as "FS..
The <Ctri> keys and key sequences which we have discussed are the
default settings used to control the Update Processor and other tools of
Advanced Pick. In general, they are fixed and cannot be changed or
reassigned to, say, the function keys.
Figure 7.1 shows a keyboard definition which might be used to assign the
following actions to the <Cursor control> keys of the keyboard on port 0
for use with Advanced Pick:
o <Up arrow> to move the cursor up one line (like the "B key).
© <Down arrow> to move the cursor down one line (like the "N key).
© <Left arrow> to move the cursor one character to the left (like the "J
key).
© <Right arrow> to move the cursor one character to the right (like the
AK key).
o 4<Up arrow> to move the cursor to the top of the item (like the "T
key).
o 4<Down arrow> to move the cursor down one page (like the "T key).
4<Left arrow> to move the cursor one word to the left (like the "Y key).
© 4<Right arrow> to move the cursor one word to the right (like the "U
key).
Note that, since each key can only send a single character, it is not
possible to define a keyboard which would send sequences such as:
"XF
The Advanced Pick keyboard 7-5
and so on. Itis possible to redefine the function keys in a similar manner
by means of the SET-FUNC command.
Release 6.1 and later have a facility for redefining the <Ctri> keys by
means of the SET-IMAP command which allows you to set up a mapping
between a set of keyboard sequences and the equivalent internal codes
used by the system.
7.3 SET-KBRD
The keyboard is set up to the USA layout when you boot the system. The
SET-KBRD command allows the keyboard of the terminal on line 0 to be
redefined for other layouts and for foreign languages.
The items which define the keys consists of four sets of specifications
representing the characters sent by the key and <Shift>, the key only, the
key and <Ctrl>, and the key and <Alt>. Within each set, the lines
represent the various characters generated by the keys on the top row of
the keyboard, the second row, the third row, and so on. Each line is
made up of pairs of hexadecimal digits, one pair for each key of that row.
If the pair FF is used for any key, then that key will have no effect when
pressed. The function keys are set by the SET-FUNC verb described
later.
SET-KEYS item.name
© the scan code for each key which is to be set/changed. You will find
a chart of these scan codes in the reference literature for your
terminal keyboard.
<Alt> key.
It is a good plan to copy one of the existing specifications and use this as
a basis when you are creating a new set of keyboard assignments.
7.4 SET-FUNC
The function keys can be used with the Pick system. Their use, however,
is different from their application within DOS systems, each function key
sending a predetermined stream of characters.
specifying the names of the file and the item where the function key
definition is held.
The item which defines the function keys consists of 4 lines each made
up of 12 pairs of hexadecimal digits, one pair for each function key. The
four lines represent the various characters generated when the user
presses the function key and <Shift>, the function key only, the function
key and <Ctri>, and the function key and <Alt>. A fifth line specifies a pair
of hexadecimal digits representing a lead-in character which will be
transmitted immediately before the appropriate character for each
function key.
will reset the function keys to their default definitions, as shown in Figure
7.2; the asterisk represents the lead-in character, hexadecimal 2. If you
are writing Basic programs to handle the function keys, it is perhaps wise
to arrange for your program to receive these default settings and react
accordingly.
The Advanced Pick keyboard 7-7
FL *@ *p *space *0
F2 *A *Q *1
F3 *B *R *2
F4 *c *s *3
FS *D *T *$ 84
F6 *% *5
F7 *F *v *& *6
F8 *G *7
Fo *H *( *8
F10 *I wy *) *9
Fll *Z ae
Fl2 *K *T *
7.5 Summary
Many of the standard Advanced Pick tools use the special <Ctrl> keys of
the terminal keyboard. In this Chapter, we looked at some of the <Ctrl>
key actions.
The SET-KBRD and SET-FUNC verbs are available to set the keyboard
and the function keys to send specific character strings.
TCL and TCL commands 8-1
Each TCL command is executed immediately, and when the process has
completed, the system returns to the TCL prompt.
© Control and interrogate the characteristics and the usage made of the
system.
© Control the spooler and the printers.
© Perform backup and restore operations.
There are several forms of TCL commands. Some require only the
command word:
TIME
The first word in any TCL command is the verb. Each verb is defined by
an item held on the master dictionary the MD. Each separate account
-
has its own MD and, therefore, its own repertoire of commands, although
about 95% of all commands are available to all users; however, certain
privileged operations, such as CREATE-ACCOUNT and DELETE-
ACCOUNT, are normally only available to the DM account.
Figure 8.1 shows the MD items which define some of the common verbs.
Exactly which system tool is used to produce the required effect is
different for the verbs: the OFF verb and the UPDATE verb invoke special
coding held in the ABS frames; the POVF verb calls a macro which then
invokes another system tool, OVERFLOW; the LISTFILES verb invokes
a Basic program held on the DM,BP, file. The ways in which a particular
verb achieves its effect is of no concern to the ordinary user, the main
thing is to know what the verb does and how to use it.
Ol VH N VE VR
02 D OVERFLOW Aj14 3]9
03 F
04 DM, BP, LISTFILES
These verb-items are held on the MD exactly like the STAFF records are
held on the STAFF file. Whenever a user types in a TCL command, the
system picks out the first word the verb and then uses this to search
- -
through the MD to find the definition for that verb, and then invokes the
appropriate tool. If the you make a mistake and type in a verb which is
not defined on your MD, then it will be rejected with a message such as:
Editor then the EDIT verb can be removed from the MD of that account.
-
The verbs can also be renamed and you may even add your own
programs to the MD so that they look and behave like TCL verbs and
commands.
TCL and TCL commands 8-3
delete a character
we) delete a word
"Ww insert a blank space
start/stop inserting text
There are a few general points about working at TCL. We shall discuss
some of these in more detail later.
EDIT STOCK
COPY STOCK
CT STOCK
R83 Pick systems used an asterisk to specify aif items. This can still
be used on Advanced Pick:
EDIT STOCK *
COPY STOCK *
CT STOCK *
and, if you wish to submit all the items on a file to the Update
Processor, you must use the asterisk:
UPDATE STOCK *
© The TCL stacker will store each TCL command which the user
enters. These lists of commands are stored on a file called TCL-
STACK with the user-id as the item-d. The stored commands may be
recalled and/or corrected as required.
© All the TCL commands issued by the user may be recorded on the
CAPTCL file for inspection. This is a security feature employed in
some organisations.
WHO (P
ISTAT (S
LIST-ITEM STAFF 1000 2000 (P
If several options are specified, these may appear in any sequence and
with or without separating commas:
Each command has its own options and these will be shown in the
technical description of the command, although for those verbs which
produce a report, the P option and the N option are generally available:
P to send the output to the printer,
TCL and TCL commands 8-5
BREAK-KEY
CASE
LEGEND
SPELLER
STACK
TCL-HDR
TIMEDATE
TYPE-AHEAD
and the command with no options will display the current status. For
example:
TIMEDATE (F
TIMEDATE (N
TIMEDATE
TIMEDATE-OFF
TIMEDATE-ON
8.3 Case-sensitivity
We have seen that any TCL command and any Access sentence may be
entered in either UPPER- or lower-case. The CASE command will allow
you to reset and/or display the sensitivity for your own terminal:
CASE
will display a message such as:
CASE (N
CASE-ON
8-6 This is Advanced Pick
CASE (F
CASE-OFF
either of these will set your input to be case-insensitive.
:case-off
(1319] Case insensitive.
efile al
REC1 cat
REC2 Cat
REC3 CaT
REC4 cAT
RECS CAT
efile al
REC1 cat
REC2 Cat
REC3 CaT
REC4 cAT
RECS CAT
:case-on
(1318] Case sensitive.
cfile al
REC1 cat
cfile al
RECS CAT
Figure 8.3 illustrates the way in which the case-sensitivity and the manner
in which the data is held on the file can affect the results of Access
sentences. Note that all commands and keywords are case-insensitive.
Itis possible (by using a DS-pointer instead of the simple D-pointer for the
data-level identifier) to define a file such that the item-ids are to be case-
sensitive; that is, so that there may be four distinct items with item-ids:
FRED
Fred
fred
f£ReD
Whilst this may seem a good thing, it can lead to certain complications.
In the absence of any other guidelines or constraints, it is good practice
to:
8.4 TIMEDATE
If you just hit <Return> instead of entering a TCL command, the system
will display the time and the date:
TIMEDATE~ON
TIMEDATE-OFF
or the equivalent:
TIMEDATE (N
TIMEDATE (F
TIMEDATE
with no options will display the current status of the function, indicating
whether it is on or off.
8.5 Stacker
The Advanced Pick stacker stores every TCL command which you enter,
and allows you to recall a TCL command which you entered earlier and -
modify it, if you wish and issue it again. The commands are stored in a
-
stack. The contents of the stack can be scanned, inspected and recalled
by the standard Update Processor <Ctrl> keys; these are summarised in
Figure 8.4. Those marked with ¢ may be used to amend a command as
you are typing it.
delete a word
insert a blank space
start/stop inserting text
These keys and key sequences are entered at TCL. Of particular value
are:
You can recall the last command issued by means of the "D key.
You can navigate up and down the stack by means of the "D and 4F
keys.
You can search for a specific substring within the stack by means of
the "A key. A command such as:
XXXXX A
will search for the most recent command which contains the string
000K, and:
"A
There is no limit to the number of commands which are held in the stack,
so you must take care to clear it down (or delete the item) from time to
time by means of commands such as:
CLEAR-FILE TCL-STACK
CLEAR-FILE DM, TCL-STACK,
clear down the stacks for all users.
Commands invoked through a macro which has an M identifier (in
attribute 1) are added to the stack, those in a macro with an N identifier
are not.
The stacker is normally active, but it may switched off/on by means of the
commands:
STACK-OFF
STACK-ON
-
which the users issue. This ability to scan the recorded commands and
monitor the user's work can be valuable for security purposes or when
training new users.
For each user, TCL command history item is saved on the CAPTCL file.
a
These items hold the commands with the most recent at the end, as
illustrated in Figure 8.5, and are held with item-ids of the form:
u*[p
am*[0
o1 create-file captcl 1 11
When you are carrying out any processing be it a long Access report,
-
the process has finished and control returns to you. This can be
inconvenient.
When you are in the midst of a process, you may press the <Break> key
or the <Esc> key to suspend the current process and then issue a TCL
command. When you interrupt a process in this manner, the system
stops execution and saves all the necessary information so that the
process can be resumed exactly where it was interrupted, it then replaces
the normal system prompt by:
to indicate the level at which you are processing and waits for you to enter
a TCL command. At this point, you may issue any TCL command to
initiate a second process. This second process may, in turn, be
interrupted and a further operation invoked. When each process has
completed at the lower level, the appropriate prompt will be displayed,
and you may issue a further TCL. command at this lower level. This
facility is known as level pushing and is illustrated in Figure 8.6.
YYYYYYYYYYYYYYY
Yyyyy<Break> Push to level 3
tiszzzz Invoke second process at level 3
022212042120222
ZZZZZZZZZZZZZZZ
ends
¢Return> Return to level 2
8-12 This is Advanced Pick
YYYYYYYYyy
YYYYYYYYYYYYYYY
YYYYYYYYYYYYYYY
ends
t:aaaa Invoke process at level 2
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
ends
Return to level 1
XXXXXXXXXXXXXXX
ends
prompt is displayed:
Either the <Break> key or the <Esc> key may be assigned to invoke this
level pushing, and this will normally be set during the logon procedure for
the user or for the account. The following TCL commands are available
to control this:
BRK-LEVEL
assigns the <Break> for level pushing,
ESC-LEVEL
assigns the <Esc> for level pushing,
BRK-DEBUG
assigns the <Break> for invoking the debugger (the conventional role),
TCL and TCL commands 8-13
ESC-DATA
assigns the <Esc> for sending the <ESCAPE> character (the
conventional role).
ESC-TOGGLE
enables/disables the action of the <Esc> key between level pushing
and sending the <ESCAPE> character, and vice versa.
depth of nesting
The depth of the processing level for each user is shown in the STAT field
of the modified WHERE report, as illustrated in Figure 8.7.
TO) command and log to another account. The TCL prompt on the new
account will be of the form:
to remind you that you have pushed a level. You may carry out any work
on that account and when you hit <Return> at the prompt, you will return
to your original processing on your original account.
8.9 Macros
If you need to issue the same TCL command or Access sentence, or the
same sequence of commands and/or sentences, over and over again, it
is possible to save the sequence as a macro. The macro can then be
recalled by name, as and when required. This saves typing effort and
removes the risk of errors, and is particularly valuable when developing
systems for non-technical users.
command. Thus, when the macro in (c) is invoked by means of the TCL
command:
STOCK.MACRO.2
the macro processor will display each of the TCL commands in turn and
wait for you to hit <Return> to execute the command. Before you hit
<Return>, you may use the standard cursor controls of the Update
Processor to amend any part of the display to patch the TCL command
before it is invoked. The command will ignore the command.
If the first line of the macro begins with N (instead of M), then the
commands will be executed without requiring any user intervention.
00 macro name
01 M or N (comments}
02 TCL command 1]data 1]data 2)
03 TCL command 2]data 1]data 2)
04 TCL command 3]data 1]data 2]
STOCK.MACRO.1
M
02 SORT STOCK BY PART.NO
(b)
STOCK.MACRO. 2
The first attribute of the macro definition starts with the identifier M or N
followed by optional comments. If M is used, each command in the
macro is added to the TCL stack and passed to the user for him/her to
modify and/or issue the command. If N is used, the commands of the
macro are executed without requiring such user-intervention and they are
not added to the stack.
then the specified text will be appended to the end of the first command
in the macro, generating the sentence:
°
If any of the TCL commands (or the modified commands) is invalid, then
the macro will abandon.
All macro definitions are held on the MD and will be created by means of
the Update Processor or the EDITor:
UPDATE MD macro.name
EDIT MD macro.name
CREATE-MACRO macro.name
or:
CREATE-MACRO macro.name (N
which will establish the last executed TCL command (taken from the top
of your TCL stack) and save it on the MD as a macro with the name
macro.name, The N option on the CREATE-MACRO command will
establish the macro with an N identifier in attribute 1, otherwise M will be
used.
8-16 This is Advanced Pick
LIST-MACROS MD
LIST-MACROS WAGES,MD,
will list the available macros on the MD of your account or some other
account.
TCL and TCL commands 8-17
DISPLAY meesage
and will display the message on the screen. TYPE may be used as an
alternative to DISPLAY.
PROMPT {message}
{message} --
Quit/Continue (q/c) ?
These commands can be issued directly at TCL, but they have little
meaning outside the macro/menu context.
8.10 Menus
8-18 This is Advanced Pick
STOCK.MENU
as illustrated in Figure 8.10. You may then enter the required option:
When the appropriate command has been executed, you will be asked
to:
ME
3) The TCL command which that option is to invoke. This may be any
TCL command and even another menu name. Several TCL
commands may be specified as further muifivalues.
00 menu name
01 ME
02 menu title
03 descriptive text 1]Help message 1]TCL command 1
00 STOCK. MENU
T-DET
DISPLAY Remove diskette
07 Delete stock items
Delete old items from the STOCK file
RUN STOCK.BP DEL.REC
(b) STOCK.MENU
Figure 8.9: Menus
The menu processor will handle any number of options, and the screen
display will be tailored to handle the various lengths of descriptive text,
producing only a single list if the texts are long.
Enter number of choice, number? for Help, <Return> to exit menu, or verb:
Menu definitions are held on the MD and may be created by means of the
Update Processor or the EDITor. There are two associated commands:
LIST-MENU MD {item.list}
to display the contents of the specified menu(s) held on the MD, and:
LIST-MENUS MD
LIST-MENUS WAGES,MD,
to list all the menus on your MD or the MD of another account.
As this last command will reveal, there are a number of standard menus
provided with the Advanced Pick system.
LIST
SORT
UPDATE
RUN
OFF
HELP
OP = the Output Processor
EDIT
COPY
BASIC
COMPILE
CATALOG
{DIR
The System Manager is likely to make most use of the range of TCL
commands which are provided to set, reset, assign, enable and disable
the various characteristics of the Advanced Pick system. We discuss
many of these commands individually in other Chapters of this book. We
discuss some miscellaneous topics here.
8.11.1 EPick
HELP topic
or.
8-22 This is Advanced Pick
? topic
where fopic is the subject on which help is required. For example, the
TCL command:
HELP FRAME
would invoke EPick and display the EPick entry on frames. If you ask for
help on a topic which is not included in EPick, then the next available
alphabetic entry will be offered. Thus, if you asked for:
HELP GRO
Having found a particular entry in EPick, you may use the AP keyboard
sequences, shown in Figure 8.11, to browse through the information
which is displayed.
© Type in the topic (or just the first few letters of the topic) on which help
is required.
You can terminate the current HELP session at any time by typing any of
the *X sequences shown in Figure 8.11.
8.11.2 SLEEP
All TCL commands are executed immediately they are entered, tying up
the terminal until the job is complete and the system is ready for further
commands. There are two ways in which this may be changed: the
SLEEP command and the phantom scheduler.
SLEEP 22:30
to sleep until the specified time, and
SLEEP 60
to sleep for 60 seconds.
your port would sleep until 10:30 p.m. and then wake up to print the
STOCK report and finally, log off.
2{H}{S} (tcl.command}
for example:
If H is specified (in either the ZH or ZHS forms), then all the terminal
output will be sent to a spooler hold file; if the S is specified (ZS / ZHS),
any error messages which may be generated by the phantom scheduler
will be suppressed; if S is not specified (Z / ZH), all messages will be
8-24 This is Advanced Pick
displayed on the terminal from which the command was issued (this can
be irritating).
1) The user-id (and the password) which is to be used. The default is the
user-id which you are using at the moment.
4) The number of the line on which the process is to run. The default is
any available phantom line.
The phantom process will then be initiated by the phantom scheduler and
your terminal will be freed for normal use as the phantom job proceeds.
The JOBS file is used to record details of jobs handled by the phantom
scheduler. The TCL commands STARTSCHED and STOPSCHED are
used to enable/disable the phantom scheduler.
Mouse support,
000
Text windows,
Controlling and dependent windows,
File zooming,
TCL and TCL commands 8-25
and many more. There will be more details of GraPICK in future editions
of this book.
8.14 Summary
In most application systems, users will not be exposed to TCL but will
invoke their processing via menus and other front-end processors.
The GraPICK software provides a graphical user interface for many of the
standard AP tools and applications.
The Editor 9-1
The Editor
The Editor is a fundamental tool for creating, changing and deleting any
item held on any file. It was widely used on R83 Pick where it was the
only hands-on tool for creating and editing items, but on Advanced Pick
it has been superseded by the Update Processor in most areas.
pass, line by line, through an item, at each line allowing you to give
commands which will change the contents of that line, delete that line or
insert new lines. In contrast, the Update Processor is a full-screen editor
in which the entire item is displayed at once and you can move around the
screen to make changes where you want and in any sequence.
Because of the great power of the Editor to change or delete any item
from any file, it is a potentially dangerous tool and should be kept away
from non-technical users (and vice versa). It is retained on AP for
compatibility with R83 Pick systems.
The sole remaining use of the Editor is probably for making gang
changes to a file, that is, making the same changes to a large number of
items on a file.
The Editor works with two versions of your item: the original version and
the new version which is built up line by line as you move through the
- -
Whenever you display any lines on the screen (possibly by hitting the
<Return> key to browse through the item or by using the L command),
you are looking at the lines of the original version, but when you change
a line the amended line (and any earlier lines) are copied to construct the
new version. As illustrated in Figure 9.1 (a), if we go to line 5 and
change
eeececececee to RXXXX
then the modified line will be moved across to the new version; the
original line in the original version will not be changed. The F command
(it stands for Flip) will copy any remaining lines from the original version
to the new version and then exchange the two versions, as shown in
Figure 9.1 (b), so that any further changes will be to the newly amended
version, now shown on the left.
Finally, when you file the finished item, any remaining lines will be copied
from the original version to the new version and the new version will be
written to the file on disk. Unlike some editors which you may have used,
9-2 This is Advanced Pick
you do not need to move to the end of the item to ensure that all the lines
are copied.
aaaaaaaaaa
bbbbbbb bbbbbbb
ccc ccc
ddddddddd ddddddddd
eeeeeeecee XXXXX
fffff
aaaaaaaaaa
bbbbbbb
ccc
ddddddddd
fffff
There are a few general points concerning the Editor and the commands
which you will use to control the Editor:
© You will give each command in response to the prompt:
R999/abc/def/
DE999/A/
R999/abc/def/
-DE999/A/
in which case the lines will not be displayed as they are changed.
© The Editor does not keep a backup copy of the original item. When
you file your amended item or delete the item, the original contents
are lost. A deleted item may be recovered by means of the
RECOVER-FD command.
9.2 EDIT command
EDIT MYPROGS
EDIT MYPROGS *
either of these forms will let you edit aif the items on the MYPROGS
file, passing them you to one at a time. Here, as in the previous case,
each item is processed independently of the others.
{f you wish to edit just certain selected items, then you may issue an
Access SELECT or SSELECT sentence, and having selected the
-
the name of the file and without the asterisk, like this:
The Z option will suppress the messages and the beep which sounds
when a new item is created.
The list of the commands which are used to control the Editor is shown
in Figure 9.2. We shall look at the most useful here.
number Cc Fs Pp T
<Return> DE G PD TB
? EX I R U
EXK L RU x
A F M s XF
AS FD ME s? z
B FI N sL
<RETURN>
DE{n}{/string/{p{-a}}}
Delete all those of the next n lines including the current line
- -
which
contain the string in columns p to q inclusive.
DE
will delete the current line.
DE7
will delete the next seven lines, that is, the current line and the
following 6 lines.
DE5/HELP/
will delete every one of the next five lines which contains the word
HELP
DE7/HELP/10-25
will delete every one of the next seven lines which contains the word
HELP starting anywhere in column 10 to column 25 inclusive.
DE20/END/10
will delete every one of the next 20 lines which contains the word END
starting anywhere in column 10 or beyond.
DE/PRINT/
will delete the current line if it contains the word PRINT.
EX
Abandon the current item and exit from the Editor. If you have made any
changes to the item, the Editor will ask you to confirm that you want to
abandon it.
EXK
Exit from the Editor and abandon the processing of the current item and
any further items in the item-list specified on the EDIT command. If you
have made any changes to the current item, the Editor will ask you to
confirm that you want to abandon it.
9-6 This is Advanced Pick
Incorporate any changes made and move the pointer to the top of the
tem. and then continue with the editing of the item. We illustrated this
earlier.
FD
Delete the current item from the file and terminate the editing of the item.
This command should be treated with respect, because accidental
deletion is as permanent as intentional deletion. If you are editing a list of
items, then the next item will be presented for processing, otherwise the
Editor will terminate.
FI
File the item: apply any changes made to the item, write the item back to
the disk, overwriting the original version if there is one. If you are editing
a list of items, then the next item will be presented for processing,
otherwise the Editor will terminate.
FIO ITEMZ
will save the current item as item ITEMZ on the file which you are
using and leave the original item unchanged. If ITEMZ already exists,
then it will be overwritten.
FI(MYWORK NEW1
FIO(MYWORK NEW1
will save the current item as item NEW1 on the file
MYWORK, leaving
the original item unchanged. The FIO form will overwrite NEW1 iff it
already exists on MYWORK.
FS
Apply any changes made to the item, write the item back to the disk,
overwriting the original version if there is one, and continue with the
editing process unlike Fl which leaves the Editor. The forms:
-
FS ITEMZ
The Editor 9-7
FSO ITEMZ
FS(MYWORK NEW1
FSO(MYWORK NEW1
are available and behave much like the Fl forms described earlier.
Gn
Move the pointer to line number n. This is identical to entering just the
number n.
I
Insert one or more lines after the current line.
to show that lines are being inserted after line number n. You can then
enter the new information, line by line, each line being prompted by the
same message:
00n+
An input of null (Gust hit <Return>) will terminate the insert action.
Care must be taken when you want to insert blank lines. This may be
achieved by inserting lines containing dummy character-string which is
a
I xxxxx
Insert the single line of data xxxxx after the current line. There is a space
between the and the data (otherwise the command will be rejected). For
|
example:
1 PRINT "ENTER NEW ADDRESS"
Ln
9-8 This is Advanced Pick
Display n lines starting at the line following the current line. For example,
if the current line is line 1, then the command:
L20
will display lines 2 to 21, inclusive.
L{n)/string/{p{-q}}
Display all those of the next n lines which contain the string in columns p
to qinclusive. For example:
L20/AREA/
will display those of the next 20 lines which contain the word AREA in
any position in the line.
L5/AREA/6-12
will display those of the next 5 lines which contain the word AREA
within columns 6 to 12 of the line.
L/AREA/
will scan the item and display the first line which contains the word
AREA anywhere on the line.
L9999/AREA/
will display all the lines (from here on down) which contain the word
AREA anywhere.
Ln}: xxxxx
Scan the next n lines of the item and display any which begin with the
characters xxxxx. The command:
L20:\
will display all of the next 20 lines which start with the \ character.
L:1000
could be used to locate the statement label 1000 in a Basic program.
Any occurrences of 1000 other than in columns 1 to 4 would be
ignored.
Merge, or copy, n lines from item jifii on the same file as the current item,
starting at line number m, and insert them after the current line in the item
being edited. If you omit n, a value of 1 is used; if you omit m, a value of
1 is used; if you omit iii, then the current item is used. The command
MES/ANDATA/10
will copy the five lines from the item ANDATA, starting with line 10
(that is, lines 10, 11, 12, 13, and 14) and insert them after the current
line in the item which you are editing. The item ANDATA is assumed
to be on the same file as the item which is being edited, and will itself
be unchanged.
The Editor 9-9
ME3//20
will copy the three lines20, 21, and 22 from the current version of the
item which you are editing and insert them after the current line. This
duplicates these lines.
If the item is to be taken from another file, then you will use the form:
ME{n}(fffff {iiiii})(m}
Merge, or copy, n lines from item iiiii on the file starting at line number
m, and insert them after the current line in the item be ng edited. The
command:
ME3(ALLPROGS UPDP)7
will copy the three lines 7, 8 and 9 from the item UPDP on the file
ALLPROGS.
ME9999 (SOURCE MASTER)
will copy all the lines from item MASTER on the file SOURCE.
ME9999 (MAINPROGS
will copy all lines from the item on the file MAINPROGS which has the
same item-id as the item being edited.
Display the next 23 lines of the item. This is a prestored L23 command
which is automatically set up on entry to the Editor. We shall discuss
prestore commands later.
R{n}
Replace the next n lines, including the current line. This is much like the
|command and invites you to type in n lines of information to replace the
next n lines of the item. When you enter a null line, this will terminate the
replacement activity.
Replace the string string? by string2 for the first (left-most) occurrence in
columns p to q inclusive of the next n lines starting at the current line.
Note the following points about this form of the R command. Some of
these are illustrated by the examples shown below:
© If you omit the number of lines, then a value of 1 is assumed.
e The strings may be of different lengths
e Either string may be null
e Unless you use the RU form described below, only the first (left-most)
occurrence of string? will be changed.
o Asmentioned above, my examples use the / character to separate the
9-10 This is Advanced Pick
strings, although any character (other than the colon and numeric
digits) may be used.
o If the character " is used within string/, it has a wild card effect and
"
represents any character. However, the character within string2 is
as the character "
respected
© The A "command may be used to override this wild card effect.
© An attribute-mark, that is, <Ctri> and " character, within sfring2 will
truncate the \ine at that point.
Here are some examples:
R/WAGE/SALARY/
will replace the first occurrence of the word WAGE by the word
SALARY in the current line.
R5/WAGE/SALARY/
will replace the first occurrence of the word WAGE by the word
SALARY in the next five lines, starting with the current line.
R/WAGE//
will remove the first occurrence of the word WAGE from the current
line.
R/ /WAGE/
will append the word WAGE to the right-hand end of the current line.
The string of spaces (string?) must be longer than any string of
spaces which may occur within the line. There is no APPEND
command.
R/ /WAGES/
will insert the word WAGE at the left-hand end (that is, the beginning)
of the line.
R/WAGE/SALARY/30-50
will replace the first occurrence of the word WAGE in columns 30 to
50 inclusive by the word SALARY in the current line.
R5 /WAGE/SALARY/30-50
will replace the first occurrence of the word WAGE in columns 30 to
50 inclusive by the word SALARY in the next five lines, starting with the
current line.
R/WAGE/SALARY/30
will replace the first occurrence of the word WAGE in columns 30
onwards by the word SALARY in the current line.
R/*/-/30-30
*
will replace any in column 30 by the - character. Any * elsewhere in
the line will be ignored.
RS/WAGE/SALARY/30
will replace the first occurrence of the word WAGE in columns 30
The Editor 9-11
onwards by the word SALARY in the next five lines, starting with the
current line.
R999/°//30
will remove the 30th character from this and the next 998 lines. The
'is the character over the figure 6 on the keyboard and is the Editor
wild card character.
RUS999/*//30-50
will remove all the characters from columns 30 to 50 inclusive from
this and the next 998 lines.
Move the pointer back to the top of the item. Any changes which have
been made will not be visible until an F command or FS command is
issued
L23
This happens because the command L23 is prestored when the Editor
is invoked.
commands -
over and over again, then you may store the command(s)
and recall them when required. For example, we might store a command
such as:
R/!/./
in prestore number 6 by entering the command:
P6 R/!/./
and then invoke this by entering:
P6
All ten prestores are used in the same manner, and there is no distinction
between them. You can check the current prestores by means of the
command:
PD
Let us imagine that we wish to change the word WAGE to the word
SALARY in line 7 of an item, then we might store the commands:
Pl G7
P2 R/WAGES/SALARY/
Pl
the Editor will move to line 7 and change the word WAGES to SALARY.
Itis possible to program the Editor and construct a foop of commands in
which the final command in the sequence recalls the prestore command
itself. For example:
Pl R999/WAGES/SALARY/ [FI[P1
Prestore commands such as this are useful when making gang changes
to a number of items, a process which otherwise might need a complex
program to scan and change the items.
The Editor 9-13
This is illustrated by the sequences in Figure 9.3 (a) and (b) either of
which will change the word PERSONNEL to P in line 3 and/or the word
ADMINISTRATION to A in line 7 of all items on the PAYROLL file.
sEDIT PAYROLL *
«Pl G3[R/PERSONNEL/P/
-P2 G7[R/ADMINISTRATION/A/ [FI
«P3 P1(P2[P3
(a)
:EDIT PAYROLL *
Pl G3(R/PERSONNEL/P/ [G7 [R/ADMINISTRATION/A/ (FI[P1
(b)
:EDIT PAYROLL *
9.5 RECOVER-FD
RECOVER-FD
and if you enter Y, the item will be returned to the file in the state that it
was when you last started to edit it.
EDIT INVOICES *
RECOVER-FD can also be used to recover the fast item which was
deleted by the Update Processor "XO sequence.
9.6 Summary
The Pick Editor is an alternative to the Update Processor and can be used
to create / amend / delete any item on any file.
Within Advanced Pick, the main use of the Editor is probably for carrying
out program-controlled editing and for performing gang changes, that is,
making the same changes to a large number of items on a file.
The Update Processor 10-1
10
is the list of item-ids of the items to be processed. We shall use the full
form UPDATE in our examples.
- -
The options available with the UPDATE verb are shown in Figure 10.1.
STOCK 1000
PRICE 56.00
All movement of the cursor through the screen image, data amendment
and filing the finished item is performed by means of the Update
Processor <Ctri> keys. The identity, nature and appearance of the data
is contol by the attribute definitions for the datanames DESCRIPTION
and PRICE
then the Update Processor will default to a list of datanames which are
specified in the macro field (attributes 15 and 16) of the data-level
identifier item for the STOCK file. If there is no such macro list, then the
entire item will be displayed and the Update Processor will behave exactly
like a full-screen editor; this is the situation when editing an item such as
an Output Processor document or a Basic program,
If there is a macro for the file and you do not wish to use the datanames
defined there but wish to edit the item directly, then you can use the
keyword ONLY:
UPDATE ONLY STOCK '1000'
will apply the Update Processor to each of the specified items in turn. As
one item is finished, by means of one of the *X sequences, the next item
will be presented. In this situation, you may use the sequences:
'xr to file the item,
-xx to abandon the item,
"xs to return to the previous item in the list,
"xx to abandon the item and any remaining items in the item-list.
Forms such as:
UPDATE STOCK *
UPDATE STOCK * DESCRIPTION PRICE
will apply the Update Processor to aif existing items on the file.
The forms:
UPDATE STOCK
10-4 This is Advanced Pick
without any item-ids, will create a new item with a unique item-id of the
form:
ddddx
and based upon the current internal date (dddd) and a system-wide
sequence number (x), and then proceed to accept the data for that item.
When the item is filed (by the "XF sequence), control will return to TCL.
The ID processing code may be used to control the form of the new item-
ids which are created.
10.3 DATA-ENTRY
to create a new item with a unique item-id, as in the previous case, but as
the final field (the PRICE in this instance) is entered, each item is
automatically filed and a new item will be presented. The sequence "XK
will terminate the activity and return to TCL.
10.4 ID-PROMPT
the Update Processor will ask for the item-id (if no item-list is included in
the command), and then display the item-id just like any other attribute
and allow the user to amend it, thereby moving to another item.
The Update Processor will accept the file-name, the list of item-ids, and
the datanames in almost any sequence:
provided that this is not ambiguous. The syntactic similarities and the
semantic differences in the forms:
UPDATE STOCK 1000 2345
UPDATE STOCK DESCRIPTION 2345
UPDATE STOCK DESCRIPTION QUANTITY
means that you must pay particular attention to the datanames and the
item-ids which you use in your commands. To avoid any ambiguity, you
should enclose the item-ids in apostrophes. If the Update Processor
The Update Processor 10-5
cannot resolve any ambiguity, it will abandon the process with a message
of the form:
change the data-level identifier D-pointer for the data section which
is held on the dictionary section of the STOCK file.
UD MD STOCK
change the file definition D-pointer for the DICT section of the
STOCK file which is held on the MD.
In these forms, the Update Processor is invoked with a standard list of
attribute definition fields to determine which fields are presented. Figure
10.2 shows the fields used by the UD verb, depending upon which type
of item is being maintained.
(a) D-pointers
dictionary-code attribute-type
account column-width
filename
The UD verb displays a screen comprising the fields from the lists in
Figure 10.2, and the contents of the items are created and maintained in
the normal manner. We discuss the form and function of these fields
ater.
Using the UD verb to create and maintain your Access attribute definitions
rather than the standard line EDiTor, has the advantage that it displays
the name of each field as a prompt for each part of the definition, and that
the ? help facility can also be used. Indeed, D-pointers may only be
amended by the UD verb and cannot be edited by means of the standard
EDITor.
amended
The UD macro allows you to change any of these fields and verifies the
consistency of your changes.
Access enquiry
Attribute definitions are used by the
language and also by the Update processor. They 00 dataname
provide information to control the format and 01 dictionary-code
appearance of the data when the dataname is used 02 attribute-count
in an Access sentence, and they hold information 03
04 structure
which controls and validates the data when the 05 not used
dataname is handled by the Update Processor. 06 not used
07 output-conversion
08 correlative
The fields which make up an attribute definition are 09 attribute-type
illustrated in Figure 10.3. We shall look more 10 column-width
11 not used
closely at the contents of attributes 1 to 10 when we 12 not used
discuss the structure and use of attribute definitions 13 hot used
14 input~conversion
with Access in Chapter 13. 15 macro
16 not used
Attribute 0: the item-id of an attribute definition is 17 description
18 not used
the dataname which will be used in Access 19 not used
sentences and UPDATE commands. 20 hotkey.all
21 hotkeyl
Attribute 1: the dictionary-code is
this as an attribute definition
A to identify Po hotkeyO
© Attribute 17: This is the description, a free-format text field for any
comments concerning the usage and nature of the field, which is to be
displayed if the user enters ? when inputting this field.
© Attributes 20 to 30: These contain the CALLs to any subroutines which
are to be invoked by the hotkey sequences as this field is being
handled by the Update Processor. We discuss hotkeys later.
The UD macro validates the changes which you make to your attribute
definitions.
The Update Processor has many attractions for the Systems Analyst who
is designing an application system:
1) Itis dictionary-driven.
2) Access datanames and attribute definitions can be used, and these
may be extended for more detailed control of the way in which a field
is handled by the Update Processor.
3) Any changes to the attribute definitions for a file are immediately
implemented when the Update Processor is used to update those
data fields on the file.
4) Very little if any bespoke code need be written to produce a viable
- -
maintenance utility.
There are several points to be recognised if you are thinking about using
the Update Processor as a part of your application system:
o Your users must master some of the <Ctrl> keys and key sequences
which control the Update Processor. At the very least, these will
include:
"xr to file the item
and the cursor-movement keys:
o A mastery of the full range of <Ctri> keys may be beyond the grasp
of many non-technical and/or infrequent users.
© The advanced features and functions such as:
© Zooming,
e Cruising,
The Update Processor 10-9
e Double-clutching,
are best reserved for more experienced users. We look at these later.
© The speller should be switched on only when absolutely necessary to
the application.
© The programmers must be conversant with the form and content of
attribute definitions in order to exploit the features of the Update
Processor. Traditionally, many programmers have concentrated on
programming and ignored all but the most elementary features of
attribute definitions.
© It may be necessary to produce a number of Basic subroutines to
validate the data and control the actions performed by the users within
the Update Processor.
In general, it may be more attractive to use the Update Processor for
simpler ad hoc file updates, whilst retaining Basic programs for the more
complex tasks of creating new items and for performing detailed
calculations, data validation and data manipulation. In all cases, it is
better to provide your users with a series of macros (or Procs) which will
invoke the Update Processor to handle specific fields on a specific file,
rather than giving them free rein to use the Update Processor to change
any fields on any items on any files.
M
UPDATE file.name item.list datanames
PQ
HUPDATE file.name item.list datanames
P
will delete the item. If you are feeding a data string, then this will be
enclosed in quotation marks; for example, the macro line:
UPDATE file item] "AAAAAAAAAA"
will set the first attribute of the item to AAAAAAAAAA and then await
further commands from the user.
10-10 This is Advanced Pick
EDIT STAFF *
P1 7]R/YES/NO/]FI]P1
Pl
The Update Processor has facilities specifically for use during the
development of Basic programs and subroutines:
o The sequence "XR will file, compile and run a program item. This
invokes the equivalent COMPILE-RUN command. "XR can also be
used to file and invoke a macro, a menu or a Proc.
o The sequence "XC will file, compile and catalogue a
program/subroutine item. This invokes the equivalent COMPILE-
CATALOG command.
Note that these use the COMPILE (case-insensitive) compiler. There is
no equivalent form which will use the BASIC compiler.
When using the Update Processor as a text editor, there are additional
The Update Processor 10-11
facilities for:
programs, and such but which may not be appropriate for maintaining
-
processing codes, will not be cleared and you may move the cursor
through the text and overtype / insert new text into the existing data.
However, if the attribute definition uses a processing code such as
-
a date or a time then the field will be cleared immediately you enter
-
any new data into the field; if the attribute definition includes an input
conversion code CU, then the data may be edited character by
character.
If a field represents a date and has a D input conversion code, then
you may enter the date in any of the acceptable formats:
dd/mm/yy
dd mmm yyyy
mom dd yyyy
o Youmayenter:
?
to display a help screen about the particular field. This help message
is held in the description of the attribute definition for that dataname.
o The key is used to enter a new value to a set of multivalues.
© Ifafield comprises a set of multivalues, each multivalue is displayed
on a separate (unlabelled) line.
© lfthe system beeps when you attempt to add a new multivalue to an
attribute, this means that a limit has been placed on the number of
multivalues which may be held in that attribute and no further
multvalties may be added. The V processing code is used to impose
such limit.
a
The full range of <Ctri> keys and sequences which are used with the
Update Processor are shown at the back of this book. The most
important contro! sequences for editing the text of an item are:
to clear /delete to the end of the current attribute.
H and the equivalent <Backspace> key to overwrite the character to the
left with a space.
to delete the current character.
-o to delete to the end of the current word.
to toggle between the overtype and insert modes. When this key is
pressed, the data will be broken at the cursor position, allowing new
data to be inserted at that point. Pressing the "R key a second time
will join the broken text. The letter O or is displayed in the top-right
corner of the screen to indicate whether the Update Processor is in
the Overtype mode or in the insert mode.
-
v to insert a value-mark.
to insert one space.
to undo the last change made.
?
when using the Update Processor to handle a dataname. If there is no
description for a dataname, no action is taken when you enter the ?
request.
The Update Processor 10-13
aaaaa
bbbbb
cecee
ddddd
allowed in the attribute. The system will beep if you attempt to enter
more than the specified number of multivalues.
We shall look at these and the other processing codes later.
Bridges,
Zooming,
Cruising,
Double-clutching,
will be of interest, and when editing general items -
such as text, macros,
menus and programs, then:
Prestored commands,
Spelling checking,
Cut and paste,
Search and replace,
CLIENT
000 1201 <= Client number
001 JONES BROS
002 34 HIGH STREET
003 234}345)567 <== Order numbers
ORDER
000 234 <= Order number
001 1201 <== Client number
002 8166
003 25000
BCLIENT;1;3
10.12.2 Cruising
"Y
Figure 10.7: Cruising
If an index is available for an attribute which is being handled by the
Update Processor, you may cruise through this index looking for the
required value. Let us illustrate this by considering the following scenario:
© You are using the Update Processor to maintain a purchase order
item on the PURCHASE.ORDER file, and ...
10-16 This is Advanced Pick
© You are required to enter a supplier code. This will be held as a data
field within the PURCHASE.ORDER item and is also the item-id of the
appropriate supplier item on the SUPPLIER file.
© You know the supplier's name SMITH but not the supplier code,
- -
but...
© Anindexis available for the SUPPLIER file based upon the supplier's
name.
Now, if instead of a supplier code you enter just the first few letters of
- -
key, then all the names in the index starting with SMITH SMITH, SMITH
-
key will take you back up the index. When the required name is
presented, you will press:
<Return>
or:
"M
and that supplier code will be placed into the field which is being updated.
This concept, known as cruising, is illustrated in Figure 10.7.
As we shall see later, these actions require that certain indexes and
pointers are created to link the files in this way.
10.12.3 Zooming
A further concept which is of value when two files are associated in this
manner is that of zooming. Zooming allows you to select an attribute in
the current item and use this as an item-id to go to the associated file and
process the corresponding item there.
Let us imagine that you are modifying an item on the ORDER file and that
the cursor is positioned at the CLIENT field where the client code is 8901,
the key to an item on the CLIENT file.
ORDER
Ref 12345
Date 29/07/93
Amount 25.00 "6G rf CLIENT
Client 8901 > Ref 8901
Name JONES & COMPANY
Address 34 HIGH ST..
Orders 2000]3000] ..
The Update Processor 10-17
the Update Processor will jump across to item 8901 on the CLIENT file,
where you can amend that CLIENT item. When you use a "X sequence
to file and terminate the activity on the CLIENT file, you will return to the
ORDER item. This is illustrated in Figure 10.8. As we shall see later,
these actions require that certain indexes and pointers are created to link
the files in this way.
10.12.4 Double-clutching
Let us imagine that you are using the Update Processor to modify item
3000 on the ORDER file, as illustrated in Figure 10.9. The concept of
double-clutching combines the actions of zooming and cruising to allow
you to use the current CLIENT field 8901 to pass to that item on the
CLIENT fle, and then to browse through the items on the ORDER file for
th att client.
ORDER
Ref 3000
Date 29/07/93
Amount 25.00 "GG r- CLIENT
Client 8901 Ref 8901
Name JONES & COMPANY
Address 34 HIGH ST..
Orders 2000]3000) ..
ORDER "GG
Ref 2000 <
Date 14/06/93
Amount 125.25
Client 8901
As we shall see, these actions require that certain indexes and pointers
are created to link the files in this way.
SUPPLIER file PURCHASE.ORDER file
10-18 This is Advanced Pick
1000 9007
01 SMITH & SONS 01 9630
02 ANSTEE PARK 02 1001
03 9009 03 12345
1001 9008
01 SMYTHE INDUSTRIES 01 9632
02 34 HIGH STREET 02 2000
03 9007 03 34575
2000 9009
01 WATKINS LTD 01 9635
02 123 ELLAND RD 02 1000
03 9008]9010 03 40025
3000 9010
01 LANDAU & SONS 01 9639
02 P.O.BOX 43 02 2000
03 4550
ADDRESS
dictionary-code A
attribute-count 2
PO. NUMBER
dictionary-code A
attribute-count 3
input-conversion IPURCHASE.ORDER;AO (3)
-
DICT of the PURCHASE.ORDER file
PURCHASE.ORDER
dictionary-code D
correlative BSUPPLIER: 2:3 (4)
18765A0 (5)
1p9010 (6)
macro DATE SUPPLIER AMOUNT (7)
DATE
dictionary-code A
attribute-count 1
output-conversion D2/ (8)
The Update Processor 10-19
input-conversion (9)
CU (10)
SUPPLIER
dictionary-code A
attribute-count 2
correlative TSUPPLIER;C;;1 (11)
input-conversion ISUPPLIER;A1 (12)
AMOUNT
dictionary-code A
attribute-count 3
output~conversion MD2 (13)
input-conversion MD2 (14)
In Figure 10.11, the bracketed references to the left of the important fields
denote:
1) 198761 is established by the CREATE-INDEX command which we use
to set up the index on attribute 1 (the name) of the SUPPLIER file.
13) The output conversion indicates that this field is to be displayed with
two decimal places.
14) The input-conversion indicates that this field can be entered in forms
such as 123 or 123.0 or 123.00 and is to be converted to the
equivalent internal form: 12300 implying two places of decimals.
We can now use the Update Processor to maintain items on the
PURCHASE.ORDER file by means of commands such as:
UPDATE PURCHASE.ORDER
to add a single item.
When you are using the Update Processor, you may want to repeat the
same sequence of commands several times. For example, you may
want to make the same changes to a number of items, or make the same
change at several places within a single item. The Update Processor has
a facility to create and execute a prestore command or sequence of
commands. The prestore command(s) are held in the prestore buffer,
and a number of Update Processor commands are available for
manipulating this buffer. These are illustrated in Figure 10.14.
o Create and modify the contents of the prestore buffer by means of
the sequence:
"ZL
(that is, prestore Write.) and when the Update Processor asks for the
prestore-id, enter:
prestore.id<Return>
specifying the name by which the prestore buffer is to be saved.
Figure 10.14 (a) shows the item which is actually created.
© Retrieve a previously saved item into the prestore buffer by means of
the sequence:
"2R
(that is, prestore Read), and when the Update Processor asks for the
prestore-id, enter:
prestore.id<Return>
specifying the name by which the prestore buffer was previously
saved.
© Retrieve and then execute a previously saved item by means of the
sequence:
"2R
and when the Update Processor asks for the prestore-id, enter:
prestore.id'P
specifying the name by which the prestore buffer was previously
saved. The saved command(s) will then be loaded into the buffer and
executed
In all cases, the prestore-id is entered in the form:
{(file.name} item.id
specifying the name of the file and the item-id. If the file name is omitted,
then it is assumed that the prestore command is held on the MD.
000 prestore.id
001 P <= Identifies a prestore item
002 A'xxx'R'yyy'N <= Update Processor commands
<
item
10-24 This is Advanced Pick
a)
(move the cursor to the next screen) is placed in the prestore buffer. For
this reason, the command:
will jump to the next page of your item. This applies until you change the
contents of the prestore buffer.
The Update Processor has facilities for manipulating a block of text using
the text processing technique known as cut and paste. This is
particularly useful when editing documents and Basic programs.
Current cut - -
Pick -
les
< "cP
"CR item
to mark the start of the block, and then move the cursor to the end of
the block and enter the sequence:
"cc
to mark the end of the block. The cut block is removed from the item
and loaded into the cut buffer.
o Cut and leave: mark a block of text and place it in the cut buffer,
The Update Processor 10-25
to mark the start of the block, and then move the cursor to the end of
the block and enter the sequence:
"ce
to mark the end of the block. The item is not changed, but the
marked block is loaded into the cut buffer.
© Paste the contents of the cut buffer: Move the cursor to the
required position, and the current contents of the cut buffer are pasted
into position using the sequence:
"CP
You should remember that the cut buffer is initialised each time you
invoke the Update Processor, so it is not possible to carry text from an
item in one session to an item in another (except by writing/reading the
cut buffer, as described below).
© Save the current contents of the cut buffer as an item on a file, using
the sequence:
"cw
(that is, Cut Write) and then, when the Update Processor asks for the
cut-id, enter:
cut.id <«Return>
specifying the id by which the cut section is to be saved.
© Retrieve and paste a previously saved cut section, the cursor is first
moved to the required position.
"CR
that is, Cut Read), and when the Update Processor asks for the cut-
id , enter:
cut.id <«Return>
specifying the id by which the cut section was previously saved. The
saved cut section will then be pasted into the current item. This action
is similar to the ME command of the Pick Editor.
{(file.name} item.id
specifying the name of the file and the item-id. If the file name is omitted,
then it is assumed that the cut section is held on the current file.
The cut buffer is empty when the Update Processor is invoked, and the
contents are lost when the UP session terminates. Thus, the buffer can
be used to pass text from one item to another in the same UP session,
but not between sessions.
10-26 This is Advanced Pick
and when the system asks for a replacement string, enter the
sequence:
yyyyy <Return>
or:
yyyyy"M
at any point. If, you restart the search, and there is already text in the
The Update Processor 10-27
search buffer, you can edit this using the normal Update Processor
<Ctri> keys.
'
If either the search string or the replace string contains the or
" '
characters, the string must be enclosed in and characters respectively.
Thus, you would use the command:
' "
to change all occurrences of to in the item.
The Update Processor has an automatic spelling checker based upon the
WORDS file held on the DM account. Whenever the spelling checker is
active and an unrecognised word is keyed-in, the processor will beep and
allow you to enter any of:
to accept the word.
'ata to accept the word and, when it is complete, add it to the
WORDS file.
to disable the spelling checker.
to cruise forwards through the WORDS file and find the
(alphabetically) next acceptable word.
to cruise backwards through the WORDS file and find the
previous acceptable word.
"28 to switch the spelling checker on/off from within the Update
Processor.
The S option on the UPDATE command will disable the spelling checker
at the start of the session. The TCL commands SPELLER / SPELLER-
ON / SPELLER-OFF can be used to interrogate / enable / disable the
spelling checker on your port.
The WORDS file on the standard AP system is empty. Before the
cruising facilities can be used, an index for the WORDS file must have
been created by means of the command:
CREATE-INDEX WORDS AO
10.12.10 Hotkeys
"Xn
and the Update Processor finds the entry CALL STOCK.HOT.1 in field 21
(the hotkey1 field) of the attribute definition for that attribute, it will call the
Basic subroutine STOCK.HOT.1. Similarly, the hotkey "X5 would call the
subroutine EMERGENCY.CHECK.
The Basic subroutines which are used as hotkey routines have the
familiar form, with the following observations:
© The first statement in the subroutine will be of the form:
SUBROUTINE subroutine.name (parameter)
14.
If several hotkey subroutines are to be called one after another, these will
be specified as multivalues:
21 CALL STOCK.CHECK]CALL STOCK.HOT.1
11
-
is created as an item on a file. The individual lines (or attributes) of the
document comprise:
Output Processor does not include its own text input or editing facility, but
the Update Processor is an ideal tool for use in creating and maintaining
text item(s) for the Output Processor. As we saw in the previous Chapter,
the Update Processor offers facilities such as:
The Output Processor can also be used as a tool within Basic programs,
displaying and/or printing messages, explanations, help texts and so on.
Using the Output Processor in this way reduces the programming effort
in formatting and outputting the text, and the fact that the text is held
outside the program makes it more flexible and easier to amend the text
at any time, and also means that the same text can be incorporated
directly into the user documentation.
As you see, the item consists of text and OP commands. The final output
version of this document is shown in Figure 11.2.
07 INDEX
08 _.LINE LENGTH 60
09
10 . INDENT MARGIN -5 .JUSTIFY
11 All Output Processor commands begin with a dot, and the
commands may be specified on separate lines or they may be
embedded within the text provided that a space comes before
-
OP MB.TEXT SAMPLE1 (P
The final output document would look like that in Figure 11.2.
11-4 This is Advanced Pick
JUSTIFY
-XJUSTIFY
«INDENT MARGIN
- INDEX
» LINE LENGTH 60
All Output Processor commands begin with a dot, and the commands
may be specified on separate lines or they may be embedded
within the text provided that a space comes before and after
-
* Not justify the text, that is, it will not make the right
margin even. The .JUSTIFY command is available to make the
left and right margins even.
* Not capitalise the first letter of each sentence. The .CAP
SENTENCES command is available to ensure that each sentence
starts with a capital letter.
* Break a hyphenated word at the hyphen if it is too long to
fit on the line.
The lines of text in your original document may be as long or as
short as necessary.
Any spaces in the text are left exactly as they are. So, if
you want two spaces after each sentence, you must type them in.
The Output Processor is not wysiwyg what you see is what you get.
-
The original text and the final document are quite different in appearance.
The true appearance of the document is only seen when it is finally
displayed or printed on the printer. This fact, together with the
requirement that the user must be familiar with the Update Processor in
order to create and maintain the document, means that the Output
Processor is often rejected in favour of other software.
11.2 OP command
where file.name is the name of file holding the document(s), and item.list
is a sequence of one or more item-ids identifying the documents which
are to be output; the item list may be omitted if a select-list is available.
The options are shown in Figure 11.3.
n.m
x analyse the usage of the words in the document and place the
results into the WSYM file.
and margin size other commands enable and disable specific features
-
and effects italics on, italics off, bold-face on, bold-face off:
-
«CAP SENTENCES cs
«CENTER .c
-ITALICS IT
-XITALICS XIT
«INDENT MARGIN 5 -IM 5
-JUSTIFY J
«XJUSTIFY XJ
«LINE LENGTH 60 LL 60
documents.
11.4 Quick OP
Don't let any fear of having to master a vast number of commands put
you off using the Output Processor. If you simply want to create a
document to print a piece of text, then you need only remember a few
points and a small number of commands:
o You can hold the text of your document in any item on any file.
© The lines of the raw (input) text can be any length. The Output
The Output Processor & Runoff 11-7
Processor will break them down to the length to fit your screen or your
printer, or to the line length which you specify.
© You will use the Update Processor to create the text item:
UPDATE file.name document.name
© When you have filed your document away, you will use a command
such as:
OP file.name document.name
to display the document, or:
OP file.name document.name (P
to print the document, specifying the name of the file and the item
where the text is held.
lf you want to use more than this of the Output Processor, then a few
commands will be of interest:
JUSTIFY
make the right-hand margin even.
-SKIP 2
- INDENT MARGIN -5
indent the left margin five places to the left.
. CENTER
output the following line in the centre of the page.
» LEFT MARGIN 8
set the left margin of the document 8 places from the edge of the
paper.
LINE LENGTH 60
set the page width to 60 characters.
-PAPER LENGTH 60
set the page length to 60 lines.
.»PARAGRAPH 0
do not indent the first line of each paragraph. A space at the start of
a line will skip a blank line and start a new paragraph.
-PARAGRAPH 10
indent the first line of each paragraph 10 places to the right.
frrff
READ 11111
incorporate the text held in item jiiii on file f at this point as the
11-8 This is Advanced Pick
The Runoff text processing system was provided as a standard part of the
R83 Pick system and, for compatibility it is still supported on Advanced
Pick systems. The Output Processor is descended from Runoff and both
are provided for the production of documents, manuals, specifications,
and similar printed matter. The major difference is that the OP has been
extended to exploit the features of current printers and printer technology,
and has provided for features such as bold-face and underlining in a
more consistent manner than does Runoff.
A list of the Runoff commands is given in the Appendix. As you will see,
Runoff commands are very similar to those of the Output Processor
except that Runoff commands must be specified on separate lines and
cannot be embedded amongst the text of the item. Otherwsie, Runoff is
used in the same way and for the same purposes as the Output
Processor. Let us illustrate Runoff by looking at a simple document. A
typical item is illustrated in Figure 11.4.
This is typical of the format of a Runoff document. It is
made up of lines of text and (optionally) Runoff command
lines. Some commonly-encountered Runoff commands are:
» INDENT MARGIN 5
»NOFILL
-NOJUSTIFY
FILL
- INDENT MARGIN
» INDEX
- JUSTIFY
«NOFILL
«INDENT MARGIN -5
«FILL
«JUSTIFY
All Runoff commands begin with a dot in the first position.
The Output Processor & Runoff 11-9
to print the document, then the final document would look like that in
Figure 11.5.
This is typical of the format of a Runoff document. It
is made up of lines of text and (optionally) Runoff command
lines. Some commonly-encountered Runoff commands are:
»NOJUSTIFY
«FILL
» INDENT MARGIN
- INDEX
-JUSTIFY
«NOFILL
Since every Advanced Pick system comes equipped with both the Output
Processor and Runoff, and the Output Processor is more powerful, why
should you bother with Runoff? If you are coming new to AP without any
experience of R83 Pick or similar systems, then, if you use a text
processing system at all, it will probably be the Output Processor.
However, many people migrating to AP from R83 Pick and the like may
have brought a considerable library of Runoff documents with them: it is
for these organisations and their users that have included this brief |
summary of Runoff.
11.8 RUNOFF command
where fife.name is the name of file holding the document(s), and item. list
is a sequence of one or more item-ids identifying the documents which
are to be output; the item list may be omitted if a select-list is available.
The Output Processor & Runoff 11-11
Don't let any fear of having to master a vast number of commands put
you off using Runoff. If you simply want to create a document to print a
piece of text, then you need only remember a few points and a small
number of commands:
You can hold the text of your document in any item on any file.
The lines of the raw (input) text can be any length. Runoff will break
them down to the length to fit the line length which you have specified.
A line beginning with a space will indicate the start of a new
paragraph.
You will use one of the editors to create the text item:
UPDATE file.name document.name
11-12 This is Advanced Pick
o When you have filed your document away, you can use the TCL
RUNOFF command:
RUNOFF file.name document.name
to display the document, or:
RUNOFF file.name document.name (P
to print the document, specifying the name of the file and the item
where the text is held.
© Certain print effects are produced by means of contro! characters:
& underline the following character
&A enable underlining on all subsequent text
&\ disable underlining
output the following character in bold-face
@* enable bold-face on all subsequent text
@\ disable bold-face
If you want more than this of Runoff, then a few simple commands will be
of interest:
»NOJUSTIFY
stop Runoff making the right-hand margin even.
SKIP 2
skip two blank lines.
» INDENT MARGIN 5
indent the margin five places to right.
«INDENT MARGIN -5
indent the margin five places to the left.
-NOFILL
output all subsequent text exactly as it is entered. You might use this
when entering a table of information which is to appear exactly as you
type itin.
«FILL
reset the .NOFILL action and cause all subsequent text to be
reformatted to fit the page width.
. CENTER
output the following line in the centre of the page.
LEFT MARGIN 8
set the left margin of the document 8 places from the edge of the
paper.
.LINE LENGTH 79
set the page width to 79 characters.
+PARAGRAPH 10
The Output Processor & Runoff 11-13
PARAGRAPH 0
do not indent the first line of each paragraph.
-PARAGRAPH -10
indent the first line of each paragraph 10 places to the left (a hanging
paragraph).
-READ fff£ff Liiii
incorporate the text which is held in item iiiii on file fat this point as
the document is being output.
-BEGIN PAGE
skip to a new page.
With these commands and the following rules concerning the use of
commands:
© Each Runoff command or sequence of Runoff commands must be on
a separate line and the full stop must be the first character on the line,
© Runoff commands may be in upper- or lower-case,
and copying the illustrations shown in this Chapter, you should be able to
get started with Runoff.
11.10 Summary
12
you can type in any Access sentence and this will be processed and the
report will immediately be displayed on your screen or printed on the
printer.
might display a report starting like that in Figure 12.1 (a), showing the
item-ids of the items on the STOCK file, together with the DESCRIPTION
and the PRICE of each item. Words such as DESCRIPTION and PRICE
are datanames which identify parts of the data on the STOCK file. You
-
or your Systems Analyst will have set up these datanames on the
-
adding the word LPTR to the sentence, then the same report would have
been produced on the printer.
One of the beauties of Access is its flexibility; you can ask for any of the
datanames for the file, you can ask for the datanames in any order, and
you can ask for as many datanames as you want. If we had typed the
sentence:
LIST STOCK PRICE DESCRIPTION QUANTITY
these are optional and can be included or omitted as required; you don't
type in the curly brackets. Although I've had to spread this sentence over
several lines, you will type the entire sentence as a single line, just like
any other TCL command.
Access: the enquiry language 12-3
If you omit all the optional elements, you produce the simplest possible
Access sentences:
LIST STOCK
COUNT STAFF
Provided that you put the verb at the beginning of the sentence, the rest
of the elements can come in any sequence. For example, we could issue
a sentence such as:
if we wanted a list of all the desks sorted in order of price; I've indicated
the four elements. We could have typed this same sentence with the
elements in a different sequence, such as:
or even:
or the equivalent:
where we sort the items first BY TYPE and then if there are several
-
items of the same type BY PRICE. However, you must not split an
-
with the BY PRICE splitting up the WITH TYPE = "DESK" element, would
be wrong and the Access processor would reject it.
12.3 Access verbs
The verb is the first word of an Access sentence. There are many
Access verbs available, and each one has a slightly different action from
the others. By far the greatest use is made of the verbs LIST and SORT.
HASH-TEST
produce the item statistics for a file based upon any hypothetical test
modulo. We met this in Chapter 4.
ISTAT
produce the item statistics for a file. We met this in Chapter 4.
LIST
produce a report showing the items on a file and in the same order
that they are held on the file.
REFORMAT
SREFORMAT
reorganise the data within the items to produce new items on another
file.
SORT-ITEM
LIST-ITEM
produce a report showing the contents of the items on a file.
SORT~LABEL
LIST-LABEL
produce a report in label format.
SORT
produce a report with the items sorted into a specified sequence.
SELECT
SSELECT
create a list of the item-ids of the items on a file which can be used by
another command.
STAT
produce a report showing the total and average size of items on a file.
Access: the enquiry language 12-5
SUM
produce a report showing the total of a data name of the items ona
file.
S~DUMP
T-DUMP
dump one or more items to backing storage.
T-LOAD
restore one, several or all the items to a file from a diskette/tape
produced by the T-DUMP / S-DUMP command.
LIST-1TEM AN sort-1TEM
SELECT ANd sseLect
T-pump and s-pump
and even LIST and SORT. In all cases, the sorting form is used if you
specify any sort specifications in the sentence. Thus,
LIST STOCK BY PRICE DESCRIPTION PRICE
and:
SORT STOCK BY PRICE DESCRIPTION PRICE
will present the items in the order that they are found on the file, but:
will present the items sorted into ascending order of their item-ids. This
distinction applies to all the sorting/non-sorting pairs.
CARS, DECEMBER
to process the items held on the DECEMBER data section of the
CARS file.
DICT STOCK
to process the items held on the DICT section of the STOCK file.
MD
to process the items held on the MD.
12.4.1 LISTFILES
{f you have forgotten the name of the file that you want to use in your
Access sentences, commands such as:
LISTFILES
will display the names and other details of the files which are available
to you on this account. An example of the report is shown in Figure
4.19.
LISTFILES (P
will produce the same report on the printer.
LISTFILES (C
LISTFILES (CP
will show just the names of the files on this account.
The item-ids,
o Any TOTALIed fields,
eo
Any BREAK-ON fields,
together with any other datanames which you include in the sentence.
The datanames for the individual pieces of information which are to
appear in the report make up what is known as the output list. Thus, the
sentence:
LIST STOCK PRICE
will produce a report containing the item-ids and one column of data: the
PRICE. Thatis, the output list comprises just the PRICE. The sentence:
Access: the enquiry language 12-7
will produce a report showing the item-ids, the DESCRIPTION and the
VALUE. The output list comprises the DESCRIPTION and the VALUE.
The use of the sort specification BY PRICE to specify the order in which
the items appear in the report does not automatically include the PRICE
in the output list for the report. The sentence:
will show the item-ids, the NAME and the SALARY. The use of the
TOTAL keyword to add up the individual SALARY fields will include the
SALARY in the output list for that report.
There is no limit to the number of datanames which you can ask for in
your output list, and you may ask for any dataname several times, if you
wish.
STOCK 9999
DESCRIPTION CHAIR, BLUE, PINE
LOCATION MN/16/69
SUPPLIER NAME A.B.ATKINS AND Co
SUPPLIER ADDRESS PO BOX 134 ALTRINCHAM CHESHIRE AL9 9LA
SUPPLIER TELEPHONE 061-999 2375
STOCK : 3333
DESCRIPTION CHAIR, WHITE, LAMINATE
LOCATION MN/19/13
SUPPLIER NAME A.B.ATKINS AND CO
SUPPLIER ADDRESS PO BOX 134 ALTRINCHAM CHESHIRE AL9 9LA
SUPPLIER TELEPHONE 061-999 2375
STOCK : 6666
DESCRIPTION SIDEBOARD, ORANGE, OAK
LOCATION LS/17/33
SUPPLIER NAME ROGER PETERSEN PLC
SUPPLIER ADDRESS 98 WALTHAM CROSS WALTHAM FOREST ESSEX
SUPPLIER TELEPHONE 081-999 4767
LISTDICT STOCK (P
to produce the report on the printer. In either case, the report will show
all the attribute definitions which define the datanames on the dictionary
of the file. As the fragment in Figure 12.4 shows, the LISTDICT report
Access: the enquiry language 12-9
includes one entry for each dataname, and shows various pieces of
information about the attribute definitions which are available for use with
the file. The datanames shown in the first column of this report may be
freely used in Access sentences which handle that file.
We'll look at the meaning of the various parts of these attribute definitions
when we look at the structure of dictionary items later.
COLOR A 1 G11 10
60,1
COLOUR A 1 Gl 1 10
60,1
DESCR A 1 DESCRIPTIO 25
N
DESCRIPTIONA 1 T 25
MATERIAL A 1 G21 T 10
TYPE A 1 60,1 10
QTy A 2 R 3
QUANTITY A 2 R 1
BAY A 3 G1/1 10
DEPOT A 3 GO/1 10
DEPOT.NAME A 3 GO/1 T 20
TDEPOT;C731
FIRST. LOCATAON 3 UC07031 10
LOCATION A 3 10
SHELF A 3 G2/1 10
PRICE A 4 PRICE MD2 R 6
MIN A 5 R 3
MINIMUM A 5 10
SUPPLIER A 6
SUPPLIER.ADARESS 6 Supplier a TSUPPLIERsC232 T 20
ddress
SUPPLIER.NAAE 6 TSUPPLIERsC3 11 T 20
SUPPLIER.TEAEPHONE 6 Supplier t TSUPPLIER;C;33 T 20
elephone
DATE A 7 D2 R 9
MOVED A 7 b2 R 9
If you don't know the datanames which are available to you for a
particular file, or even if there are no datanames at all for the file, then
you can use the set of temporary attribute items. These have the
names:
and so on, and can be used just like the regular datanames mentioned
here. They may be used with any file in sentences such as:
SORT STOCK Al A2 A3 A4 BY A7
SORT STOCK Al TOTAL A2 A3 TOTAL A5
12-10 This is Advanced Pick
If the file dictionary contains actual datanames A1, A2 and so on, these
will be respected and will take precedence over the temporary attribute
items.
The AO, A1, A2 names continue indefinitely, although the following are of
special interest:
A9998
to output a sequential number. You can think of this as a line-number
on the report.
A9999
to output the length of the item in bytes.
1000 1 18
2000 2 64
3000 3 66
4000 4 62
5000 64
6000 6 64
7000 7 62
8000 8 62
9000 9 68
with the data of another, then you can use the USING keyword in a
sentence such as:
SORT COPY.STOCK USING DICT STOCK DESCRIPTION TOTAL VALUE WITH TYPE
"DESK"
001 A
002 9999 0
003 Lines Bytes Count
004
005
006
007
008 U201E ec' c;'1'
009 R
010 5 5 5
(a)
1000 7 18 1
2000 7 64 1
3000 7 66 1
4000 7 62 1
5000 7 64 1
6000 7 64 1
7000 7 62 1
8000 7 62 1
9000 7 68 1
(b)
*LINES
outputs the number of attributes in the item.
12-12 This is Advanced Pick
*BYTES
outputs the size of the item in bytes. This is like temporary attribute
item A9999 mentioned earlier.
*GAP
outputs a blank column (three spaces in width) to give more space
between the columns of the report. The heading in attribute 3 is three
spaces, although you cannot see this in Figure 12.6 (a).
®ONE
LIST STOCK
SORT STOCK BY TYPE
LIST STOCK WITH TYPE "DESK"
which do not include an output list, then you might expect just a single
column the item-ids to be produced. But Access will let you (or your
- -
as the default output list or the implicit output list which will be used
-
If you don't specify an output list in your sentence. This saves typing an
output list with every Access sentence. Typically, the Systems Analyst will
create a default output list which includes the most important fields for
each file: the name, initials and department of the STAFF file, the name
and telephone number of the SUPPLIER file, the description, price,
quantity and location for the STOCK file, and so on.
then any default output list will be ignored. If there is a default output list
and you don't want it to be used, you can include the ONLY keyword in
the sentence:
Unless you impose any special conditions in your Access sentence, the
report will normally include ail the items on the file. This is not always
desirable. For example, you mayy just be testing an Access sentence and
only be interested in whether the sentence works or not. The SAMPLING
keyword will enable you to restrict your report to a specific number of
items on the file. For example, sentences such as:
will show only the first twenty items on the file, and:
will show only the first ten items which refer to desks.
If you want a range of item-ids, then it may be simpler to use forms like
12-14 This is Advanced Pick
these:
LIST STOCK > '1000' DESCRIPTION PRICE LOCATION
LIST STOCK "1000" DESCRIPTION PRICE LOCATION
>»
to show only those desks of which we have more than 50 units in stock.
Note that the values which you are seeking 50 and DESK in the last
-
> signs of our examples, you can use any of the symbols shown in Figure
12.7. lf you omit the symbol, as in Figure 12.8, then the sign is
assumed
Incidentally, British users may have some difficulty finding the key which
displays the character #. On some keyboards, it is represented by the
pound sign £ and on others by the hash or sharp sign #. It's usually the
character above the number 3 on the top row of the keyboard.
WITH NO QUANTITY
WITHOUT QUANTITY
IFNO QUANTITY
will show only those items which have a null QUANTITY.
as illustrated in Figure 12.10. Here, only the zero value for item 8763
appears.
Let's imagine that you want a list of all the products on the STOCK file
which are made of pine. If you were to use a sentence such as:
then you would not find any items which satisfy this requirement, because
all the STOCK items have descriptions such as:
and there is no item with a description which consists just of the four
letters PINE, which is what the Access sentence asks for. The value in
quotation marks must match exactly with the value of that dataname on
the file.
For our STOCK file, we have been fortunate because the Systems
Analyst has created the dataname MATERIAL which picks out the last
word of the description, so you could issue the sentence:
But there is another, more general way of looking for a partial string, by
means of a sentence such as:
LIST STOCK WITH DESCRIPTION = "(PINE" DESCRIPTION
which displays details of any items of which the description ends in the
letters PINE. The resultant report is illustrated in Figure 12.11.
STOCK DESCRIPTION
The brackets are used singly or in pairs, as illustrated here, and they
behave rather like the « wild card character which you may have met in
DOS. Access has another wild card character:
A
This represents any single character and behaves rather like the 7 wild
card character which you may have met in DOS. Thus, if want to |
produce list of all the products which have DESCRIPTIONSs starting with
a
or if want all those which have a five-letter word for the type, might use:
| |
to produce a report which includes CHAIRs and TABLEs, but not DESKs
or SETTEEs.
12.8 Sort specifications
The LIST verb produces a report showing the items in the order that they
appear on the file. As we saw in Chapter 4, Advanced Pick does not hold
the items in any special order, it's just the order that the items were
placed when they were added to the file or changed or deleted. If we
were to issue the sentence:
LIST STOCK DESCRIPTION
one day, this might show the items in one sequence, and if we issue the
same sentence next day, the items might appear in a different sequence.
Access: the enquiry language 12-19
With most commercial reports, you will want the items to appear in some
particular sequence; for example, on the STOCK report, you might want
the product numbers (that is, the item-ids) to appear in numerical order,
or you may want the items to be sorted into alphabetical order of
description. To produce a report in which the items are sorted by item-id,
you will use the:
SORT
verb, as illustrated by the fragment in Figure 12.12. This sorts the entries
in the report into order of ascending item-d. The items on the disk file are
unchanged by this and any other Access process.
- -
STOCK DESCRIPTION
Incidentally, even though you are sorting the report in price sequence, the
PRICE won't automatically appear in the report; if you want to see the
PRICE, you have to include PRICE in the output list.
If you want the highest prices first, then you can sort the report in
descending order, like this:
SORT STOCK BY~DSND PRICE WITH PRICE > "20" PRICE TYPE
Without the BY-EXP keyword, only the first multivalue is used for sorting
purposes, although the other multivalues appear in the order in which
Access: the enquiry language 12-21
they are held on the file. Compare the entries for item 8763 on the two
reports in Figure 12.14.
you may find that the final report looks better if you skip a few lines
between the various types or the various departments, thereby making it
easier to identify the individual groups. Such a visual effect is known as a
control break and is produced by including a clause such as:
BREAK-ON TYPE
or:
BREAK-ON DEPARTMENT
This is illustrated in Figure 12.15. Note that, when you use the
BREAK-ON keyword, the dataname will automatically be included in the
output list for your report, and in the position implied by the position of the
BREAK-ON clause in the sentence.
As you see, a line of asterisks is displayed at each control break. You can
suppress these by using a form such as:
BREAK-ON TYPE " "
which will suppress the asterisks (it actually replaces them by a space),
or you could use:
which will print a string of = signs (or any other message you wish) at
each control break. Within the "xoox" message after the BREAK-ON
keyword, you can include any text and special options to call up other
features. These include:
The BREAK-ON field is always included in the output list; this may not be
desirable. One way around this is to use the ROLL-ON keyword. The
sentence:
SORT STOCK BY TYPE ROLL-ON TYPE " " DESCRIPTION TOTAL VALUE
will produce exactly the same output as Figure 12.15 but without the
TYPE column.
You may have several control breaks:
SORT STAFF BY SITE BY DEPARTMENT BY NAME BREAK-ON SITE BREAK-ON
DEPARTMENT
Take care when you do this, because the Access processor will produce
one control break whenever there is a change of SITE and another
12-24 This is Advanced Pick
If you use DET-SUPP and BREAK-ON in the same sentence, the detail
lines will be suppressed and at each control break there will appear
- -
any subtotals for any TOTALIed fields, and for other fields there will
appear the previous entry in that column (that is the last entry just before
the control break); the item-ids will not appear. Compare the report in
Figure 12.15 with that in Figure 12.16.
PRICE, QUANTITY, VALUE, AGE and so on. You can add these up as
they are displayed and show the totals at the end of the report, if you
include:
TOTAL VALUE
or:
TOTAL QUANTITY
The TOTAL keyword causes the totalled field to be included in the output
list.
If you use the BREAK-ON keyword in your report, then the subtotals of
any TOTALIed fields will be shown at each control break. Figure 12.15
illustrates this.
XR{b}
This is used as an input conversion and produces a running subtotal of a
dataname when used with the TOTAL keyword in an Access sentence.
The optional b specification indicates the number of break-levels to which
the subtotalling is to be restricted.
12.11 GRAND-TOTAL
The TOTAL keyword produces a grand total at the foot of the report
beneath the QUANTITY and the VALUE columns. This grand total line
will be identified by a line of asterisks at the left of the page. As the
BREAK-ON keyword can specify an alternative text at the control break,
so the GRAND-TOTAL keyword can be used to specify a message for the
final grand totals:
GRAND-TOTAL "text"
to produce the report shown in Figure 12.17. Compare this report with
those in Figures 12.15 and 12.16.
GRAND-TOTAL "SUMMARY'U'"
will display the word SUMMARY and underline the grand total figure.
GRAND-TOTAL "January''s final figures'UP'"
will skip to a new page before printing the final figure and then
underline the grand total.
5870.00
17248.00
6800.00
in your Access sentence if you want to print the report on the printer
instead of displaying it on the screen. The word is actually an
abbreviation for line-printer.
Like the other elements which make up an Access sentence, LPTR can
come anywhere in the sentence after the verb.
WHO LPTR
COPY STOCK LPTR
12.12.1 TCL-SUPP
When an Access sentence produces a report on the printer, the sentence
is normally repeated at the head of the report. If you don't want this, the
action may be suppressed for an individual report by using the TCL-SUPP
keyword:
LIST STOCK DESCRIPTION TCL-SUPP LPTR
The action can be disabled/enabled for all your Access reports by means
of the TCL-HDR-ON and TCL-HDR-OFF commands. The TCL-HDR
command will display a message indicating whether the action is in
operation or not.
The LEGEND facility allows the System Manager to specify a piece of text
which is to appear at the foot of every Access report sent to the printer.
The text of this system-wide legend is specified (in Output Processor
format) in an item with the item-id LEGEND which is held on the
MESSAGES file. An item containing a legend for a specific user may be
created on the MESSAGES file with the item-id:
LEGEND*user.id
Asimple legend might include your company name, like that illustrated
in Figure 12.18.
01
02
03 Malcolm Bull / Training & Consultancy Services
and the action can be disabled/enabled for all your Access reports by
means of the LEGEND-ON and LEGEND-OFF commands. The
LEGEND command will display a message indicating whether the action
is in operation or not.
your report, showing the page number, the name of the file, the date and
the time, as we saw in Figure 12.1. But you may wish to specify your own
heading and this can be achieved by means of the HEADING keyword,
like this:
Stock Report
will appear at the top of each page of your report, replacing the standard
heading.
If you wish, you can have your own heading at the top of each page
and/or your own footing at the bottom of each page. This is illustrated
by the fragment in Figure 12.19 which was produced by the sentence:
SORT STOCK BY PRICE DESCRIPTION PRICE
HEADING "'C'Stock Report'LC' 'h'"
FOOTING "End of page 'PN' of the report"
You can use HEADINGs and FOOTINGs with displayed reports and with
printed reports.
You can control the text of the heading and footing by means of a set of
option codes within the text of the heading or the footing, as we see in
the following section.
Stock Report
7 to output the date and time in the form: 09:30:59 01 Jan 1995
If you wish to include an
apostrophe in your heading or footing, you will
represent this by two apostrophes. For example, you might use the
heading
HEADING Kathy O''Donnell''s report **'LL'"
to output:
** Kathy O'Donnell's report **
followed by two blank lines at the top-centre of every page of the report.
if there are two adjacent codes, you will enclose them in one set of
apostrophes, as these examples illustrate:
HEADING "'C'** Sales Report *#'LC!+++++++++44+4444444'L'" FOOTING
"*LL'Produced 'T* Page 'PN'*
which will change the normal form of an Access report or modify the
normal action of the Access processor. We have already met
GRAND-TOTAL, BREAK-ON, BY, FILL, SAMPLING and DET-SUPP.
Others which you may find useful are:
ID-SUPP
suppress the item-id which is normally shown in the first column of the
report. When ID-SUPP is used, only the datanames in the output list
(or the implied output list) will appear in the report.
HDR-SUPP
SUPP
either of these will suppress the normal page heading.
COL-HDR-SUPP
suppress the page heading and also the column headings.
12-30 This is Advanced Pick
DBL-SPC
produce double-spaced output, skipping a blank line between each
item.
DUPLICATE
used with attributes for which an index is available and will allow you
to select or avoid duplicate fields. The sentence:
will show only those items which have the same price as other items.
NI-SUPP
suppress the final message which shows the number of items listed.
NOPAGE
suppress the normal action of pausing at the foot of each page when
you are displaying a report on the screen. You might use this if you
are only interested in the last page of a report. This has no effect if
the report is going to the printer.
As you might expect, you can put these keywords anywhere in your
Access sentence:
LIST STOCK DESCRIPTION PRICE ID-SUPP
LIST STOCK DBL-SPC NI-SUPP
SORT STOCK BY TYPE BREAK-ON TYPE TOTAL PRICE DET-SUPP
SORT STOCK COL-HDR-SUPP ID-SUPP DBL-SPC LIST STOCK ID-SUPP DET-SUPP
ISTAT STOCK NOPAGE
and you can use these anywhere within a sentence to make it read more
naturally. Throwaways are completely ignored by the Access processor.
If you are likely to be creating your own attribute definitions, take care that
you don't use any of these throwaways as your datanames; if you do, they
will be ignored. The command:
LISTCONN
or:
LISTCONN (P
will produce a list of the modifiers (or connectives) which are available
with Access sentences.
12.15 Predefined phrases
sTDl
Ol H
02 BY TYPE DESCRIPTION BREAK-ON TYPE TOTAL VALUE
(a)
name
o1 R
02 file.name <s2= file
holding phrase
03 phrase.name <=== name of phrase on that file
(b) A remote phrase
Figure 12.21: Phrases
12-32 This is Advanced Pick
Phrases may be used in any appropriate context and may be mixed with
other phrases, clauses, datanames and/or modifiers:
SORT STOCK > '1000" WITH PRICE > "50" STD1 LPTR
Typically, phrases will be held on the dictionary of a file where they are
used, as in this example, or they may be held on the MD. A remote
phrase may be set up to refer to a phrase held on another file, as shown
in Figure 12.21 (b), which shows the name of the file and the item where
the true phrase is held.
The item-id of the phrase may be any name which does not conflict with
the standard datanames and Access keywords. A special phrase may be
set up with the item-id:
Qfile.name
or:
9
and this will define a default output list to be used when no other output
list has been included in the sentence, as we mentioned earlier. Thus, if
you issue a sentence such as:
LIST STOCK
the Access processor will search for a phrase with the item-id @STOCK
or @ and append this to the sentence. Ifa file has severa/ data sections,
then a sentence such as:
1 2 3 BY DESCRIPTION
Let us imagine that you have a STAFF file and that you need to produce
a series of reports concerning the employees aged 60 or over. When you
issue a sentence such as:
the Access processor will read every item on the file to determine whether
or not that employee is 60 or over. If you then need to produce another
report about these same employees with a second sentence:
Yes. If you are going to process the same subset of items on a file the -
employees aged 60 or over several times, then you can save yourself
-
which produces a select-list, that is, a list of the item-ids of all employees
who satisfy the selection criteria, and then immediately save the list by
issuing a command such as:
SAVE-LIST ELDERS
to save the select-list of eligible item-ids with the name ELDERS; you can
use any name here. This saved-list will be saved on the POINTER-FILE
file which is provided just to hold such lists. You may subsequently recall
and use the saved-list whenever you need it. This is done by a command
such as:
GET-LIST ELDERS
GET~LIST ELDERS
SORT STAFF BY DEPARTMENT NAME BREAK-ON DEPARTMENT
Access: the enquiry language 12-35
These two sequences have the same effect as the sentences at the top
of this section, but using saved-lists makes the reports much faster.
Figure 12.22 shows the screen display when this sequence of commands
was used.
:GET-LIST ELDERS
[4041 63 items selected out of 1 items.
sLIST STAFF NAME DEPARTMENT LPTR
Entry #1
:GET-LIST ELDERS
[404] 63 items selected out of 1 items.
:SORT STAFF BY DEPARTMENT NAME BREAK-ON DEPARTMENT LPTR
Entry #2
verbs or any of the other verbs shown below then the next command
- -
which you give will use that select-list. Thus, if you use a sequence of
commands such as:
SELECT STOCK WITH TYPE "DESK"
EDIT STOCK
you will edit only the DESK items on the STOCK file.
SELECT STOCK WITH TYPE "DESK"
SELECT STOCK WITH PRICE > "25.50"
SAVE-LIST DESK50
create and save a list of the item-ids of all the items which are desks
and cost more than 25.50.
EL ELDERS
invoke the Update Processor to create a new list or to change a
saved-list.
COPY-LIST ELDERS
CL ELDERS
either of these will copy a saved-list and saved it under another name,
or save it as an item on an ordinary file. The options on the COPY-
LIST command are much the same as those for the COPY command.
COPY-LIST ELDERS (T
display the contents of a saved-list.
COPY-LIST ELDERS (P
print the contents of a saved-list.
DELETE-LIST ELDERS
DL ELDERS
either of these will delete a saved-list. It is good practice to delete any
lists when you no longer need them, thereby saving space on the
system.
SORT-LIST ELDERS
sort the contents of a saved-list into ascending alphanumeric order.
GET-LIST ELDERS
SSELECT ELDERS BY BIRTH. DATE
SAVE-LIST ELDERS
sort the contents of a saved-list into some other order, as indicated on
the SSELECT sentence.
LIST-LISTS
LL
either of these will display the names of the lists which are currently
saved on the POINTER-FILE.
ISELECT
ISSELECT
either of these will select all the items which are in the same physical
group as a specific item:
ISELECT file.name item.id
ISSELECT file.name item.id
NSELECT
produce list of items in the current select-list which are not present
a
SELECT FILE1
NSELECT FILE2
produce a select-list of all those items which are present on FILE1 but
not on FILE2.
COMPARE-LIST
compare the contents of two saved-lists:
COMPARE-LIST {file1} listl {operator} (file2} list2 {file3}
{list3}
reporting those items which occur in both lists (using the & operator),
12-38 This is Advanced Pick
not in both lists 0), in either list (=), in the concatenation of both lists
(+), or in the difference of list? minus /ist2 (-), to display the results or
produce a new saved-list.
Using the commands illustrated above, your lists will be saved on the
standard POINTER-FILE file; this is shared by all users. Whenever you
save a list, it is good practice to make a written note of the name of the
list, when you created it, and what it is used for. You should also be sure
the use LIST-LISTS and DELETE-LIST to monitor and remove any lists
which are no longer needed. If you are creating and saving a list for
short-term use, then you can save a little time by omitting the name of the
list entirely:
SAVE-LIST
GET-LIST
EDIT-LIST
case, Advanced Pick will use the list saved on the standard
In this
POINTER-FILE with the name:
su
If you wish, you can save your lists on any file, it doesn't have to be the
POINTER-FILE. good idea to hold your saved-lists on your own file
It's a
if you want to retain them for a long time, or if they are large and might
hinder other users. To do this, you simply include the name of your file in
the command which refers to the list:
and so on.
Although our examples use lists which are made up of item-ids, you can
creates lists from any attribute(s) on a file. For example:
SELECT STOCK SUPPLIER
generate a select-list consisting of the supplier codes (defined by the
dataname SUPPLIER) taken from the items on the STOCK file.
SSELECT STOCK DESCRIPTION PRICE WITH TYPE "DESK"
generate a select-list consisting of the descriptions and prices of
items. This is illustrated in Figure 12.23.
:COPY-LIST DESKXXX (T
DESKXXX
001 DESK, GREEN-BLUE, ASH
002 5600
003 DESK, BLUE, OAK
004 5600
005 DESK, BLACK, MAPLE
006 5600
007 DESK, WHITE, ASH
008 5600
009 DESK, GREEN, ASH
010 5600
SELECT ...
SSELECT ...
GET~LIST ...
QSELECT ...
will select all items on FILEA with item-ids starting with A and use these
(the primary list) as the item-list on the COPY command, and then select
all items on FILEB with item-ids starting with Z and use these (the
secondary list) as the item-list on the destination line. Other commands
which can use the primary and secondary lists are:
COMPARE
COMPARE-LIST
thus allowing a program to pick up keys from the secondary list and
handle two select-lists at the same time.
to suppress the number of items listed at the foot of the report. This
J
is equivalent to the NI-SUPP modifier and the option.
to suppress the output of the legend message for list and sort
operations. This is equivalent to the LEG-SUPP modifier.
to output the data as text across the page. This is equivalent to the
FILL modifier.
The options may appear in any order, with or without separating commas
and with or without the closing parenthesis.
1000 1111
DESK, GREEN-BLUE, ASH STOOL, GREEN, PINE
56.00 20.00
1234 1500
CHAIR, RED, OAK CHAIR, ORANGE, PINE
10.00 25.00
2200 2222
SETTEE, BROWN, OAK DESK, BLUE, OAK
10.00 56.00
might be used to produce output like that in Figure 12.25, each item
producing a label, and the datanames in the output list -
item-id,
DESCRIPTION, and PRICE each producing a line on the label. The
-
0 e
a
t-}
?
The values are entered at one time and are separated by commas:
2310 260
If a mistake is made or the parameters are inconsistent with the page
width/depth as specified by the terminal characteristics, the processor will
abort with a message such as:
Because it's easy to get the parameters wrong, the label processor is
frequently invoked by a macro, a Proc or a Basic program in which the
parameters have been specified correctly. This is particularly important
where the facility is to be made available to end-users.
If you specify the fourth parameter (d) to indicate that you wish to indent
the labels, for example:
23110 260
then you will be asked to enter (again with just sequence of ? prompts)
a
4100190
or we could write this as the macro or the Proc shown in Figure 12.27.
Note that have used the ONLY keyword to suppress any macro or
|
N
SORT-LABEL ONLY STOCK]4 100 19 0
PQ
HSORT-LABEL ONLY STOCK
STON
H410019 0
P
The REFORMAT and SREFORMAT verbs will take the data from one file,
reorganise it, and then useitto create items on another file. For example,
the sentence:
REFORMAT STOCK DESCRIPTION IDATE PRICE QTY
would read the data from the items the STOCK file, rearrange the data
into the order indicated by the datanames in the output list:
DESCRIPTION
IDATE
PRICE
QTY
and use it to create new items on a file specified by the user. The new
items will have the same item-ids as the original items (R83 Pick users
take note). if we had used a sentence such as:
REFORMAT STOCK DESCRIPTION IDATE PRICE QTY ID-SUPP
then the new items would have the DESCRIPTION (the first attribute in
the output list) as their item-id. Care must be taken since any output
conversions and correlatives in the attribute definitions will be applied to
the new data, so a date would appear as 01 Jan 1999 instead of the
internal form 11324. For this reason, it might be better to use the
temporary attribute names:
REFORMAT STOCK Al A7 AS A2
produces the report shown in Figure 12.28 (b). When we issue the
sentence:
REFORMAT STOCK DESCRIPTION IDATE PRICE QTY
the processor will ask us for the name of the output file:
File name?
and, if we reply with the name NEW.STOCK, the new items will be
established on the NEW.STOCK file, as shown in Figure 12.28 (c).
This example illustrates some important points:
o Any data on the source items not included in the REFORMAT
sentence will be ignored when the new items are created.
© Multivalues are transferred intact, value-marks and all.
Any output conversion and/or correlatives are applied to the data as
it is used to build the output file.
REFORMAT and SREFORMAT are the only Access verbs which can
actually change the data on a file. All other Access verbs perform
look-only actions.
To these, we might add some further important points:
© already exists on the output file, then the new data is added
If anitem
as multivalues; R83 Pick users should note this point.
© If you give a null response to the FILE NAME prompt, then the input.
file will be assumed. Care should be taken when reformatting a file
back on to itself in this manner.
Access: the enquiry language 12-45
© Ifyou specify TAPE as the output file, then the records will be written
to backing storage.
© R83 Pick users should note the way in which the new item-ids are
created. On R83 Pick, the first output value was used as the new
item-id.
12.21 Summary
Access is the database enquiry language available on the R83 Pick and
the Advanced Pick operating system.
Each file has a data dictionary which holds a number of attribute definition
for datanames, such as DESCRIPTION, PRICE, LOCATION, QUANTITY,
which identify the attributes of the data items, or datanames such as
VALUE, TYPE which are based upon the data held in the items. These
datanames can be used in sentences, to display and print reports based
upon the contents of the database.
The Access language allows you to control the content, format and
appearance of the reports.
Access & attribute definitions 13-1
13
are constructed.
00 item-id
01 dictionary-code
02 attribute-count
03 substitute-header
04 structure
05 <== not used
06 <== not used
07 output-conversion
08 correlative
09 attribute-type
10 column-width
definition.
The remaining fields are concerned with the Update Processor and are
not used by the Access processor.
and connectives which are used in Access sentences (so you should
-
13.1.2 Dictionary-code
13.1.3 Attribute-count
9998 will output an fem sequence number: 1 for the first item on a report,
2 for the second, and so on. Do you recall the A9998 and A9999
temporary attribute items?
9999 will output the number of bytes in the item, that is, the item length.
13.1.4 Substitute-header
The heading may contain any characters, including spaces, and it does
not matter if this conflicts with the standard keywords (such as TOTAL),
indeed, this is one useful application of the heading field.
then there will be no text heading, just a line of dots. If you want no
heading (that is, blank heading), you should create a substitute-header
a
MINIMUM
OF
PRODUCT
© The column-width.
of the column heading text is less than the column width, the
If the width
heading will be padded to the right with dots.
13.1.5 Structure
To illustrate this, let us imagine that the data items on our STAFF file hold
two attributes: one (let's say this is attribute 28), holds the DIAL.CODE,
such as:
0171
886 9999
they would be shown with the controlling attribute first, as if you had typed:
LIST STAFF NAME DIAL.CODE PHONE.NUMBER
(a)
13-6 This is Advanced Pick
(b)
and so on.
Note that there is no code for outputting data in the centre of the column.
However, the XC processing code:
XC{n}
can be used to centre the output within a field n characters in width.
13.1.9 Column-width
13-8 This is Advanced Pick
(the correlative) and convert it to the required format for output (the
conversion code).
1) The Access processor first picks out from the data item the attribute
which is specified in field 2 of the attribute definition for that dataname.
specifying the name of the file and a list of datanames which are to be
created / changed. For example:
will invoke the Update Processor and display the fields shown in Figure
10.2, allowing you to enter the information which you need. The definition
is maintained by means of the regular Update Processor <Ctrl> keys.
Access uses only the dictionary-code field (attribute 1), attribute-count
(2), substitute-header (3), structure (4), output-conversion (7),
correlative (8), attribute-type (9), and column-width (10) of the
attribute definitions, the others are used by the Update Processor and
may be left blank if the definition is used only in Access sentences.
13-10 This is Advanced Pick
13.4 Examples
In this section, we shall look at some data items and some attribute
definitions, and illustrate the results when these are used in Access
sentences. have only shown that part of each output report which
|
displays the data for items 2000 and 9000; the raw data of these items is
shown in Figure 13.4 (a). The " character is the attribute-mark which
separates the individual attributes of the data items.
2000°SETTEE, YELLOW, OAK*18°DN/1/69*10000*30°1111°9581
9000°SIDEBOARD, YELLOW, ASH°99°DN/14/70*13000°15*2222°9539
DESCR 1 DESCRIPTION
01 A A
02 1 1 1
03 Description Product ] Name
04
0s
06
07
08
09 T
10 25 15 15
(d) Output
In Figure 13.4 (c), you see three attribute definitions all referring to
attribute 1 of the data items. They differ in the substitute-header, the
attribute-type and the column-width. Note how attribute-type T breaks the
text at a space, whereas attribute-type L breaks it at the 15th character
when the data is too wide for the column. These examples also remind
Access & attribute definitions 13-11
us that there may be several datanames for any particular data attribute.
Qty |
woven |
PRICE |
VALUE |
NAME
01 A A A A A
02 2 7 4 0 6
03 Price Supplier}name
04
05
06
07 D2 MD2 MD2
08 A2*4 TSUPPLIER;C
09 R R
10 3 9 6 i5
(b) Output
items, then ignores this and uses the correlative to derive a value
(multiplying attribute 2 by attribute 4). This result is then passed on
the output conversion code MD2 which inserts a decimal point, and
then outputs this right-justified in a column 8 characters wide. Since
there is no substitute-header, the dataname (VALUE) is used as the
13-12 This is Advanced Pick
column heading. Note that, since line 002 contains 0, the dataname
would have output the item-id if this has not been overridden by the
correlative.
© NAME takes the contents of attribute 6 of the data items, and then
processes the correlative and uses the data as the key to an item on
the SUPPLIER file, fetching attribute 1 (the supplier name) from that
file, and outputs this as text in a column 21 characters wide. The
substitute-header is used as the column heading, and the value-mark
-
shown ass] in diagram (a) produces a multiline heading.
-
14
Aexpression
in the calculation.
Here are some examples of the A code. The table in Figure 14.1 shows
the results of these codes when applied to an item with the item-id XYZ
which consists of the nine attributes:
11°22°33*44°55*66°77°88°1]213]4]5
and the current date is 9157, that is the 25th January 1993.
Av11"/"2"
will return the value 5, and the remainder 1 (or the fractional part 0.5)
will be lost.
A(2+5)#"100"/"2"
will perform the same calculation as the earlier example, but
multiplying by 100 first will retain some of the decimal places. A
subsequent MD2 conversion code might be used to display the
number with two decimal places.
ap-Mill find today's date (as a number of days in the internal Pick form)
and subtract from this the contents of attribute 7 of the data item. This
Access processing codes 14-3
might be used to find the number of days since an order was placed
(if the order date is held in attribute 7). Later, we'll say more about the
way in which dates are held on data files.
AR(8,3)
will divide the contents of attribute 8 by the contents of attribute 3 and
return the remainder.
A6["1","3"]
will return the first three characters of the contents of attribute 6.
as(9) Will add together all the multivalues of attribute 9 and return the
result.
AS(9)*7
will add together all the multivalues of attribute 9 and multiply the
result by the contents of attribute 7.
A(N(FLD1)+(N(FLD2) )*N(PRICE)+5
will evaluate the datanames for FLD1, FLD2, and PRICE and perform
the calculation shown, and then add the contents of attribute 5.
Ag*4
AO*4R
A6(MD2)
will apply the processing code MD2 to the contents of attribute 6.
A(2*6) (MD2)
will multiply attributes 2 and 6 together and then apply the processing
code MD2 to the result.
A'Y': ((2%6)(MD2))
will apply the MD2 processing to the product of attributes 2 and 6, and
then prefix a Y to the result.
Figure 14.1 shows the results using the same data item as before.
14.1.3 A operands
14.1.4 A operators
+ addition.
subtraction.
multiplication.
division, returning the quotient.
concatenation.
(c) apply processing code c.
The effects of many of the other processing codes described below can
be achieved by means of the A code. This is largely for historical reasons
as the older forms were superseded by the more recent A code.
BCLIENT; 1:3
operate in both directions, from the ORDER file to the CLIENT and from
the CLIENT file to the ORDER. Whenever an item is added to or deleted
from the ORDER file, attribute 3 of the CLIENT file is changed
accordingly. In this situation, the Update Processor will not allow the
order-numbers on the CLIENT file to be deleted until the corresponding
order on the ORDER file has been deleted.
Bfilename:a;b{:c}
where filename indicates the file (the CLIENT file in our example) to which
the items on this file (the ORDER file) are associated (bridged); a is the
attribute in the ORDER file which holds the item-ids of the CLIENT items;
b is the attribute in the CLIENT file which forms the other end of the
bridge. The parameter c suppresses the bridge back to this (the ORDER)
file implied by the parameter b, and has one of the forms:
n:+ means add the value of attribute n of the current ORDER item
CLIENT item,
to attribute b in the
14.3 C: Concatenation
The C code is used to concatenate join together data attributes
- -
and/or literals to produce a single output result. It has the general form:
Cx{:x}
Access processing codes 14-7
To illustrate this, let us imagine that one of our data items looks like this:
111°222°33)44]55°333°444°555°666
in which attribute1 contains the value 111, attribute 2 contains 222, and
attribute 3 contains the multivalues 33, 44 and 55, and so on. The
following examples show the effects of some of these codes:
C1;"/"32
will output 111/222 (and is identical to results produced by the a1:°/":2
code).
Cc"The answer is ": 1;" units"
will output The answer is 111 units
c"£";6:".00"
will output £666.00
C"AA";3:"BB"
will output AA33 44 55BB and any value-marks will be replaced by
spaces.
evi"
will output the number 1 and is useful for counting items, as we see
with dataname *ONE in Figure 12.6.
C'YES'
will output YES
will output null and is useful if you want to leave a wider gap between
the columns of a report, as we see with dataname *GAP in Figure
126..
14-8 This is Advanced Pick
CALL ACCSUM
will call a Basic subroutine which has been catalogued with the name
ACCSUM and which starts with a statement like:
SUBROUTINE ACCSUM(INVALUE)
The CALL code can be used in attribute definitions used in Access reports
or as an input-conversion in definitions used by the Update Processor,
and opens up the way to powerful data validation and transformation. It
is also used in hotkey specifications, as we see in Chapter 10.
Within the called subroutine, details of the file and the current item can be
obtained by means of the ACCESS function. This function is used in
contexts such as:
5 returns the current attribute counter, that is, the number of the attribute
which is being processed by the attribute definition.
10 returns the current item-id. In certain contexts, new value may be
a
maintained via the Update Processor, the familiar <Ctrl> keys can be
used to move through the field and to edit the data field. For example, a
description such as:
without having to retype CHAIR and OAK. However, if the data field is
defined with an input-conversion, such as D or MT, then the entire
contents of the field will be erased when the user begins to type any new
data into the field. So, let us imagine that the user wishes to change an
existing date:
14-10 This is Advanced Pick
29 Jul 1990
to:
29 Jul 1995
How can we allow the user to change just the 0 without retyping the rest
of the date? The answer lies in the CU character update conversion
- -
cu
and will allow the <Ctrl> keys to be used to move through and edit the
existing date field.
The programs which add data to the files will use the D code to convert
the dates entered by the user in forms such as 31 December 1999 or
-
9876
that is, Saturday the 14th January, 1995, then the conversion codes will
return the following:
Access processing codes 14-11
D 14 Jan 1995
p2 14 Jan 95
D2/ 14/01/95 (or 01/14/95 if the date is set to the standard US format).
py 14 (the Julian date, the number of days since the beginning of the
year).
pw 1 (the month of the year as a number in the range 1 to 12).
pwa Saturday
py 1995
The TCL DATE command is useful when you are working with dates, as
the following examples illustrate:
DATE
display today's date in the form:
DATE 31/12/93
display details of a specific external date:
DATE 9876
display details of a specific internal date:
DATE 321 (J
display details of a specific Julian date of the current year:
14-12 This is Advanced Pick
DATE (C
display the calendar for the current month.
F;2:5;+
A2+5
will add together the contents of attributes 2 and 5 of the data item.
A7-6
will subtract the contents of attribute 6 from the contents of attribute
7 of the data item.
F;11;23;*
A11*23
will multiply the contents of attribute 11 by the contents of attribute 23
of the data item.
F:9:11;/
A9/11
will divide the contents of attribute 9 from the contents of attribute 11
Access processing codes 14-13
F32+6*
A(3+2)*6
will add together the contents of attributes 3 and 2 and multiply the
result by the contents of attribute 6.
F25 + c2 /
A(2+5)/'2'
will add together the contents of attributes 2 and 5 of the data item
and divide the result by the number 2. Note the first form in which the
constant 2 is preceded by the letter C. All arithmetic is carried out in
integers and any remainder from division will be ignored.
F;D;7;-
AD-7
(as a number of days) and subtract from this the
will find today's date
contents of attribute 7 of the data item.
F:8:3:R
AR(8,3)
will divide the contents of attribute 8 by the contents of attribute 3 and
return the remainder.
F:6:01;C3:[]
a6('1', 3
will return the first three characters of the contents of attribute 6.
F:1:73:
Al:7
c1:7
will concatenate the contents of attributes 1 and 7.
F:9;8
aS(9)
will add together all the multivalues of attribute 9.
F;9:8;7;*
AS(9)*7
will add together all the multivalues of attribute 9 and multiply the
result by the contents of attribute 7.
EPick described the other operands and operators which are available.
AB/CD123/EFO0/GH
then skip 2 such groups (AB and CD123) and return the next 1 group
(EF00). The result would be: EFOO
ci/2 Will return CD123/EF00. Note that the delimiter(s) are included if
more than one group is returned.
1/999 will return CD123/EF000/GH, that is, everything (or the next 999
groups) after the first group.
The I code is primarily concerned with files and their indexes, and is found
in several forms:
I
lacode
Ifile; acode
and we saw examples of some of these in Chapter 10 when we discussed
cruising, Zooming and double clutching.
The second form is held in the data-level identifier and is set when you
issue rsa CREATE-INDEX command such as:
CREATE-INDEX STAFF A2(GO 1)
Alternatively, you may apply the code explicitly by setting attribute 8 of the
data-level identifier to:
IA2(GO 1)
indicating that index entries are to be maintained (in this case) for the
second word of attribute 2. When a CREATE-INDEX command is next
issued for this file, then the index will be established and this code will be
|
198765A2(GO 1)
storing the FID (98765 in this instance) of the root node of the appropriate
index. Once the FID of the root node has been set by the
CREATE-INDEX command, it must not be changed. Whenever an item
is added, changed or deleted from this file, the index will be updated.
Look at references (1) and (5) in Figure 10.10.
ISUPPLIER;A1
indicating that the contents of this attribute are based upon the data which
is indexed as attribute 1 of the SUPPLIER file. Look at references (3) and
(12) in Figure 10.10; as reference (11) there shows, you should also have
a Tfile processing code in the attribute definition for the supplier-number
field of the PURCHASE.ORDER file to permit you to cruise through the
SUPPLIER file. When you are required to enter a supplier-number, you
can use the Advanced Pick <Ctrl> keys to pass to the index for the
SUPPLIER file and browse there until the required SUPPLIER is found.
such as:
UPDATE STOCK
UPDATE STOCK DESCRIPTION PRICE
UPDATE STOCK DATA-ENTRY
UPDATE STOCK DESCRIPTION QUANTITY DATA-ENTRY
14-16 This is Advanced Pick
in which the item-id is omitted, then a new item will be created and when
this is filed, a unique item-id will be created based upon the current
internal date and a system-wide sequence number. If you wish to
control the format of the new item-ids, you may use the ID code as a
correlative in the data-level identifier. There are several forms of the
code:
IDT
IDAexpression
IDn
for example:
IDA(D: '/'.T.1[ 1, 1 ])
will use the A processing code to derive the item-id from other data in the
item; in this instance, building the item-id from the current date and time
followed by the first letter of attribute 1 of the item. The expression can,
of course, use the CALL code to invoke a Basic subroutine, thereby
allowing virtually any item-id to be generated.
The third form:
TDn
will create unique numeric item-ids starting at n. As new items are added
to the file, the system will update the value of n in this code to reflect the
next number to be used. We used this at reference (6) in Figure 10.10.
When new item-ids are generated under the control of this code and itis
found that an item already exists with the generated item-id, then the
Update Processor will increment the generated item-id until a unique
item-id is obtained.
and the default item-id (today's date plus a unique identifier) will be used
instead.
test the contents of attribute 2 of the data item: if the value is zero or
null, then the sum of attributes 5 and 7 will be output, otherwise the
contents of attribute 2 will be output.
in which the ELSE pairs with the first IF and the first THEN, not with the
6
ac
14.12 L: Length
The L code is used to test the length of the data field and take
appropriate action. There are three forms:
Lo will output the /engthof the data value. For example, a data value of
SAND would output 4, and a data value of CEMENT would output 6.
L4 Will output the data only if the value is 4 characters in length, longer or
shorter strings will output null. For example, a data value of SAND
would output SAND, and a data value of CEMENT would output null.
Thecardmeasuresby
MCAN
MCNA either of these will return only alphabetic and numeric
characters:
Access processing codes 14-19
Thecardmeasures45by625
MC/AN
MC/NA either of these will remove alphabetic and numeric characters:
tt
MCDX
MCXD will convert decimal values to hexadecimal, and hexadecimal
values to decimal.
45625
MCS will capitalise the first word of each sentence in the data, leaving all
other characters unchanged:
These codes are particularly useful for transforming string and character
data which is being processed by a Basic program.
The MD mask decimal code, and the associated MR and ML forms, are
used for formatting and presenting numeric data such as numbers, prices
14-20 This is Advanced Pick
fight-justified,
L left-justified,
R fight-justified.
This justification is only of significance when the xi element is also
used.
is anumeric digit specifying the number of decimal places which are
to be printed.
As Figure 14.3 shows, if the ML code is used, the field will be filled to
the right, otherwise the field will be filled to the Jeff.
is a code specifying the way in which negative values are to be
presented, and will be one of the following:
c negative values are to be followed by CR.
D positive values are to be followed by DB and the minus sign is
to be dropped from negative values.
Applications which need to record clock times usually hold these in the
Advanced Pick internal format and represent the number of seconds
since midnight, as illustrated in Figure 14.4.
The MT code is used to convert such times between the internal form and
any one of the following external formats:
ut will convert the internal time to a form such as 00:20 or 17:30 showing
just the hours and the minutes.
mts convert the internal time to a form such as 00:20:34 or
-Will
17:30:59 showing the hours, minutes and seconds.
muta convert the internal time to a form such as 12:20AM or
Will:
05:30PM using the suffix AM or PM.
14-22 This is Advanced Pick
The P code is used to indicate that data values are only to be output if
they match one (or more) of a specific set of patterns. The general form
of the code is:
P(pattern)
or:
P(pattern) (; (pattern) }
of the P code:
P(3N) Will output the data field if it consists of three digits. Values such as
000 or 111 or 987 will match; values such as 12 or 1234 or 1.1 or
111.1 or 1.111 or ABC will not match this pattern and will output a null
value.
P(oa) Will output the data field if it is null or consists only letters.
P(1NON) Will output the data field if it consists of at least one digit and only
numeric digits. Values such as 1 or 1029384756 will match; values
such as 1A or 1AB will not match.
p(2a4N) Will output the data field if it consists of two letters followed by four
digits. Values such as AA1111 or ab1029 will match.
P(2A'/'2N)
P(2A/2N)
Access processing codes 14-23
These two are equivalent and will output the data field if it consists of
two letters followed by a / and two digits. Values such as AA/99 or
XZ/00 will match.
P(3N);(3A'-'4N)
will output the data field if it consists of either three digits (3N) or three
letters followed by a hyphen and four digits. Values such as 333 or
AAA-9999 or ABC-1029 will match.
If the data matches any of the specified patterns, then the data will be
output, otherwise a nuff will be output.
S; 'NOT ZERO';°ZERO'
will test the current data and output NOT ZERO if the value is non-
zero and non-null, otherwise it will output ZERO.
s:7: 3Will test the current data and output attribute 7 if the value is non-
zero and non-null, otherwise it will output attribute 3.
8: 7; °VALID'
will test the current data and output attribute 7 if the value is non-zero
and non-null, otherwise it will output VALID.
S;*;' ZERO'
will test the current data and output the value if it is non-zero and non-
null, otherwise it will output ZERO.
14-24 This is Advanced Pick
73,5 Will return the 5 characters starting at the 3rd character of the data:
OOR D
T,5
71,5 are equivalent and will return the first 5 characters of the data: FLOOR
The Tfile -
translate file processing code uses the current data value
-
(let's call this the source value) as the key to another file and then reads
(or translates) a specific attribute from that item on that file.
We can illustrate this by looking at items on the STOCK file which hold a
supplier code (in attribute 6) and use this (the source value) to pick up
data from the corresponding items on the SUPPLIER file. Two STOCK
items are shown in Figure 14.5 (a), and these hold the supplier codes
2000 and 1000, respectively. In (b) we see the two items 1000 and 2000
on the SUPPLIER file. The definitions in (c) can then be used to output
the original source value and the data translated from the SUPPLIER file,
to produce the report shown in (d). The Tfile code:
TSUPPLIER;C; ;1
1000 |
ROGER PETERSEN PLC"081-999 4767
2000 |
A.B.ATKINS AND CO*061-999 2375
001 A
002 6 6
003
004
005
006
007 TSUPPLIER;C;;1
008
009 T T
010 8 20
TSUPPLIER;C; 2
will use the source value as the key to an item on the SUPPLIER file
and then return attribute 2 of that item; using the data structure shown
in Figure 14.5, this would be the telephone number. If there is no
such item on the SUPPLIER file, or the item exists but attribute 1 is
null, then the source value will be returned.
TDICT PARMS;C;;7
will use the source value as the key to an item on the DICT section of
the PARMS file and then return attribute 7 of that item. If there is no
such item on the DICT section of the PARMS file, or the item exists but
attribute 7 is null, then the source value will be returned.
TSTOCK;X;:9
14-26 This is Advanced Pick
will use the source value as the key to an item on the STOCK file and
then return attribute 9 of that item. If there is no such item on the
STOCK file, then a null value will be returned.
TSTOCK; X2; 1
will use the source value as the key to an item on the STOCK file and
then return the second multivalue of attribute 1 of that item. If there
is no such item on the STOCK file, then a null value will be returned.
TCLIENTV;;33
will use the source value as the key to an item on the CLIENT file and
then return attribute 3 of that item. If there is no such item on the
CLIENT file or attribute 3 is null, then the original item will be omitted
from the output.
T(DICT
where filename identifies the file from which the data is to be read,
subcode is one of the letters C or X or V, indicating the action to be taken
if the required data cannot be found on the file; x is the number of the
*
specific multivalue which is to be returned or if the multivalue in the
same position as the source multivalue is to be returned; if x is omitted,
then the entire data attribute will be returned (and any value-marks
replaced by spaces); a is the number of the attribute which is to be read
from the file. The full range of subcodes is:
c totranslate and return the required attribute. If the item does not exist
in the translate file, or the item exists but the specified attribute is null,
then the original value is returned.
x totranslate and return the required attribute, or to return a null value.
to translate and return the required attribute, or to omit this item
entirely from the report.
The full form of this most useful code is described in EPick and the
reference literature.
XAn
xanv of the user performing the update in attribute
Will store the user-id
n of the updated item.
Access processing codes 14-27
XDn
xonv Will store the current date in attribute n.
XSn
xsnv Will accumulate the number of seconds for which the item was
handled by the Update Processor and store this in attribute n.
XTn
xtnv Will store the current time in attribute n.
15
File indexing
In order to read an item from an Advanced Pick file, you must know the
name of the file and the item-id of the specific item that you want. For
example, the items on the STAFF file will be uniquely identified by the
item-id, the employee number, those on the STOCK file might be
identified by the part-number, and so on. To process a particular item on
the STAFF file by means of the Update Processor, you might use a
command such as:
and to read the same item within a Basic program, you will use a
statement of the form:
but this will have to read through every item on the file looking for the
SMITHs; this would take a considerable time for a large file, and for a
Basic program, the same requirement would be a long and complicated
process. Advanced Pick allows you to create an index of secondary
keys. This index is held in alphabetical order and your Basic programs
can scan through the index, looking for a particular secondary key -
SMITH and then find the item-id or item-ids of the item(s) with that
- - -
secondary key; having found the item-ids of all the SMITHs you can read
these items to find the one you want. A further application is within the
Update Processor where we can cruise through the index, looking at the
items on the file using the specified field as a key into the index. We
looked at this in Chapter 10.
Pick. A file may have any number of indexes, one for the surname, one
for the surname and first name combined, one for the department, one
for the post code, one for the telephone number, and so on. In fact, an
index may be based upon any information derived from the item. Some
analysts use the term B-tree for such an index.
In Figure 15.1 (a), we see a simple Access listing of the file; in (b), we
create the index and then display the D-pointer to see the index details
which have been added to attribute 8. In (d), we dump the frame
occupied by the index to look at the physical form and see that the index
contains the secondary key (the surname) and the relevant item-id(s),
and the entries in the index are sorted into alphabetical order.
The instructions for deriving the index-key from the data in the item are
specified as an A processing code in the CREATE-INDEX command:
CREATE.INDEX STAFF Al
and Advanced Pick stores these instructions together with the FID of the
root of the index in attribute 8 the D-pointer for the data section of the file.
In our example, these are:
I7870A1
showing that the root FID of the index which is based on the A processing
code:
Al
starts at frame 7870. The index is held in frames of virtual memory, not
on a Pick file.
where file.name is the name of the file for which the index is to be created,
and Acode is the A processing code which is to be used. Here are some
further examples:
:CREATE-INDEX STAFF Al
000011 <= 11 items were added to the index
:LIST-ITEM DICT STAFF STAFF
STAFF
001 D
002 7861
003 7
004
005
006
007
008 17870A1 <== Set up by the CREATE-INDEX process
009 L
010 10
As Figure 15.1 illustrates, the entries in the SURNAME index are held in
sorted sequence. If you issue SORT or an SSELECT sentence and
a
there is an index for the sort field which is used there, then the index will
be used to speed up the action of the sort. Thus, if we issue an Access
sentence such as:
SORT STAFF BY SURNAME
and the processing code in the attribute definition for the dataname
SURNAME matches the A processing code(s) for the index(es) for the
STAFF file, then this index will be used to retrieve the sorted data. There
are other verbs which can exploit indexes: WLIST, WSORT, WSELECT
and WSSELECT.
to list only those items which have duplicate index keys for the SURNAME
field, that is, where two or more employees have the same SURNAME.
The syntax of the Basic READ statement still requires a specific item-id:
READ RECORD FROM FILE, item.id ...
MATREAD ARRAY FROM FILE, item.id ...
READV VARIABLE FROM FILE, item.id .
but the ROOT and KEY statements can be used to find an item-id for a
given secondary (index) key and this item-id can then be used in cla READ
statement to get the item for processing. The sequence of events in
using these statements is:
2) KEY to find the item-id (or nearest match) for a given secondary key.
specifying the name of the file for which the index is to be used, and the
A processing code on which the index is based. The variable
--ROOT.V
example is the index-variable which is used to store the details
in this -
of the root for use in subsequent KEY statements which will retrieve
item-ids from the index.
The Basic KEY statement allows the program to access items by means
of the index, by returning an item-id which matches the secondary key
provided by the program. The form of the statement is:
The use of these statements is illustrated by the Basic program and the
output shown in Figure 15.2.
the index will be constructed. If we inspect the data-level identifier for the
file, we find that this looks like Figure 15.3 (a), indicating that the root of
the index is at frame 24190. This root is essentially an index to the index.
Dumping the root frame, we produce the display shown in Figure 15.3 (b).
Surname: EDWARDS
006
*
EDWARDS JOHN
Surname: EDWARDS
016
*
EDWARDS PETER
Surname: J
014
JENKINS * DENNIS
NAMES
01 D
02 26354
03 17
04
os
06
07
08 I24190A1 <=== Root FID: 24190
09L
10 10
(a)
(b)
Figure 15.4.
Data-level
identifier, |
24190
Root
of
index
5E85 - SES6
<F >= NEVILLE >= SAYER N
and and
< NEVILLE L SAYER
<
N,
(a) (b) (c) (d)
root frame from which are suspended one or more leaves or leaf
frames. The routines which maintain the index attempt to distribute the
names through the leaf frames in a balanced manner, with each
individual leaf occupying no more than one frame.
the frame is filled it will be split into two. The other leaves are unchanged.
The root frame now looks like that in Figure 15.6, giving us a diagram like
that in Figure 15.7.
Root
of
index
There are several noteworthy points, some of which are verified by the
above illustrations:
© The entries in the index comprise the index key (as specified by the A
code when the index is created) followed by an attribute-mark
followed by the item-id (or item-ids) of the item(s) for which that it the
index key.
© Acontrol field showing the length of the index entry precedes each
index entry.
© Each entry is followed by one or two segment marks, so that the entry
is an even number of bytes in length.
Any file may have one or more B-tree indexes to facilitate the retrieval of
items by way of secondary keys. A number of TCL facilities and Basic
statements are provided to use such indexes. Once they have been
created, indexes are automatically maintained whenever items are added
to, changed, or deleted from the file.
The Basic language 16-1
16
01 *
Program to construct simple Access sentences
02
os PROMPT
06
07 EQUATE DN TO CHAR(10)
11 COUNT = 1
13
15
16 LOOP
19 GOSUB Vet.dataname
20 REPEAT
21 GOSUB Execute.sentence
22 STOP
23
24 *
Subroutines eeeiedteeter eee eee titete+ thee kkikk
25
26 Get.dataname:
27
29 INPUT DATANAME
30 DATANAME = TRIM(DATANAME)
31 RETURN
32
33 Vet.dataname:
34
37 Add.dataname:
39 COUNT = COUNT + 1
40 RETURN
41 MISSING:
43 CRT MSG3
16-4 This is Advanced Pick
44 RETURN
4s
46 Execute, sentence:
47
CRT '
48 DN : 'Executing : SENTENCE
50 INPUT RESP,1
52 RETURN
that it has a DICT section and a data section and it is the usual practice
-
to keep all the programs for a particular application together on one file.
Let's imagine that I've created the program shown in Figure 16.1 as an
MBPROGS and saved it with the item-id SENTENCE01.
item on the file
The program would be created and changed by means of either the
Update Processor or the Pick Editor:
UPDATE MBPROGS SENTENCEOL
or:
EDIT MBPROGS SENTENCE01
and so on, then must use the COMPILE verb, which will accept the
|
Enter dataname #4
Even if you haven't done any programming before, you can probably
understand some of the Basic program, and with the help of Figure 16.2
you may be able to figure out what the program is doing. For those new
to Basic and programming, let us look at some of the statements which
| have used in this program, noting any interesting points:
© The numbers to the left of the program statements in Figure 16.1 (01
to 52) are the line-numbers of the individual statement lines in the
program; these are the 52 attributes of the program item. The line-
numbers only appear when we display the source program and are
not a part of the text of the program itself. This is where Pick/Basic is
quite different from those dialects of Basic which need line-numbers
to organise the statements into the correct order.
© The lines which begin with an asterisk are comments and include
these to explain what the program is doing. The computer ignores
16-6 This is Advanced Pick
with GOSUB, GOTO and other statements. You can have numeric
statement labels, or alphanumeric label, as here. Alphanumeric
labels must be followed by a colon.
o The CRT statement displays information on the screen. could have
|
waits for the user to type in some information, and when the user hits
the <Return> key, that information will be placed in a variable
identified by the name DATANAME.
The statement:
INPUT RESP,1
waits for the user to type in one character of information, and places
this in a variable called RESP.
The Basic language 16-7
© The statement:
IF RESP='Y' THEN EXECUTE SENTENCE
tests whether the contents of the variable RESP (which has just been
typed in by the user) is the letter Y, and, if so, the sentence which has
been built up in the variable SENTENCE will be executed. The
program has constructed an Access sentence in the variable
SENTENCE, adding each dataname required by the user to the end
of the sentence. If RESP does not hold the letter Y, then the
processing will pass on to the statement on the following line, line 52.
Other interesting statements and structures are:
stor terminate the execution of the program and, in this case, prevent the
processing crashing into the subroutines at the end of the program.
DATANAME TRIM(DATANAME)
take the dataname typed in by the user and remove any superfluous
spaces.
READ DEFN FROM STOCK.DICT,DATANAME ELSE GO MISSING
use the contents of DATANAME as an item-id to read an item from
the file which has been opened as STOCK.DICT. If there is no such
item, then the processing jumps to the statement label MISSING; if
there is an item, then the contents of that item are placed in the
variable DEFN.
IF DEFN<1> NE 'A' AND DEFN<1> NE 'S' THEN GO MISSING
check attribute of the data which has been read into DEFN to see
1
whether this is an A or an S: if not, then the processing jumps to the
label MISSING; if the first attribute of DEFN fs A or S, then the
processing continues to the next statement.
SENTENCE SENTENCE : : DATANAME
append a space and the new dataname to the end of the sentence
which is being built up in SENTENCE.
COUNT = COUNT + 1
add 1 to the contents of variable COUNT, keeping a count of how
many datanames the user has typed in.
Some points which might interest experienced programmers are:
© The indentation of the program statements is entirely optional. have |
for a response of Y and this will handle the case where the user has
entered y.
© Pick/Basic does not demand an END statement at the physical end of
the program. Indeed, it is wise nof to include a final END statement
as this may hide missing END statements within the program.
Now let us look more closely at some of the features of the Basic
language and Basic programming on Advanced Pick.
16.2 Variables, literals, numbers and strings
Two types of data are handled by Basic programs: numbers and strings.
We can see these in action in this sequence:
PRODUCT = ''CHAIR'
DISCOUNT 25.0
INPUT PRICE
COST PRICE * (100-DISCOUNT) / 100
PRINT PRODUCT, COST
COUNT COUNT + 1
program:
"CHAIR'
25.0
100
by a calculation:
COUNT = COUNT +1
COST (PRICE * QUANTITY) * (100 + VAT.RATE) / 100
INPUT PRICE
As a new value is assigned to a variable, any value already held there will
be lost. Any variable may hold just one value and this may be a number
or a string.
invalid literals are shown in Figure 16.3 (a). We discuss the available
range of numbers later.
A string is a sequence of alphanumeric characters,
"
and when used in a
Basic statement, a string will be enclosed in or or \ \characters. Some
literals are shown in Figure 16.3 (a). Astring may be any length from 0
(for a null string) up to 2 gigabytes, that is, 2,147,483,648 characters in
length.
The first uses a numeric literal 100 and the second uses string literala
"100", but both are acceptable and both will give the same result. The
Basic run-time processor recognises that we are doing arithmetic
*
(because we use the arithmetic signs for multiplication, for subtraction
-
and / for division), and will convert all the data to numbers. Because of
16-10 This is Advanced Pick
the need to convert the data, the second statement would be the slower.
Obviously, it would be an error if we had written:
COST PRICE * ("YES"-DISCOUNT) / "100"
but this non-fatal error would only be detected when the statement was
executed and the run-time processor attempted to convert "YES" to a
number, and it would, in fact, then use a value of 0. Similarly, if we were
to use numeric literals in a string handling operation such as:
16.2.1 Variables
Your program may use up to 214,748,362 variables at any one time (this
includes individual named variables and all elements of any dimensioned
arrays in the program), and each variable and array is uniquely identified
by name. The name may be up to 48 characters in length, and must start
with a letter followed by any combination of letters, digits, full stops, dollar
signs and (on later releases) the underscore character.
Some acceptable and some unacceptable variable names are shown in
Figure 16.4. The compiler will reject any attempts to use certain reserved
words, or the names of the intrinsic Basic functions (a list of these is
shown in the Appendix) for your arrays, or those keywords shown in
Figure 16.4 (c) for your variables.
Data.X NextR STORE.32.A TAX
DATAX Nextl Subroutine9 TOTAL.TO.DATE
Endl RECORD TABLE .B2 VALUES
Income. tax SIZE.SS Tax VALUE1
to test various pieces of data and store the result as true (a value of 1) or
false (a value of 0) in the variable OAP; we can subsequently use this
logical value in statements such as:
IF OAP THEN CRT 'This employee is a pensioner'
IF NOT(OAP) THEN CRT 'Not eligible for pension'
IF OAP THEN CALL PENSION.ROUTINE
16.2.2 Precision
A#3540705968149597751242378595390670323015412790761
B=3540705968148700000000000000000000000000000000000
C#4371241896208856100100048221092623586370756606568
81926429
D=0
16-12 This is Advanced Pick
PRINT 2/3
0.6666
variables, each of which is identified by the name of the array and its
position within the sequence. Basic will let you handle one-dimensional
arrays, like INCOME in Figure 16.6 (a), and two-dimensional arrays, like
SCORE in Figure 16.6 (b). Before you use such arrays, they must be
deciared explicitly in order to indicate how big they are and,
consequently, how much storage the compiler is to allow. For example,
a statement such as:
DIMENSION INCOME(12)
DIM INCOME(12)
would set aside 12 variables for an array called INCOME, and either of
the statements:
DIMENSION SCORE(4,5)
The Basic language 16-13
DIM SCORE(4,5)
INCOME(2) for the second element, which contains the string QQ,
and so on up to ...
33 QQ AA xx yy 22 19 51 66 69 45 31
1 2 3 4 5 6 7 8 9 10 11 12
1 77 A D
2 M N
3 A B
4 32 DR 55
1 2 3 4 5
SCORE
TT BI 32
1,1 1,2 1,3 1,4 1,5 2,1 2,2 3,5 4,1 4,2 4,3 4,4 4,5
INCOME(1) 0
INCOME(3) * INCOME(1) + INCOME(7)
INPUT INCOME(5)
PRINT INCOME(6)
INCOME(9) 2 * INCOME(9)
PRINT SCORE(1,1)
SCORE(2,3) = SCORE(4,5)
INCOME(1) SCORE(4,5) * 100
DIMENSION NUMBER(100)
IF NUMBER(X)='.' THEN
X=Xe1
EXIT
END
COUNT=COUNT+1
TOTAL=TOTAL+NUMBER (X)
NEXT X
MEAN=TOTAL/COUNT
DIFF=MEAN-NUMBER(C)
DIFF.SQ=DIFF*DIFF
SUM.SQ=SUM.SQ+DIFF.SQ
NEXT C
VARIANCE=SUM.SQ/COUNT
Enter value #3 20 2
Enter value #4 21 8
Enter value #5 21 8
Enter value #6 20 8
Enter value #9 20 2
Mean 20.890000
Variance 0.430900
Standard deviation: 0.656429
which would take the numeric value held in the variable X (let's imagine
this contains the number 3), and use this subscript to print the contents of
INCOME(3) the third element in the array. Figure 16.7 shows how we
might use an array to store a series of numbers and then manipulate the
16-16 This is Advanced Pick
array to calculate the mean of the values and the statistical standard
deviation. Some other examples of subscripts:
TOTAL INCOME(VALUE)
ANSWER SCORE(ROW, 3)
INCOME(VALUE/2) = NEW1
SCORE (ROW, COLUMN) INCOME (ROW*COL/2)
PRINT SCORE (INCOME(1) , INCOME(C) )
Array names conform to the same rules as Basic variable names, they
must be unique within the program, and they must not conflict with the
names of variables or any of the standard Basic functions. There may be
any number of DIMENSION statements in a program, and several arrays
may be declared on a single DIMENSION statement:
DIMENSION INCOME(12), SCORE(4,5), STOCK(10)
or:
DIM INCOME(12), SCORE(4,5), STOCK(10)
then the first element of the array is INCOME(1) and the final element is
INCOME(12); any subscripts outside this range, such as:
INCOME (0)
INCOME(100)
INCOME (-5)
are invalid and will cause a fatal compilation error (if a literal subscript is
used) or a fatal execution error (if the subscriptis calculated by the
program). Non-integer subscripts are truncated, so that a reference to
INCOME(1.5) would be interpreted as INCOME(1).
The MAT statement will allow you to assign values to all the elements of
an array. For example:
MAT INCOME=1
assign the value 1 to every element in the array INCOME.
there are no ways of handling the array as a whole and there are no
mathematical functions to allow you to perform matrix manipulation.
and will test all the elements of the array or all those in a specific row
-
or column -
and return a value of frue if any one (or more) of the
elements of the array satisfy the test. The same forms are available with
dynamic arrays, as we see later.
You may assign names to the individual elements of a dimensioned array:
and this is particularly useful when you are writing code to handle file data
which has been read in by the MATREAD statement.
attribute 5 REC<5>
attribute 4 REC<4>
attribute 3 REC<3>
attribute 2 REC<2>
attribute 1 REC<1>
© Insert new elements at the front of the array, at the end of the array,
or elsewhere within the array.
o Remove elements from the array.
Some examples of dynamic arrays can be seen in Figure 16.8. The
dynamic array in (a) consists of a sequence of attributes; that in (b)
shows how the values of the same dynamic array might look if some of
the attributes were multivalued; that in (c) shows the appearance if some
of the values had subvalues; subvalues are rarely encountered in
practice. The references to the right of each line show how that element
of the array would be identified in Basic assignment statements such as:
NAME REC<1>
TOTAL REC<2> * REC<3>
REC<5> 'NO'
REC<4> = NEW. VALUE
PRINT REC<2,1,1>
°'
REC<2,1,2>
The Basic language 16-19
Itis this notation and usage which earns them the name dynamic array.
The adjective dynamic arises from the fact that (unlike a dimensioned
array) a dynamic array is not fixed in size and elements may be inserted,
appended and deleted from the structure.
"
In Figure 16.8, have used the character to represent the attribute-
|
mark which separates the individual attributes of the array, the ] character
to represent the value-mark which separates the individual values, and
the \ character to represent the subvalue-mark which separates the
individual subvalues. Note that attribute 4 holds a null data value and is
represented by just the following attribute-mark. Any references to
REC<4> or to REC<6> onwards are acceptable and would refer to null
values.
For example, let us imagine that a variable called DYNARR holds the
following dynamic array:
AA*B)]BB]BBB*C]c\ce\ccc]CC*DD
PRINT DYNARR
would display the entire contents of the variable (including any
attribute-marks, value-marks and subvalue-marks):
AA*B)]BB)BBB*C]e\ce\ccc]Ccc*DD
PRINT DYNARR<1>
would display the contents of attribute 1 of the dynamic array held in
DYNARR (including any value-marks and subvalue-marks):
AA
PRINT DYNARR<3>
would display the contents of attribute 3 of the dynamic array held in
DYNARR (including any value-marks and subvalue-marks):
C)e\ce\cec]cc
PRINT DYNARR¢<3,
would display the contents of value 2 of attribute 3 of DYNARR
(including any subvalue-marks):
e\ce\cce
PRINT DYNARR<3,2,1>
would display the contents of subvalue 1 of value 2 of attribute 3 of
DYNARR:
16-20 This is Advanced Pick
If we were to apply each of the following statements one after the other:
DYNARR<1> 'QQQ'
would replace the contents of attribute 1 of DYNARR (and any value-
marks and subvalue-marks) by the string QQQ:
DYNARR<9> 'XX'
would replace the contents of attribute 9 by the string XX. If there
were fewer than 9 attributes in the array, sufficient attribute-marks
would be added to position XX at attribute 9:
QQQ°B]BB]BBB*C]c\cc\ccc]cc*pp***** xx
DYNARR<O> 'YES'
would insert a new attribute YES at the front of the data in DYNARR,
moving all the existing data up by one attribute:
YES*QQ0*B] BB] BBB*C]c\cc\ccc]cc*pD*****xX
DYNARR<3,2> 'bbb'
would replace the contents of value 2 of attribute 3 of DYNARR (and
any subvalue-marks) by the string bbb:
YES bbb]
DYNARR<4,2,1> =
would replace the contents of subvalue 1 of value 2 of attribute 4 of
DYNARR by null:
DYNARR<-1> 'QW'
would append the string QW as a new attribute to the end of
DYNARR:
YES *QQQ°B] bbb]BBB*C]\cc\ccec]cc*pD***** XX*OW
DYNARR<1,-1> 'A123'
would append the string A123 as a new value to the end of attribute
1 of DYNARR:
YES ]A123°900°B]bbb]BBB*C]\cc\ccc]cc*DD*****XX" QW
DIMARR2(4,5)<3>
and so on. If we add the substring notation to this, we get terrifying forms
such as:
DIMARR2(3,4)<5,6,7>[8,9]
STRING separated
either of these will use the fields within the variable
by attribute-marks and load these as successive elements into the
dimensioned array INCOME.
Both dimensioned arrays and dynamic arrays can be used for building
and holding lists of data used by the program and for holding data which
is read from disk files and/or which is to be written to disk files. In these
situations, the programmer is often faced with the decision of whether to
use a dimensioned array or a dynamic array.
are more intelligible and much easier to write and maintain than are
statements such as:
PRINT DIMARR(7)
DYNARR(7) = DYNARR(7) + 7
and:
PRINT DYNARR<7>
DYNARR<7> DYNARR<7> + 7
The statements:
EQUATE NAME TO DYNARR<1>
INPUT DYNARR<3>
As you see, there are no hard and fast rules ... just points to be
considered.
© Selection: those which test the data and take one of several different
courses of action according to the result:
IF ANSWER 'Y' THEN GOTO 1000 ELSE GOTO 2000
CASE CODE=A''; GOSUB Add. routine
ON CODE GOSUB 100,200,300,400
FOR NUMBER 1 TO 10
TOTAL * TOTAL + NUMBER
PRINT NUMBER. TOTAL
NEXT NUMBER
As these last examples indicate, there are facilities for passing control to
and from internal subroutines, and also for creating and calling
external subroutines which are written as separate coding units.
16.5.1 Statement labels
GOSUB Vet.dataname
GOTO End.of.job
ON OPTION.NUMBER GOSUB Add, Change, Delete
GOTO 100
GOSUB 200
GOTO 200.99
16.5.2 IF structure
The IF statement,
The CASE statement, and
The computed GOTO, and
The computed GOSUB statements.
The IF statement may take any of the forms shown in Figure 16.9. When
the statement is executed, the condition (A=B) will be tested; if the result
is true (if A Ais equal to B), then the statement(s) in the THEN clause (A=0)
will be executed; if the result is false (if A is not equal to B), then the
statement(s) in the ELSE clause will be executed. The IF statement may
be a single-line statement, as in example 1, or it may be presented as a
multiline structure, like example 4. In general, the coding is easier to
write, to read and to understand if it is written as a multiline structure with
the dependent statements (A=0 and B=0 in these examples) indented, as
illustrated
Inany of these forms, the condition A=B can be any /ogical expression
and the statements A=0 and B=0 may themselves be any statement, any
sequence of statements, or any other structure. Here are some more
examples:
IF ANSWER='YES' THEN STOP
terminate the program execution if the variable ANSWER contains the
string YES.
IF TOTAL > MAXIMUM THEN CRT 'TOO BIG'
display the message TOO BIG if TOTAL contains a value greater than
that in MAXIMUM.
There are several other Basic statements which have the same
THEN/ELSE structure, including:
OPEN ...
READ ...
READV ...
MATREAD ...
READNEXT ...
LOCATE ...
INPUT ...
and any of these may be presented as a single-line statement or as a
multiline structure, as illustrated by example 9 in Figure 16.9.
The test such as that carried out in the IF statement is sometimes called
a logical expression. A logical expression is any combination of:
Variables,
Literals,
The logical operators (as illustrated below),
The logical connectives (AND /OR/&/! as illustrated below), and/or
Logical functions (NOT i/ NUM/ ALPHA / ASSIGNED),
which produces a value of false or true, and they are encountered in
several contexts in Basic:
nn Checks that the value comprises only n numeric digits, that is, 0 to
9.
na Checks that the value comprises only n letters of the alphabet, that
is, A Ato Z (upper-case) and a to z (lower-case).
To check that a value does nof match a certain pattern, you will use forms
such as:
IF CODE MATCH '3N' ELSE PRINT 'Not 3 digits'
IF NOT(CODE MATCH '3N') THEN PRINT 'Not 3 digits'
CASE NOT(CODE MATCH '3N')
The IF statement tests the value of a logical expression and takes one of
two possible courses of action. The CASE statement offers a means of
taken any one of several courses of action, according to a sequence of
tests. The structure of the CASE statement is illustrated by the examples
in Figure 16.10.
Let's start by looking at fragment (a). As this is executed, the first CASE
condition (A=1) will be tested: if this is true then the statements:
B=A
C=A
will be executed, and the processing will then jump out of the structure -
B=B*2
will be executed, and the processing will then jump out of the structure -
to statement number 99. This testing will continue until all the CASE
conditions have been tested (and you may have as many CASE sections
as you wish): if none of the conditions is true, then the processing will fail
straight through the CASE structure and carry on with the processing
following the END CASE statement (statement number 99).
BEGIN CASE
CASE A=1
BeA
CzA
CASE A=2
B=B*2
c=c*2
CASE AsO OR BT0
c=0
END CASE
99 * Rest of program
(a)
CRT 'Enter option N :
INPUT REPLY
BEGIN CASE
CASE REPLY='N'; ALL NEW. ROUTINE
CASE REPLY='C'; CALL CHANGE.ROUTINE
CASE REPLY='D' CALL DELETE.ROUTINE
CASE REPLY='S'; STOP
CASE 1
16-30 This is Advanced Pick
(b)
The result of CASE 7 is always true (recall that a value of 0 is false and
any other numeric value is true).
Some points to note about the CASE structure:
© The entire set of CASE statements is enclosed in a pair of BEGIN
CASE / END CASE statements.
© There may be any number of CASE statements within the structure.
° The statements which are dependent upon a CASE statement may be
written on the same line (separated by a semi-colon), or as separate
ines.
© The first CASE statement which is satisfied is acted upon and the
processing leaves the structure, ignoring any later CASE statements.
© Each CASE statement is quite independent of the others.
o One CASE structure may be nested within another.
In practice, you will find the CASE structure a very convenient coding
device, and in many situations more manageable and easier to write and
extend than the equivalent IF structure(s).
16.5.6 ON...GOTO/ON...GOSUBstatements
Two further statements simulate the multiple testing that you get with the
CASE structure: ON ... GOTO and ON ... GOSUB. These are sometimes
known as the computed GOTO statement and the computed GOSUB
statement, as illustrated in Figure 16.11.
Look at the ON ... GOTO statement shown here. When this is executed,
the value held in CODE will be tested: if the value is 1, then the
processing will jump to statement label 100, if the value is 2, then the
processing will jump to statement label 177, and so on. If the value of
The Basic language 16-31
CODE is less than 1 or (in this case) greater than 6, then no action is
taken and the processing passes on to the next statement.
16.5.7 Iteration
There are two structures which can be used to control the number of
times which a piece of processing is executed: the FOR ... NEXT
structure, and the LOOP structure
and the end of the repeated section is marked by the NEXT statement:
next Variable
LOOP LOOP
LOOP LOOP
UNTIL condition DO WHILE condition DO
LOOP LOOP
LOOP
PRINT MSG1: ; INPUT CODE
UNTIL CODE=' DO
The Basic language 16-33
GOSUB 100
REPEAT
LOOP
CRT 'Enter Y or N: 0
INPUT RESPONSE
UNTIL RESPONSE?'Y' OR RESPONSE='N' DO REPEAT
LOOP
CRT 'Enter Y or N: :
INPUT RESP,1
''
UNTIL RESP NE AND INDEX('YyNn',RESP,1) DO
CRT 'Please enter Y for YES or N for NO'
REPEAT
LOOP
PRINT MSG2:; INPUT CODE
WHILE TRIM(CODE) = DO REPEAT
LOOP
* Do this indefinitely
GOSUB Get.data
GOSUB Analyse.data
REPEAT
3) any statements in block2 are executed then the loop starts again from
the beginning.
When you are using multiline structures such as IF, CASE, FOR and
LOOP, it is easy to forget an END, END CASE, NEXT or REPEAT
statement, and itis often difficult to determine where a missing statement
should go. The program indentation utility B/LIST will indent the source
16-34 This is Advanced Pick
form:
For example:
B/LIST WAGES.BP * (P
B/LIST MBPROGS SENTENCE01 (FO
The utility will display or print a listing showing the logical indentation, and
there are options to indent the statements of the source program.
Amongst the most useful options are:
r save the formatted program on the file and suppress the display.
o overlay the original program. Otherwise, the formatted program is
saved as xx.BLIST.
p send the listing to the printer.
force all indentations to zero. This is useful for compressing
source programs in order to save space.
s draw vertical lines on the listing to indicate the program structure.
EPick gives full details of the utility and the options which are available.
16.6 Calculations and assignment statements
The keyword LET is optional. in all cases, the expression to the right of
the = sign is evaluated, and the result assigned to the variable (or array
element) specified to the left of the = sign.
There are three main types of assignment statement:
o Arithmetic assignments,
© String assignments, and
© Logical assignments.
RESPONSE "YES"
INITIAL = FIRST.NAME[1,1]
: INITIAL
''
SALUTE = 'MRS : : SURNAME :
UNDERLINE STR('=',LEN(SALUTE))
The string operators are shown in Figure 16.15 (b). Substrings may be
extracted from a string by the square-bracket notation:
SURNAME = 'ABCDEFGH'
KEYX SURNAME[2,3]
which will extract three characters from the string in SURNAME, starting
at the second character, and assign the result (BCD in this case) to
KEYX. The same notation can be used to replace a substring within a
string:
STRING 'THE CAT SAT ON THE MAT'
STRING[5,3] 'ABCDE'
would insert the string ABCDE into the contents of STRING, replacing the
three characters starting at the fifth character, leaving THE ABCDE SAT
ON THE MAT in STRING.
The logical operators and connectives are shown in Figure 16.15 (c).
Operator Meaning
+ addition
subtraction
multiplication
division
integer division, returning the remainder
ae exponentiation
Operator Meaning
concatenation
16-36 This is Advanced Pick
car concatenation
[a,b] substring extraction / replacement
Operators Meaning
= £9 equal
# NE «> 9¢ not equal
less than
Gf greater than
LE less than or equal to
>= GE greater than or equal to
AND & and
OR ! or
and no value had yet been assigned to VALUE2, the program would
report a non-fatal execution error:
Variable has not been assigned a value: zero used!
VALUE2 = 0
''
STRING
or the CLEAR statement may be used to assign 0 to all the variables and
dimensioned array elements in the program. Typically, the CLEAR
statement will be used at the start of the program. If you use it elsewhere,
you should bear in mind that:
© Inthe main program, CLEAR will clear the contents of all COMMON
variables and all local variables, but will not clear labelled COMMON
variables.
© Inan external subroutine, CLEAR will only clear the contents of local
variables.
The ASSIGNED function is available to detect whether a variable has
been assigned a value:
IF ASSIGNED(VALUE3) ELSE VALUE3 = 0
IF NOT(ASSIGNED(VALUE3)) THEN VALUE3 0
processing using data supplied by the program. For example, the SQRT
function used in the statement:
ROOTX = SQRT(RESULT)
will take the value held in the variable RESULT this value is known as
the argument for the function calculate the square root of this number
-
and pass the result back to the program where it is assigned to ROOTX.
Some functions have more than one argument:
SPARE = MOD(AVAILABLE, BOXSIZE)
divide the contents of AVAILABLE by the contents of BOXSIZE and
return the remainder, storing it in SPARE in this example..
WORDS = FIELD(SENTENCE, 5)
scan the string held in SENTENCE and return the substring enclosed
by the fourth and fifth spaces, that is, the fifth word, placing this in
WORDS.
Some functions have no arguments, but the parentheses must be used:
TODAY DATE()
NOW TIME()
return the current date and time (in their internal formats).
pate()returns today's date in the internal form, that is, the number of days
since 31/12/67.
PRINT 'Today is ': OCONV(DATE(),'D')
AGE = DATE() - AGE.FIELD
ICONV
The Basic language 16-39
time (returns the current time in the internal form, that is, as a number of
seconds since midnight.
PRINT 'It is now ': OCONV(TIME(),'MTS')
DELAY TIME() -
START. TIME
As the table in the Appendix shows, there are many more functions
available; there are also the %ox functions which interact with the host
environment on AP/DOS and AP/Unix systems. EPick gives full details.
Function Result
ICONV('29.7.99','D') 11533
OCONV(11533,'D') 29 Jul 1999
OcONV (11533, 'DWA') Thursday
OCONV(12345, 'MTS') 03:25:45
oconv('29.7.99','Gi.1') 7
OCONV('MARY JONES', 'MCT') Mary Jones
OCONV('MARY JONES', 'MCL' ) mary jones
OCONV('mary jones', 'MCU') MARY JONES
ICONV(1234.5678, 'MD2') 123457
OCONV(123456789, 'MD2,') 1,234,567.89
OCcONV(0, 'USOBB' ) 17 mary dm
OcONV(0, 'U60BB' ) mary dm
ICONV(value, code)
OCONV (value, code)
where value is any expression and code is one of the processing codes
described below. ICONV converts data to an internal form and OCONV
converts data to an external form. Look at these examples:
EXTERNAL=OCONV(INTERNAL,'D')
takes the number held in INTERNAL and convert this to the exfernal
The Basic language 16-41
INTERNAL=ICONV( EXTERNAL,
takes the date held in EXTERNAL, in a form such as 31/12/95 or 31
December 1995, and convert this to the intemal date format, placing
the result in INTERNAL.
CAP.NAME=OCONV(NAME, 'MCU')
takes the string held in NAME and convert this to UPPER-CASE,
placing the converted string in CAP.NAME.
The processing codes which can be used in these functions are D/G/
MC /MD/MT/Tn,m//Tfile /U. However, the effects of some of these -
notably G and Tn,m and Tfile can be achieved directly by the facilities
-
of Basic. The examples in Figure 16.17 illustrate the use and results of
some examples of the ICONV / OCONV function. In those forms which
are marked with an asterisk, either ICONV or OCONV may be used with
the same effect. We take a closer look at processing codes in Chapter
14.
1
10 Returns if there is data waiting in the stack.
CRT SYSTEM(3)
CRT SYSTEM(100)
will display details of the Advanced Pick release number which is being
used.
Some other examples are shown in Figure 16.18. EPick gives full details
of what is available.
DYNARR<a>
DYNARR<a,v>
DYNARR<a,v,s>
The Basic language 16-43
specifying the attribute, the value and/or the subva/ue concerned. There
are several standard functions for handling dynamic arrays.
To extract an element from a dynamic array, you will use the following
forms:
PRINT DYNARR<7>
print attribute 7 of the dynamic array DYNARR.
VALUE2DYNARR<2> * DYNARR<5>
multiply attribute 2 by attribute 5 and assign the result to the variable
VALUE.
You may find some R83 Pick programs which use the older EXTRACT
function for the same purpose:
The forms using the <a,v,s> notation.and the INS and DEL statements,
are shorthand forms of the older EXTRACT and other functions shown
here. The compiler actually replaces these by the original functions.
DYNARR<6>=DYNARR<2> * 100
DYNARR = REPLACE (DYNARR, 6;EXTRACT(DYNARR,2) * 100)
replace attribute 6 by 100 times attribute 2.
To append an element to the end of a dynamic array:
DYNARR<-1>='123'
DYNARR = REPLACE (DYNARR, -1;'123')}
DYNARR = INSERT(DYNARR,-1;'123')
append the value 123 as a new attribute to the end of DYNARR.
DYNARR<5,-1>='B'
append a new value to the end of attribute 5 of DYNARR.
DYNARR<6,7,-1>='C'
append a new subvalue to the end of value 7 of attribute 6 of
DYNARR.
To insert a new element into a dynamic array:
INS 'A' BEFORE DYNARR<7>
DYNARR INSERT(DYNARR,7; 'A')
insert the value A as a new attribute before attribute 7 of DYNARR.
INS 'B' BEFORE DYNARR<1>
DYNARR<O>
16-44 This is Advanced Pick
Inall cases, the appropriate element and its associated field separator will
be deleted from the dynamic array.
Other statements and functions available for use with dynamic arrays
include MATBUILD and MATPARSE which we met earlier and:
sum return the sum of all the attributes (or values or subvalues) of a
dynamic array:
TOTAL SUM(DYNARR)
The statement shown in Figure 16.19 (a) will scan the dynamic array held
The Basic language 16-45
in NAMES.1 and look for the first attribute which consists of the word
SMITH. Having found such an attribute, the processor will put the
attribute-number of that attribute into WHERE and take the action
specified in the THEN clause; the search will then terminate, ignoring any
repetitions of SMITH. If it cannot find the word SMITH, then it will take the
action specified in the ELSE clause and the variable WHERE will contain
a number one more than the number of attributes in the dynamic array.
Only elements which exactly match the sought string are recognised; the
presence of a partial string, such as in the name SHOESMITH, will be
ignored.
If the names in the dynamic array are known to be sorted in some specific
order, say, Ascending Left-justified, then the statement may be written as
in Figure 16.19 (b). As before, the statement will scan the dynamic array
in NAMES.2 looking for the first occurrence of the word SMITH. If the
word SMITH can be found, the THEN clause will be executed and the
variable POSN will contain the number of the attribute where SMITH was
found. However, if there is no SMITH in the array, the search will
terminate when a word alphabetically greater than SMITH (such as
SMYTHE or WATKINS) is found, the ELSE clause will be executed and
the value of POSN will contain the position of this attribute, that is the
attribute where SMITH would have been if it had been in the array and in
the correct order.
In all these forms, the THEN clause is executed if the element is found,
and the ELSE clause if it is not found. A typical action within the ELSE
clause might be to add the value uniquely to the dynamic array. Figure
16.19 (c) shows he we might use this to add names to the list, thus
constructing a sorted list of names.
INPUT NAME
LOCATE NAME IN NAMES.2 BY 'AL' SETTING POSN THEN
PRINT NAME: '
already in the list'
END ELSE
INS NAMES.2 BEFORE NAMES. 2<POSN>
END
(c)
Figure 16.19: LOCATE statement
16-46 This is Advanced Pick
and, if the statement ends in a colon, the cursor will be held in position
immediately after the message:
CRT 'Enter your name:
INPUT SURNAME
and each individual value will appear at the left of an 18-character wide
column. These forms are illustrated by the program and the output in
Figure 16.20.
INPUT NAME
PRINT
The Basic language 16-47
1. 4142 2 4 8
1 +732 3 9 27
2 4 16 64
2-236 5 25 125
2. 4494 6 36 216
2 6457 7 49 343
2.8284 8 64 $12
3 9 81 729
3.1622 10 100 1000
3.3166 11 121 1331
with the mask immediately following the data value. Some examples
might be:
PRINT VALUE 'R2'
PRINT VALUE '2'
PRINT KEY 'R%10'
PRINT (NAME ') 'L#10° : NUMBER
PRINT VAL1 MASK1: VAL2 MASK2: VAL3 MASK3
{§}{$}{.}{n{m}}{xs}{c}
where:
Some examples, showing the source data, the mask and the results, are
shown in Figure 16.21. I've used the ~ character to represent a space
where it is significant.
Source ]
Mask |
Result ||
source |
Mask, |
Result
12345 %3 123 -123.456 L2$% 0 $-123.460
ABCDE $3 ABC | 123.456 L2$%10 $123.46000
The Basic language 16-49
The @ function generates a string which, when used with the PRINT or
the CRT statement, will move the cursor to a particular position on the
screen or produce some other display effect. Here are some examples:
@(column, row)
16-50 This is Advanced Pick
and:
@(column)
The top of the screen is row 0, and the left of the screen is column 0.
CRT @(-1)
clear the screen.
CRT @(12,12):MESSAGE: @(-3):
display a message at the centre of the screen and then clear the rest
of the screen (below and left of the message).
Some of the available arguments for the @ function are shown in Figure
16.22. The same forms are used with the Proc T statement, as discussed
in Chapter 17. EPick gives full details of the forms of the @ function
which are available on your system.
@(-1) clear the screen and move the cursor to the top left corner of
the screen.
@(-2) move the cursor to the top left corner of the screen.
@(-3) clear the rest of the screen (below and right of the cursor
position).
@(4) clear the rest of the line (right of the cursor position).
PRINT @(5,5):NAME:
will not produce the desired effect of positioning the text when sending
output to the printer. There are, however, certain forms of the @ function
which can be used with the printer, such as those which download printer
fonts and impose other settings on the printer. The System Manager can
extend these and the other @ functions by using the DEFINE-TERMINAL
command to make the appropriate changes to the items on the DEVICES
file which control each type of terminal and printer.
16.7.4 PRINTER ON
The PRINT statement normally displays the output on the screen. If you
wish to print your results on the printer, then you must first activate the
spooler by using the:
PRINTER ON
statement. All subsequent PRINT statements will then send their output
to the printer (strictly, we should say to the spooler); this continues until
the program terminates or until you execute the:
PRINTER OFF
statement. The actual printout is produced only when the spooler job is
closed; this will be when the program terminates or when the:
PRINTER CLOSE
or, if the program has been catalogued and you invoke it with a command
such as:
WAGES001 (P
16.7.5 PRINT ON
distinct printed reports at the same time. For example, the statements:
will send one set of output to print-file #1 and the other to print-file #2. At
the end of the program (or when a PRINTER CLOSE statement is
executed), all the output sent to print-file #1 will come out together, then
all the output sent to print-file #2, and so on. If you have issued TCL
commands such as:
SP-ASSIGN R1 F3
SP-ASSIGN R2 F7
prior to executing the program, then all the output which the program
sends to print-file #1 will go form-queue 3, and all that sent to print-file #2
will go to form-queue 7. Depending upon the way in which the System
Manager has set up your spooler system (as we discuss in Chapter 19),
the print-files may go to different printers.
Embedded within the text of the message, you may include any of a
number of special opfions enclosed in apostrophes. The most important
of these options include:
hit <Return> before starting a new page and resetting the line counter.
If the output is going to the printer (because a PRINTER ON statement
has been executed), then the action will be identical, except that the page
length will be different (typically 60 lines per pag) and it will not pause at
the foot of each page.
statement. This will output the footing and/or the heading and zeroise the
line counter. The extended form:
PAGE 1
or:
PAGE CNTR
will reset the page number which appears in the heading / footing. The
SYSTEM(4), SYSTEM(5) and SYSTEM(6) functions shown in Figure
16.18, can be used when a HEADING/FOOTING is active in the program.
Itis important to note that the line count which controls the pagination is
only incremented by PRINT statements which do not end in a colon.
Thus, statements such as:
PRINT NAME:
CRT NAME
CRT NAME:
OUT NUMVALUE
PRINT NAME
PRINT NAME, AGE
PRINT
PRINT 'The answer = ': RESPONSE
will increment the counter.
Although only one heading and one footing may be in action at one time,
you may change your HEADING / FOOTING as often as required, and
each will become effective at the next page break. Advanced Pick has no
formal means of cancelling a heading / footing, and you must be
particularly conscious of this if you are mixing printer output and screen
output using the PRINT statement, since any heading / footing which you
may have set for a printed report will still be effective when you go back
to PRINT output on the screen. One means of disabling a heading /
footing which you set earlier is to use a form such as:
HEADING "'N'"
FOOTING "'N'"
in which the N option suppresses the end-of-page pause on screen
16-54 This is Advanced Pick
output; without this, you would simply impose a null heading / footing and
the pagination control would still apply.
Most programs have some means of interacting with the user. This is
often conversational in nature, displaying questions on the screen and
accepting the user's response from the keyboard. The INPUT statement
is used to accept data typed in at the keyboard as the program is
executing and store the input in a variable. The program in Figure 16.23
uses the INPUT statement to ask the user for a series of numbers and,
when he/she finally enters END, the program displays the total.
TOTAL=TOTAL+NUMBER
REPEAT
CRT
CRT 'The total is TOTAL
the program will halt and wait for the user to type in a value, a number or
a string, and press <Return>; the value will then be placed in NUMBER
so that it can be used by the program. The data is placed in the variable
exactly as entered by the user, including any spaces.
Normally, the program will display a question mark to indicate that it is
waiting for input. You can use the PROMPT statement:
PROMPT ': '
to change this to any other character. You can even cancel the prompt
character altogether:
''
PROMPT
in which case you would probably include ail the text and punctuation in
your prompt messages:
PRINT @(0,5): 'Enter your name:
INPUT NAME
PRINT @(0,6): 'How old are you?
INPUT AGE
The Basic language 16-55
You can only accept one piece of information (that is, a single numeric
value or a single string) in each INPUT statement. If you want to ask the
user for several pieces of data, then you must use several INPUT
statements:
INPUT NAME
INPUT INITIALS
INPUT TELEPHONE.NUMBER
INPUT SCORE(ROW, COL)
INPUT INCOME(5)
which will wait for five seconds and then jump to a subroutine to remind
the user that input is required (possibly sounding the terminal bell) before
returning to wait for the input.
and will place a value, or sequence of values, in a queue from which they
will taken, one at a time, by the next operation(s) which requires input
from the keyboard. This is particularly useful when you are testing a
program which uses the INPUT statement to accept data from the
keyboard
To illustrate this, let us imagine that you are writing a program which
requires two pieces of data from the user: a file name, and an item-id.
The fragment in Figure 16.24 shows how we might use the DATA
statement to feed the INPUT. The DATA statement places two strings -
STOCK and 1000 in the data queue, and these are picked up in turn by
-
the two INPUT statements. This avoids your having to type in the same
data each time you test the program. When the program has been
tested, the DATA statement can be removed and the INPUT statements
will then come to the keyboard for their data.
16-56 This is Advanced Pick
DATA 'STOCK',1000
* Get file name
CRT 'File name:
INPUT FILE.NAME
OPEN FILE.NAME
* Get ITEM ID
CRT 'Item id: :
INPUT ITEM.ID
READ RECORD FROM FV, ITEM.ID
Like some R83 Pick releases, Advanced Pick offers two further
statements for handling input and output to the terminal: IN and OUT.
These are valuable when the terminal supports non-standard equipment
such as bar-code readers and point-of-sales equipment.
and this will accept a single character from the keyboard. Thus, if the
user responded by typing the letter:
A
the value 65 (that is, the decimal value of the ASCII A character) would
be placed in XCODE. When you use the IN statement:
o There is no prompt displayed,
© The <Return> key is not required.
© The cursor remains in position immediately after the newly-displayed
character.
© Control characters, such as the <Return> key, the cursor-control keys
and backspace, are acceptable as input characters. The
<Backspace> key does not, in this context, have the effect of moving
the cursor back.
The OUT statement does the opposite. Thus, the statement:
OUT VALUE
will take the numeric value held in VALUE and convert this to the
equivalent ASCII character and send this to the terminal. So, if VALUE
contained the number 65, this statement would display the letter A on the
screen.
powerful facilities for data input. This has the general form:
where c and r specify the screen position (as in the @ function) at which
the data is to be accepted; mask is any format mask which is to be
imposed on the data as it is redisplayed on the screen. To illustrate this,
let's consider these statements:
TAX=0
INPUT @(5,12): TAX "R2#12"
When this statement is encountered it will clear the bottom line of the
screen, if there is already an INPUTERR error-message there, and
display the message. Note that despite the keyword there is no error-
- -
is not executed immediately, but indicates that, if the user enters * at any
subsequent INPUT @ statements, then this is to be interpreted as a nui!
value. Any single character may be specified, and this null-indicator will
stay in operation until it is changed by a subsequent INPUTNULL
statement.
The INPUTTRAP statement has two forms and allows a set of special
single-character codes to be input by the user. If one of these special
characters is entered, the processing will jump to a specific statement
label where the program will take the appropriate action. Some examples
of this statement are:
INPUTTRAP "?/.¢>" GOTO 10,20,30,40,50
INPUTTRAP "?/.<>" GOSUB 10,20,30,40,50
INPUTTRAP '?/.<>' GOTO Help, Scrub, Stop, Back, Forward
Whenever you are accepting data from the user, you should pay
particular attention to the question of case sensitivity. Unless you have
issued any special statements in your program, all data is case
insensitive. For example, data which is handled by a program may be
entered and held as:
and all four forms will be equivalent for the purposes of statements such
as:
subsequent data strings, including keyboard input data and file data, are
to be case sensitive or not. If CASING is OFF, then the four values shown
here are considered to be identical; with CASING ON, the four will be
different strings.
16.9 Subroutines
GOSUB Vet.dataname
The program then jumps to that statement label and continues executing
from there. When a:
RETURN
If you wish to use the same coding in several programs, you could use an
external subroutine. As a simple example, let us suppose that want a
|
Note that the first line of this item consists of the word SUBROUTINE
followed by the name of the subroutine.
01 SUBROUTINE SCREEN.MASK
02 * General subroutine to ee
03 * Clear the screen
04 CRT @(-1):
05 * Display the time .
06 CRT @(0,0)sOCONV(TIME(),'MTS'):
07 * Display the date
08 CRT @(SYSTEM(2)-7,0) OCONV(DATE(),'D2/')
:
09 RETURN
amended and compiled just like a normal program. When need to use |
CALL SCREEN.MASK
or:
CALL 'SCREEN.MASK'
or:
TARGET='SCREEN.MASK'
CALL @TARGET
But how does my program know where the coding for the
SCREEN.MASK routine is to be found? It doesn't! So the run-time
processor always looks to the MD and expects to find an item there called
SCREEN.MASK which records the name of the file and the item where
the SCREEN.MASK subroutine is to be found. must create this
|
when have compiled the subroutine. We'll say more about cataloguing
|
and within the subroutine, can use and change the contents of the
variables COUNT and DATANAME; these are known as local variables.
When the RETURN statement is executed, the contents of the local
variables COUNT and DATANAME are transferred back to the main
program, thus passing the DATANAME, which was input in the
subroutine, back to the main program. use another external subroutine
|
01 *
Program to construct simple Access sentences
02
05 PROMPT
06
07 EQUATE DN TO CHAR(10)
08 COUNT = 1
13
14 Loop
04 EQUATE DN TO CHAR(10)
07 INPUT DATANAME
08 DATANAME = TRIM(DATANAME)
09 RETURN
04 EQUATE DN TO CHAR(10)
11 COUNT = COUNT + 1
12 RETURN
13 Missing:
14 CRT MSG2 : DATANAME
15 CRT MSG3
16 RETURN
04 CRT ON : 'Executing *
: SENTENCE
06 INPUT RESP, 1
0s RETURN
-
might be left to junior programmers Furthermore, If ever need to
|
modify, say, the SCREEN. MASK subroutine, can do this quite easily and
independently without having to change the SENTENCE01 program or
the other subroutines.
A main program and each subroutine has its own local variables which
are held with the code for that program or subroutine. When a CALL
statement is executed, the data is passed from one set of local variables
to another, and the data is transferred in the opposite direction when the
RETURN statement is executed.
16.9.4 Passing data to external subroutines -
2
As the number of names in the parameter list increases, the time taken
to pass control to and from the subroutines also increases. We can
overcome this by using a set of COMMON variables which are directly
accessible from the main program and all the subroutines. Figure 16.27
shows how this might be done. Note the following points:
© I've only shown those parts of the program and the subroutines which
have changed. The rest is as before.
co The COMMON statement in the main program and the subroutines
declares a list of variables which are to be held as COMMON or -
being held outside the program and not as local variables which
would be accessible only to the individual program or subroutine.
© The CALL statement and the SUBROUTINE statement do not now
use a parameter list to pass the data.
© The variables in the COMMON set are identified by their position within
the set and not by name.
16-64 This is Advanced Pick
06
07 EQUATE DN TO CHAR(10)
08 COUNT .1
09 SENTENCE = "SORT STOCK'
10
11 CALL SCREEN.MASK
13
14 LOOP
16 UNTIL DATANAME = bo
18 REPEAT
19
20 CALL EXECUTE.SENTENCE
04 EQUATE DN TO CHAR(10)
04 EQUATE DN TO CHAR(10)
01 SUBROUTINE EXECUTE.SENTENCE
COMMON data
0 (1] (7)
ll
t
COMON
Code
coun {2]--] DATANAME |
l
I 'SENTENCE |
il ll
COMON SCREEN.MASK
Code for subroutine
T
j
(1]
-f
COMON
sone
DATANAME Tr Code
T. DATANAME
ll
subroutine
| 4)
Local
MSG1
SENTENCE
T stock. pict
MSG3
ll
I l Ll}
SCOMMON in VET.DATANAME.
04 EQUATE DN TO CHAR(10)
05 EQUATE DN TO CHAR(10)
01 SUBROUTINE EXECUTE.SENTENCE
04 EQUATE DN TO CHAR(10)
and, having done this, you would not need a DIMENSION statement to
identify ADDRESS as an array.
If you wish to use the same statement(s) or the same piece of source
code in several programs or subroutines, you can do this most easily by
setting up the statements as a separate item and including this item in
the programs and subroutines which need them. For example, might |
statement:
INCLUDE SENT.COM
or, if the program or subroutine which uses the item is held on a file other
than MBPROGS, would use:
|
When |
compile a program which uses this INCLUDE statement, the
compiler will read in the contents of SENT.COM and compile them just
as if i had written the COMMON statement explicitly. Of course, if |
and subroutines which use it. The SENT.COM item is not compiled on its
own.
This last example would execute the CALC program and then submit two
data values 10 and 100 which might be picked up by INPUT statements
in CALC.
As we saw earlier, the DATA statement offers an alternative means of
submitting data to the EXECUTEd command:
DATA '(OLD.STOCK'
EXECUTE 'COPY STOCK *'
and the DATA statement can also be used to pass data to a program
which is invoked by the EXECUTE statement:
and these values will be passed to the first two INPUT statements which
are executed within the CALC program.
used in Figure 16.30 (b), the CAPTURING clause specifies that the report
which would be displayed by the command is not to be output, instead, it
is to be captured and placed in a variable called OPUT; the contents of
OPUT will be a dynamic array, one attribute for each line which would
have been displayed on the screen.
16:29:59 29 Jul 1995
memory pibs pcb0 sysbase/mod maxfid available dfsize
1664k 74 2048 2394 7 28536 2690 1000
417 417
message 417:
(417] File 'xx' created; base = ff, modulo = mm
twice, once for each of the DICT and the data sections of the newly-
created file).
and loading the first four elements of the dimensioned DIMARR with the
values 417, STOCK2, 9876, and 37. Compare this with the EXECUTE
statement mentioned above.
If you do not want to return to your program after the command has been
executed, you should use the CHAIN statement. This has forms such as:
CHAIN 'SORT STOCK WITH TYPE "DESK" LPTR'
CHAIN 'SORT FILE: WITH ':FIELD:' "": VALUE'" LPTR'
CHAIN COMMAND
CHAIN COMM1 : CHAR(254) : COMM2 : CHAR(253) : COMM3
and is slightly faster than the equivalent EXECUTE and TCL statements.
16.12 TCLREAD statement / ERROR() function
We have seen that the INPUT statement can be used to ask the user for
16-72 This is Advanced Pick
TCLREAD COMMAND
LETTER FIELD(TRIM(COMMAND), ',4)
within the WAGES program could be used to place the entire TCL
command as string in COMMAND, and then extract the code M or W in
a
these will have their normal effect (printing any PRINT output in this
instance) and they will also appear in the string returned by the TCLREAD
statement exactly as they were entered. No matter whether or not the
TCLREAD statement has been used, you can also obtain the options
directly with the SYSTEM(15) function call. This returns all the options on
the command sorted into alphabetical order and removes any duplicates
and any non-alphabetic characters.
The effect is the same and possibly more convenient if the program
- -
has been catalogued and can be invoked by TCL command such as:
rsa
WAGES M
WAGES W (P
SYSTEM(15) function.
16.12.1 PROCREAD / PROCWRITE statements
The TCLREAD statement and the ERROR0 function are new to
Advanced Pick. Programmers who have moved from R83 Pick will be
familiar with the older PROCREAD statement. This is available on
Advanced Pick and is yet another means of obtaining the TCL command
which invoked the program:
XXXXX
01 PQ
02 HRUN MBPROGS WAGES
03 P
is available to load a string into the Proc input buffer; this would be used
to pass information back to the Proc which invoked the program.
DELETE
CLEARFILE
statements which allow you to handle the data held on Pick files. You
may handle the entire item as a dimensioned array or as a dynamic array,
or you may handle a single attribute of an item.
When you are using an Advanced Pick tool such as the Update Processor
or Access, you will refer to each file by a name such as STAFF or
STOCK
LIST STAFF WITH NAME "JONES"
LIST STOCK DESCRIPTION QUANTITY
and we can think of these names as the external names of the files.
When you are using Basic to process the items on your files, you must
first identify the files that you wish to use. This is achieved by means of
the OPEN statement. The general form of this statement is:
will locate the file STOCK and store the location (the base FID and the
modulo) of the file in a variable STOCK.FV in this instance, linking the
external name of the file (STOCK) with the internal name (STOCK.FV).
STOCK.FV is known as the file-variable. Some other examples are:
OPEN 'DICT STOCK' TO DICTVAR THEN GOTO 90
OPEN 'DICT', 'STOCK' TO DICTVAR THEN GOTO 90
FILE='STAFF'
OPEN FILE TO STAFF THEN GOSUB 100 ELSE GOSUB 200
A program may handle as many files as you need, and each one will be
opened to its own file-variable. If your program is using only a single file,
it is possible to omit the file-variable, using statements such as:
The OPEN statement has THEN/ELSE structure, and this has the same
a
statement. The THEN clause is executed if the file can be found and the
ELSE clause if the file cannot be found. You may omit the THEN/ELSE
clause:
The Basic language 16-75
in which case the compiler will interpret these as if you had written:
Having opened the file, you may now read items from the file, write items
to the file and/or delete items from the file.
For example:
READ STOCK.ITEM FROM STOCK.FV, 1234 ELSE GOTO 10
READ STOCK.ITEM FROM STOCK.FV, *1234° ELSE STOP
ID=1234
READ STOCK.ITEM FROM STOCK.FV, ID ELSE GOTO 10
STOCK. ID=1234
READ STOCK.ITEM FROM STOCK.FV, STOCK.ID THEN
GOSUB Found
END ELSE
GOSUB Missing
END
(1)
STOCK.ARRAY
CHAIR, ED, OAK 7 ll
(2) 7
(3) DN/5/88 l
(4) 1000
(5) 30 l
(6) 2000
wl
(7) 9876 ill
in which case the compiler will interpret this as if you had written:
READ RECORD FROM STOCK.FV, ITEMID ELSE RECORD='°
returning an empty string if the item cannot be found. This applies to all
forms of the READ statements described below.
has a similar action to READ except that the contents of the item (without
the item-id) will be placed in the dimensioned array called
STOCK.ARRAY: attribute 1 (value-marks, subvalue-marks and all) will go
into STOCK.ARRAY(1), attribute 2 will go into STOCK.ARRAY(2) and so
on, as illustrated in Figure 16.33. If the array is larger than the item (that
is, there are more elements in the array than attributes in the item), then
the final elements will be null; if the array is smaller than the item, then
the final attributes will be placed in the last element of the array as a
dynamic array.
The third READ statement, the READV statement, has the form:
The Basic language 16-77
and will go to the file opened to the file-variable STOCK.FV, but it will only
retrieve a single attribute attribute 7 in this example from the item with
- -
the item-id 1234 and place the data into DATE. This is illustrated in
Figure 16.33. If the attribute contains values and/or subvalues, these will
be placed in DATE as a dynamic array.
When you have read data from a file into your program, you may process
it as you wish: you can replace attributes with new values (a stock
description may change); you can perform arithmetic on numeric
attributes (goods may have been sold and the quantity in stock reduced,
or goods may have been received and the quantity in stock increased).
There are many possibilities.
PRINT STOCK.ARRAY(5)<1,2,3>
to handle the second subvalue of the third value of attribute 5. In all such
cases, the attribute number will always be 1.
If you are handling the file by means of READV/WRITEV statements, then
you will process the data as you would process a single piece of data,
and, if you want to handle multivalues within such a variable, you will use
references of the form:
PRINT DATE<1,3>
PRINT DATE<1,2,3>
16-78 This is Advanced Pick
When you have created a new item or amended an existing item, you
may want to write it to the file. You will do this by means of the WRITE
statement. Just as there are several READ statements, so there are
several corresponding forms of the WRITE statement. Exactly which
WRITE statement you use depends upon how the data is held by the
program:
WRITE RECORD ON STOCK.FV, STOCK.ID
WRITE '*REMOVED*' ON STOCK.FV, 'AB/1000°
The WRITE statement will regard the source data as a dynamic array and
use this to create the item on the file.
The MATWRITE statement will use the contents of the dimensioned array
to create the item, each element of the dimensioned array producing one
attribute of the item. Any trailing null elements in the dimensioned array
will be ignored.
The decision as to which READ (and which WRITE) statement you should
use and how you should process the data depends upon several factors:
how much data you want from the file (a single attribute or all the item);
how much processing you want to perform on that data (MATREAD is
better if there is a lot of processing on several fields); whether you can
predict the approximate number of attributes in the items (READ is better
if you are building items which have an unknown number of attributes).
It is quite acceptable if unusual
-
to use one form of the READ
-
statement to read data from the file, and a different form of the WRITE
The Basic language 16-79
statement to write data back to the file. If in doubt, you could do worse
than use MATREAD / MATWRITE.
Items are removed from the file by means of the DELETE statement.
This has a form such as:
DELETE STOCK.FV, 1234
or:
DELETE STOCK.FV, STOCK.ID
If there is no item with the item-id 1234 on the file which has been opened
to file-variable STOCK.FV, then no action will be taken. If the item does
exist, then itis deleted from the file. There is no undelete facility, so take
care.
To delete all the items from a file, you will use the statement:
CLEARFILE STOCK.FV
In a great many situations, a program will ask the user for the item-id of
the item which is to be handled and then read and process that item:
All forms of the READ and WRITE statements require a specific and
explicit item-id. There is no simple way in which Basic will allow you to
say "read me the next item on the file" or "create me a new item-id'.
There will be times when you want to perform batch processing,
handling all the items on the file or a range of items on the file. If the
items have calculable item-ids such as 1000, 1001, 1003, 1020 and so
on, then it may be a simple matter to write a loop such as:
FOR STOCK.ID = 1000 TO 2000
produces alist of the item-ids of the items on the file and associates these
with a select-variable, called STOCK.SV in this instance. The item-ids
can then be retrieved from the select-variable one by one each time the
READNEXT statement is executed:
16-80 This is Advanced Pick
The READNEXT statement obtains the next item-id from the list held in
STOCK.SV and puts this into STOCK.ID and once it is in there we can
use it to READ the item from the file, or in any way we wish. This is
illustrated in Figure 16.34. The ELSE clause on the READNEXT
statement is executed when the item-ids in the select-variable have been
exhausted.
In all cases, the SELECT statement presents ai/ the item-ids on the file in
the physical order in which they are held on the file. Using this technique
alone, you cannot sort the item-ids into any specific sequence, nor can
you impose any selection criteria to select, say, only those items which
are made of PINE. There is no SSELECT statement in Basic.
There are two ways round this problem. The first is to issue the Access
SELECT or SSELECT command at TCL before you execute the program:
:SSELECT STOCK WITH MATERIAL "PINE" BY STOCK.LEVEL
: RUN MBPROGS STOCK. REPORT
16.13.6 Locking
Pick has the facility to lock an item when it has been read from file.
This is a security feature preventing several users from attempting to
update the same item simultaneously. Locking is achieved by means of
modified forms of the READ / WRITE statements:
If you wish to rewrite an item but still keep it locked, then you will use the
forms:
WRITEU STOCK.ITEM ON STOCK.FV, STOCK.ID
MATWRITEU STOCK.ARRAY ON STOCK.FV, 1234
WRITEVU DATE ON STOCK.FV, 1234, 7
A attempts to read an item which user B has locked, then user A's
If user
program will beep and wait until user B releases the locked item. This
can be inconvenient, soa LOCKED clause has been added to the READ
statements, as illustrated by the fragment in Figure 16.36.
END ELSE
GosusB Missing
END
The FILE statement is new Advanced Pick facility which allows a Basic
a
Let us imagine that our STAFF file has the attribute definitions shown in
Figure 16.36 (a) and the data items shown in (b). The program and
output in Figure 16.36(c) illustrate some of the features of the FILE
statement.
The Basic language 16-83
(WEEKS]
HOLIDAYS A 3 HOLIDAYS R 5
[WEEKS]
CRT *
Employee name: STAFF (NAME)
CRT *
Start date: *
STAFF (START. DATE)
CRT *
Current entitlement: *
STAFF (HOLIDAYS) :
CRT *
New entitlement: ISTAFF (HOLIDAYS) :
CRT *
days = OCONV(STAFF (ENTITLEMENT) , "MD1'}: *
weeks'
CRT
WRITE STAFF ON STAFF.ID
REPEAT
Employee number?1
Employee name: SMITH
16-84 This is Advanced Pick
Employee number?4
Enter Employee:
Your Basic programs can handle data which is held on the backing
storage devices, that is, on magnetic tape and/or floppy diskette. As with
all Adva nced Pick backing storage files, the data will be read and written
as a sequence of fixed length records. The length of the records is the
block-size specified (or implied) on the T-ATT command.
Before attempting to use backing storage, the TCL SET- commands,
T-ATT, T-DET and other commands must be used to identify and select
the device externally to the program. These can be issued at TCL before
you execute the program, or they may EXECUTEd from within the
program.
Basic offers a range of facilities for handling backing storage directly by
means of statements such as:
READT variable THEN/ELSE ...
REWIND THEN/ELSE ...
WRITET variable THEN/ELSE ...
16-86 This is Advanced Pick
If a
program has been catalogued, it may be executed by the command:
program.name
DICT MBPROGS
SENTENCE01
Object program {b) Produced when the program
is compiled
-
Data MBPROGS -
SENTENCE01
{c) Created by the programmer
[s ource program
During the life of a program, the users will almost certainly require
changes to a program. All these changes will be made by returning to
step (1) and amending the source program.
Let's look more closely at these tasks.
program. The two verbs are effectively identical; the only difference is
that the BASIC verb is case-sensitive and distinguishes between
UPPER-CASE and lower-case, whilst COMPILE is case-insensitive and
does not distinguish between the two. Let's illustrate this:
print total+TOTAL
would be rejected by BASIC (because PRINT should be in upper-
case) but it would be accepted by COMPILE and would refer to a
single variable called total).
PRINT total+TOTAL
would be accepted by both BASIC and COMPILE, and would refer to
two distinct variables (total and TOTAL) by BASIC, but a single
variable (total) by COMPILE.
Beyond this case-sensitivity, the action and features of the BASIC and
COMPILE commands are identical. The format of the commands is:
BASIC file.name item.list {(options}
COMPILE file.name item.list {(options}
BASIC RU.PROGS
BASIC RU.PROGS *
either of these would compile all the programs held on the file
RU.PROGS.
SSELECT PROGS = "[AMEND]"
BASIC PROGS
select all programs which contain the word AMEND in their item-id
and then compile these programs.
Some of the options on the BASIC and COMPILE commands are shown
in Figure 16.39.
D to prevent the use of the D option on the RUN command to enter the
Basic debugger when the program is executed.
E to output the full text of any error lines as they are compiled.
L to produce a
listing of the source program as it is compiled.
indicating that the compilation was successful and that the object
program occupies 3 frames of disk space.
250 >
300 2 2 T FI Fa R e
350
:
Fe D P At P #&
400 < < F
450 ze R < Executing oe ].-Proceed? Y/N? 4qT:
500 ZY <
_
R ESENTENCE01°COUN:
550 +1*000000320000000000000000. .pATANANE 0000004600000;
600 200000000000. . DEFN*000000500000000000000000. .MSG1*°0:
650 :00000140000000000000000. .MSG2*0000001E000000000000:
700 0000. .MSG3*000000280000000000000000. FRESP*0000005A:
750 : 0000000000000000. .STOCK. DICT*0000000A0000000000000
800 #000. . ENTENCE*0000003C0000000000000000
850
There are two further TCL commands which are of interest here:
COMPILE-RUN file.name program.name
The Basic language 16-91
For example:
RUN SALES.PROGS ADD. RECORDS
RUN STOCK.BP ADD.STOCK (D
RUN RU.PROGS DELETE-RECORD (P
Figure 16.41 shows some of the RUN options which are available.
program as they were left by the last program which was executed on
that port.
ADD.STOCK (D
DELETE-RECORD (P
and this will overwrite any existing item called SENTENCE01 (unless it is
a file definition) on the MD.
and most 03 F
catalogued pointer, -
importantly -
the name of the file and 04 MBPROGS SENTENCE01
then our users would be able to execute the program by the RUN
command, as before, or they could simply type the name of the program:
SENTENCE01
and you can delete the object code and the catalogued pointer on the MD
by means of a command of the form:
DECATALOG MBPROGS SENTENCE01
16.16 Flash/Basic
O(n)
1 No optimisation.
2 Place the subroutines inline.
3 Optimise the C code using a minimum of memory.
4 Place subroutines inline and optimise the C code to produce the
fastest code (combining levels 2 and 3).
with the O option on the BASIC and COMPILE commands when using
Flash/Basic. Full details of Flash/Basic and of these options can be found
in EPick.
Ifa program has been flashed, that is, compiled with the O option, then
allthe external subroutines which that program calls must also have been
compiled in the same manner. However, if the program has not been
flashed, then it will use the slower Pick pseudo-object code versions of
any external subroutines which are called, even if flashed versions of the
subroutines are available.
16.17 Summary
verb; this reports any syntax errors in the program or produces the object
program. The object program is executed by the RUN command; this
invokes the run-time processor which interprets the Advanced Pick object
code into machine code.
17
Procs
SORT STOCK WITH TYPE "DESK" AND WITH PRICE > "50"
we might create either the macro or the Proc shown in Figure 17.1, and
either of these would do the trick.
DESK.50.M
SORT STOCK WITH TYPE " DESK" AND WITH PRICE > "BO"
(a) Macro
DESK.50. PQ
PO
HSORT STOCK WITH TYPE "DESK" AND WITH PRICE > "50"
(b) Proc
17-2 This is Advanced Pick
These items would be created on the MD, and whenever the user wished
to issue the Access sentence, he would type in the TCL command:
DESK.50.M
DESK. 50. PQ
to invoke the Proc, and the required sentence would be executed and the
report produced.
PO
IP?
A"
(a) Version 1
:PROC.T.P
(b)
Procs 17-3
PQ
A"2
A"3
(c) Version 2
But what if we wanted some means of letting the user type in just the
product type and the price which he wanted, perhaps producing the
sentence:
SORT STOCK WITH TYPE "DESK" AND WITH PRICE > "50"
SORT STOCK WITH TYPE "CHAIR" AND WITH PRICE > "100"
on another? Could we do this? The answer is YES, with a Proc like that
in Figure 17.2 (a). Obviously, this is slightly more complicated than the
Proc shown earlier, but it is much more powerful. When this Proc is
saved on the MD q saved it as item PROC.T.P), and invoked, the display
might look like that in Figure 17.2 (b), and this particular instance would
issue the Access sentence:
SORT STOCK WITH TYPE "TABLE" AND WITH PRICE > "80"
PROC.T.P.2 TABLE 80
and would pick up the data from this command without any further user
intervention. Obviously, we could write a Basic program to achieve the
same results, but a Proc is fairly quick and simple.
All your new Advanced Pick application systems will probably be written
using Basic programs, macros and menus, so there is no real need for
you to master Procs. But it is quite possible that you are working on a
system which has migrated from R83 Pick and which makes considerable
17-4 This is Advanced Pick
use of Procs. You may have to modify these Procs or even rewrite them
as macros and Basic programs. It is for such people that I include this
Chapter. shall not go very deeply into Procs, but shall show how to use
| |
PQ
HLIST STOCK WITH TYPE "DESK" AND WITH PRICE > "50"
P
PQ
HSORT STOCK WITH TYPE "DESK" "CHAIR" "SETTEE"
H BY PRICE
H BREAK-ON PRICE
" 'ure
H DESCRIPTION TOTAL VALUE
H HEADING "'C'* Price report for 'F' file *'LL'"
H LPTR
P
PQ
HSET-FLOPPY (AS
P
HT-REW
P
HT-DUMP STOCK
P
HT-REW
P
PQ
HRUN MYPROGS CALCOO1
P
PQ
HCOPY STOCK
STON
H(STOCK2
P
PQ
HSELECT STOCK WITH QUANTITY = "0"
STON
HCOPY STOCK<
H(STOCK2
P
HSLEEP 22:00
P
HSP-EDIT MUS
P
P
HSP-EDIT 11
STON
HS<
HY
P
Displaying a message
o
ODe you want to continue+
IP?
10 0
ODo you want to continue? Y/N+
IP?
IF A = ¥ GO 20
IF A = N GO 30
GO 10
10 0
OPlease enter the date as dd/mm/yy+
IP:
IF A (1NON/1NON/1NON) GO 20
IFA END XJOB TERMINATED
Go 10
10 0
oSend report to Screen or Printer? S/P+
IP?
IF A S GO 30
IF A P GO 20
Go 10
20 Add LPTR if required
H LPTR
Procs 17-7
30 C Not LPTR
PQ
C Build up part of Access sentence
H SORT STOCK WITH MDATE >=
C Get start date
10 0
OPlease enter the start date in the form dd/mm/yy+
IP:
IF A = END XJOB TERMINATED
IF A # (1NON/1NON/1NON) GO 10
C Enclose date in " and add to sentence
A"
C Add next part of Access sentence
H AND WITH MDATE <=
C Get end date
20 0
OPlease enter the end date in the form dd/mm/yy+
IP:
IF A = END XJOB TERMINATED
IF A # (1NON/1NON/1NON) GO 20
C Enclose date in ry
and add to sentence
A"
C Add any more bits to sentence
H BY PRICE DESCRIPTION BREAK-ON PRICE
C Get destination = Screen or Printer
30 0
OSend report to Screen or Printer? S/P+
IP?
IF A S GO 50
IF A = P Go 40
Go 30
40 C Add LPTR if required
H LPTR
50 C Process the sentence
P
PQ
HGET-LIST DESK.ITEMS
STON
HSELECT STOCK WITH PRICE <= "B0"<
HSAVE-LIST DESKS.LESS.THAN.50
P
PQ
HGET-LIST OLD. INVOICES
STON
HSELECT INVOICES WITH FLAG
HSAVE-LIST OLD. INVOICES
P
PQ
1c Get file name
IF A2 GO 2
The statements which are available in the Proc language are shown in
the Appendix. We shall look at some of these more closely in a moment.
Important features of any Proc are the buffers which hold the data being
processed. The organisation of the data within a Proc is illustrated in
Figure 17.3. Here, you see the two input buffers and the two output
buffers.
17-10 This is Advanced Pick
command
Keyboard
* / ss
SP / SS
O/T
Processing within the Proc Screen display
A/H
STOFF/STON
TCL processor
The TCL command which invoked the Proc is placed in the primary
input buffer, and the individual words there can be handled by using
references such as A1, A2 andso on. The IP statement can be used to
accept data from the keyboard and place this in the input buffer. Data
may be read into and picked up from either input buffer; the SP and SS
statements serve as a switch to denote which input buffer is currently
being used.
The O statement and the T statement are used to display text, messages
and other information on the screen.
The H statement is used to place specific text into the output buffer, and
the A statements can be used to move data from the input buffer to the
output buffer. The STON and STOFF statements serve as a switch to
denote which output buffer the data is to be sent to.
Many of the Proc statements are concerned with moving the data along
these paths.
For anyone new to Procs, the most confusing concept is that of the
buffers. As we have seen, there are two input buffers and two output
buffers. All these buffers are simply storage areas holding strings of data,
and it is convenient to think of these as strings of words or elements
separated by spaces.
At any one moment, only one input buffer and one output are active.
When you start to execute a Proc, the primary input buffer and the
primary output are the active buffers. There are four statements to make
each of the buffers active:
ss to set the secondary input buffer to be the active input buffer.
storF to set the primary output buffer to be the active output buffer.
In order to control the way in which the contents of the buffers are
handled, the Proc processor uses an indicator to point to a particular
element. This points to the current element in the active buffer. Some
Proc statements move this indicator, others do not. You can use a
statement such as:
$3
When you start to execute a Proc, the primary input buffer contains the
TCL command which you typed to invoke the Proc. Thus, if you invoked
a Proc called PROC.C.P by typing the TCL command:
then the primary input buffer would contain the four elements:
PROC.C.P
which is the current element of the input buffer; the secondary input
17-12 This is Advanced Pick
You can use the DO statement to display the entire contents of the active
input buffer, D to display the current element of the active input buffer, D4
to display the fourth element of the active input buffer, and so on.
If you need to ask the user for a piece of data as the Proc is executing, the
IP statement will accept data from the keyboard and place this directly
into the active input buffer, and the IS statement will accept data into the
secondary input buffer. In either case, the data will be entered at the
position indicated by the indicator for that buffer.
The P statement will process the command which has been constructed
in the primary output buffer. If this command requires further information
~ as does the COPY verb which asks you where the data is to be copied
to then the contents of the secondary output buffer (the stack) will be
-
17.4 P statements
Procs 17-13
command which have constructed in the output buffer. There are other
|
forms of the P statement which are of value in certain situations. They all
execute the command which has been constructed in the primary output
buffer, but they have additional facilities:
px is identical to theP statement except that any screen display produced
by the executing command is suppressed. This might be useful if you
were doing some action which produced output which might be
confusing or of no interest to your users or which you wanted to hide
from the users.
The statements D, DO, D1 and so on, will display the contents of the input
buffer, as we saw earlier, and you can mix these with O statements. So
the sequence:
17-14 This is Advanced Pick
OElement 1 contains +
D1+
O and 2 contains +
D2
might display:
the + sign, then this will hold the cursor so that the next displayed output
will begin at that position.
We have seen that the PP and the PW statements can be used to display
the contents of the output buffer just before they are processed. There
is no other way of looking at the contents of the output buffers.
There is a more powerful statement for displaying data on the screen: the
T statement. This has the general form:
T elementl,element2,element3, ... elementn
(x.y) to move the cursor to column x of line y of the screen and print
whatever follows starting in that position.
(-1) to clear the screen -
exactly like the C parameter.
(-2) to position the cursor at the top left corner of the screen (the
home position).
(-3) to clear the rest of the screen from the current cursor position.
(+4) to clear the rest of the current line from the current cursor
position.
The forms (x.y) and (-n) are equivalent to the e(x,y) and a(-n) functions
which are used with the Basic CRT and PRINT statements, which we met
in Chapter 16.
Procs 17-15
jumps to the statement carrying the numeric label 123. You might use
this to jump back to the beginning of a Proc and start again. There must
be a statement with the label 123 in this instance.
-
The IF statement is used to test for a certain condition and take some
course of action if the result is true. One form of the IF statement is:
IF A = value statement
for example:
IF A = YES GO 100
and this will test the current element of the input buffer (identified by A)
and if this is just the word YES, then the statement GO 100 will be
executed. If the current element is not YES, then no action will be taken
17-16 This is Advanced Pick
and the processing will continue with the statement following this IF
statement. Some other acceptable forms are:
IF A2 YES GO 10
will jump to statement 10 if the second element in the active input
buffer is the word YES.
IF A # X XEnd of job
will check the current element in the active input buffer and, if this is
the letter X, will display the message and terminate the Proc.
You can use other operators where these examples use the -
sign:
# not equal to
> greater than
less than
1 greater than or equal to
less than or equal to.
Other forms of the IF statement allow you to check that the data matches
a certain pattern:
IF A = (3A) GO 20
will jump to statement 20 if the data in Ais just 3 letters, such as ABC
and XYZ and AAA.
IF Al = (3A2N) GO 30
will jump to statement 30 if the data in A1 is just 3 letters followed by
2 digits: AAA11 or ABC92, but not AAAAA or 99999 or AAQ99.
IF A2 = (ON) GO 40
will jump to statement 40 if the data in A2 is only numeric digits (with
no letters or other characters).
IF A3 # (1NON) GO 60
will jump to statement 60 if the data in A3 does not consist of 1
numeric digit followed by any number of additional digits.
These are the same patterns that we saw when we looked at the P
processing code in Chapter 14, and the IF MATCHES statements in
Chapter 16.
Procs 17-17
17.7 Subroutines
Suppose that we were writing a Proc which needed to perform the same
processing say, clearing the screen and displaying a title from several
- -
FQ
GOSUB 100
GosUB 100
x
100 Clear the screen and display the title
T c,(0,15),"** The daily update run **"
The statement GOSUB 100 will jump to statement 100 (where we clear
the screen and display the title) and continue from there, and then the X
statement will take us back to the statement following the GOSUB 100
statement. By doing this, we only have to write the T statement once but
we can use it whenever we need to. We refer to a group of statements
such as this as a subroutine, or, because it is held within the Proc which
uses it, an internal subroutine.
[MYPROCS PART9]
which will pass control to the Proc PART9 which is held on the file
MYPROCS. When an X statement is encountered in PARTS, control will
be passed back to the original Proc. We refer to this process as calling
another Proc, and the second Proc is known as an external subroutine.
Figure 17.5 shows how we might reorganise the processing of Figure 17.4
to use an external subroutine.
PQ
[MYPROCS DISP.TITLE]
HRUN PROGS CALC01
[MYPROCS DISP.TITLE]
HRUN PROGS CALC42
(MYPROCS DISP.TITLE]
HRUN PROGS CALC999
PQ
this will pass control to the Proc FINAL.ROUTINE which is held on the file
MYPROCS, but control will not be passed back to the original Proc. We
refer to this process as chaining to another Proc.
In all cases, the same input/output buffers are used by and accessible to
all these Procs, so you don't have to concern yourself about passing data
to and fro as you jump from Proc to Proc.
The arithmetic capabilities of Procs are fairly restricted, allowing you only
to add or subtract integer constants to the current element in the active
input buffer. For example, the statement:
+2
will add 2 to the current element of the active input buffer, and:
-8
You may find it necessary to use the Sn statement to position the indicator
to the correct element.
The user-exit U01AD will allow you to read data from a file, and it is used
in a three-line sequence:
U01AD
where file.name, item.id and attribute specify the data which is to be read
from the file, and code specifies the action to be taken. The code will be
any one of:
A output to the non-active output buffer.
output to the primary input buffer.
output to the primary output buffer.
T display on the screen.
verify that the file exists.
va Verify that there is a value in the attribute.
The error handling statement specifies the action to be taken if the file
read statement does not execute successfully, that is, if the file does not
17-20 This is Advanced Pick
exist, if the item cannot be found or if the data attribute is null, according
to the code. If the statement executes successfully, then the error
handling statement will be skipped. Some examples are shown in Figure
176.
If any of the file name, the item-id, or the attribute number are to be
picked up from the input buffer, then references of the form %n can be
used to identify element n of the input buffer, as illustrated in Figure 17.6,
and #n to identify element n of the output buffer.
U01AD
STOCK 1000 1 T
(a)
PQ
1000 c
OEnter item-id+
Ip
OReading attribute 1: +
U01AD
STocK *1 1 T
(c) Output
User-exits U11AD and U21AD are also available file handling. Details of
these can be found in EPick.
17.10 Summary
The Proc language has facilities for constructing TCL commands, for
displaying messages on the screen, for accepting data from the user, for
moving and testing data, and for performing simple arithmetic and simple
file-read operations.
18
You will recall from the discussion of level pushing in Chapter 8 that
Advanced Pick allows you to ...
to indicate the level at which you are processing. You may then issue any
TCL command to initiate a second process at this lower level. The
second process may, in turn, be interrupted and a further operation
invoked. When each process has completed at the lower level, the
appropriate prompt:
will be displayed, and you may issue a further TCL command at this lower
level. The following special TCL responses are available at this point:
<Interrupt>
to denote the key which you press to interrupt a process. As we have
seen, this may be the <Break> key (if BRK-DEBUG is active), or it may be
<Break> followed by DEBUG (in the normal situation where the
BRK-LEVEL is active).
18.2 Fundamental responses
*I 123
showing that the Basic program was interrupted just as statement 123
was about to be executed. If any other process is interrupted, the system
debugger is invoked and displays something like:
The debugging software 18-3
I entrilnp: 095
to indicate that the debugger has been invoked during the execution of,
in this instance, a system routine identified by the name cntrinp.
In either case, the appropriate debugger will wait for you to enter a
command to indicate what you want to do. The two debuggers have
slightly different commands. For example, a programmer using the Basic
debugger might enter commands such as:
/VALUE
BS>100
and someone using the system debugger might enter commands such
as:
c999999, 66: 99
G<Return>
"J
these both have the same effect, instructing the system to continue
the processing, if possible.
END<Return>
END*J
to terminate the processing, leave the debugger and return to TCL or
to the logon procedure for the account.
OFF<Return>
OFF*J
to abandon all the processing and log off the account.
P<Return>
to switch the terminal display ON or OFF, that is, disable/enable the
display to the screen. The debugger messages are still displayed.
If your keyboard has been set up suitably, the <Line feed> key may be
used instead of the "J key. Used on its own, the <Return> key has no
effect, except to repeat the debugger prompt.
The above commands are available with both the system debugger (at
the prompt) and the Basic debugger (at the * prompt). If a user has
|
system privileges SYSO or SYS1, these are the only commands which
he/she can use. Users with SYS2 privileges may the other facilities and
commands described below.
18-4 This is Advanced Pick
Let's look at the debuggers a little more closely, starting with the Basic
debugger.
When you write a Basic program it may work the very first time you
attempt to execute it. There will be times, however, when things do not
go quite so smoothly: the program may not be producing the results
which you expect, it may be going into an indefinite loop, it may terminate
so quickly that you cannot see what happened. At such times you may
feel the need for some means of watching the progress through the
program, of slowing the program down, and of inspecting what values are
held in which variables. So common is this need that most computer
systems have a special piece of software a debugger which will help
- -
3) Fatal errors: these are logical errors which prevent your program
continuing (you have tried to store data in element 1000 of an array
with only 100 elements).
4) Non-fatal errors: these are logical errors which are reported as the
program executes, but from which the execution can recover (you
have added a value into TOTAL without first having set TOTAL to
a
zero).
Syntax errors must be cleared up before you can produce an executable
program, so the Basic debugger is mainly concerned with the detection
of logical errors, fatal errors and non-fatal errors.
at strategic points within the source code and then watch the program
The debugging software 18-5
No matter whether or not you use the Basic debugger, it is good practice
to design and construct your programs in such a way that it is relatively
easy to locate the source of any errors in the processing and hence to
correct the problem.
The Basic debugger may be used with standard Pick/Basic and also with
Flash/Basic.
18-6 This is Advanced Pick
There are several ways in which the Basic debugger might be invoked as
a Basic program is executing:
*140
*
showing that you are in the Basic debugger and the program has been
interrupted as it is about to execute the statement on line 40 of the source
program.
As we saw above, the commands:
END
OFF
P
Gor "J
Before we look at the ways of using the Basic debugger, there are two
entities which you must be aware of: the symbol table and the trace
table.
The symbol table is a map which is produced by the Basic compiler and
used by the Basic run-time processor, and which identifies the location of
each variable by name.
01 * Demonstration program
03 TITLE='HELLO'
04 PRINT TITLE
05 TEST=0
06 10 FOR X=1 TO 10
07 STORE (X)=X*X
08 PRINT X,STORE(X)
09 NEXT X
10 TEST=TEST+1
12 PRINT 'FINISHED'
13 END
000 h HELLO +
050 P D 2 +
100 * 2 UOP..
150 = FINISHEDP. .EWORK*STORE*:
200 :[email protected]*000000A00000000400:
250 :000005@ . TITLE*0000000A0000000000000000. . TEST*00000:
300 03100000000000. .X*0000001E0000000000000000 ._
350 :
Let us imagine that we have written a Basic program called TESTP. The
source program is shown in Figure 18.1 (a). If we dump the frame(s)
where the object program is held, we would see object code followed by
the symbol table, as in (b). The names of the variables STORE, STATS,
TITLE, TEST and X can be recognised in the symbol table. Following the
name of each variable, we see the relative memory location where that
variable is to be found and other information about the variable. When we
use the Basic debugger, we can ask that the contents of, say, the variable
TITLE be displayed; the Basic debugger will scan the symbol table for the
entry for TITLE and use the information to find the actual memory
address where the contents of TITLE are to be found.
that you cannot use any debugger commands which refer to variable
names.
The trace table is a list which is held and maintained by the Basic
debugger, and contains:
1) The names of up to six trace variables whose contents are to be
displayed each time the program execution is interrupted.
2) A set of up to four break conditions, the satisfaction of any one of
which will invoke an interruption in the processing.
to add two trace variables (as entries T1 and Figure 18.2: Trace table
T2 in Figure 18.2) and a B command:
BX)5
to add a break-point (as entry B1). Having done this, the contents of the
variables X and STORE(1) will be displayed whenever the program is
interrupted, and the break-point indicates that we want to interrupt the
program whenever the value of X is greater than 5.
As we shall see, there are other commands to remove such entries from
the trace table.
The debugging software 18-9
The BASIC and COMPILE verbs which compile your Basic program, and
the RUN verb which executes the program, offer a number of options
which allow you to make use of the Basic debugger when testing the
program.
The following options on the BASIC (and the COMPILE) command are
important if you intend to use the Basic debugger:
c to produce an object program without end-of-line characters; these
are markers in the object program which indicate the end of a physical
line in the source program. Suppressing the end-of-line characters
produces a smaller object program but any messages will refer to line
1. You should not use this option if you wish to use those facilities of
the Basic debugger which use line-numbers.
s tosuppress the production of the symbol table. You should not use
this option if you wish to use those facilities of the Basic debugger
which use variable names.
«to output a program map showing the names of the variables used,
the statement labels used, and the distribution of the program
statements across the frames occupied by the object code.
The Basic debugger can also be used with Flash/Basic.
Whenever you are testing a Basic program with or without the aid of the
-
Basic debugger you should always be sure that you are using the
-
correct version of the program and that the source program has not been
changed since you last compiled it. You can waste a lot of time if you are
looking at a printout of one version and executing another.
There are two run-time options which are important if you intend to use
the Basic debugger. These are specified on the RUN command:
RUN file.name program.name { (options)
or, if the program has been catalogued, on the command line which
invokes the program:
program.name {(options}
For example:
RUN SALES.PROGS ADD.RECORDS (D
ADD.RECORDS (D,E
you intercept the execution and call up the Basic debugger before you
start.
You cannot invoke the debugger when you call a particular subroutine.
You can, however, insert the DEBUG statement to interrupt the execution
at a specific point in a program or a subroutine.
Figure 18.3 shows some of the commands which are available for use
with the Basic debugger. Some of these are provided specifically for use
with Flash/Basic programs.
D HELP R
? DE I RETURN
$ DEBUG K s
DOWN L T
E LP UP
B EDIT N Z
c G P
Full details of the action and format of these commands can be found in
EPick.
Now let's see how you will use the more important features to debug your
programs.
if you wish to change the value held in SURNAME, then you should enter
the new value followed by <Return>. This new value will completely
replace the previous contents of SURNAME. if you press <Return>
without entering a new value, then the contents of SURNAME will be left
unchanged.
The debugging software 18-11
/STORE(7)
to display and allow you to change the contents of element 7 of the
dimensioned array STORE.
/STORE
to display -
one by one -
each element of the dimensioned array
STORE.
/STATS(2,3)
to display element (2,3) of the dimensioned array STATS.
/*
to display the names and contents of aif the variables (and all
elements of any dimensioned arrays) in the program. You will not be
allowed to change any of the displayed values.
If you attempt to inspect a variable which is not in the symbol table (or if
the program has been compiled without producing a symbol table), then
the debugger will display:
Ox
UNASGN VAR
TTITLE
18-12 This is Advanced Pick
to add the variable TITLE to the trace table, causing the contents of
TITLE to be displayed at each break-point and each interrupt.
TSTORE (7)
to add element 7 of the dimensioned array STORE to the trace table.
TSTORE
to add element 1 of the dimensioned array STORE to the trace table.
The names and contents of all variables in the trace table will be
displayed at each interrupt. You can remove entries from the trace table
by means of the U command:
UTITLE
USTORE (7)
USTORE
Use the D command if you want to see the contents of the trace table.
To follow the flow of your program, you must first invoke the Basic
debugger by any of the means discussed, and then use a command such
as:
El
"J
and the next statement will execute; repeated use of "J will proceed with
the execution statement by statement. if you want to inspect the source
program to see what the actual Basic statement is, you can use the:
15-17
to display lines 5 to 17 inclusive.
BS=17
to interrupt when statement 17 is about to be executed.
Bx>100
to interrupt when the variable X reaches a value greater than 100.
Each such break-condition is added to the trace table. You may have
up to four break-conditions in action at any.one time. Entries may be
removed from the table by means of the K command:
K$=17
KX>100
Use the D command if you want to see the contents of the trace table.
The system debugger is a very powerful tool, and in the wrong hands
-
functions are:
© As a tool for debugging processes written in the Pick Assembly
language,
© To inspect the contents of any frame of virtual memory,
© Tochange any part of any frame of virtual memory.
It is this last capability that poses a threat to the security and integrity of
the system, for, by inadvertently changing the wrong frame, you can
corrupt the standard processes and/or lose valuable data. The extended
features of the system debugger are only available to users with SYS2
privileges; only the commands END / OFF IP/G are available to other
users.
END
OFF
G
"J
P
If you invoke the system debugger accidentally, you can press the
G<Return> or the "J key to continue as if nothing had happened.
18.4.1 System debugger commands
Figure 18.4 shows the commands which are available for use with system
debugger.
D E M OFF TIME
A DB END MD P U
ADDD DIVD G ME R x
ADDX DIVX I MULD SUBD XTD
B DRS K MULX SUBX Y
c DTX L N T Z
Full details of the action and format of these commands can be found in
EPick.
The debugging software 18-15
We know that the DUMP command can be used to see what's held in any
particular frame. You can also use the system debugger to inspect the
contents of a frame, or just a part of a frame, or even just a single
character, and, more importantly, the system debugger will allow you to
change the contents of that part of the frame; the System Manager might
wish to do this as a last-ditch attempt to recover from a group format
error.
In order to instruct the system debugger which part of virtual memory you
are interested in, you will specify the appropriate address. All the
standard Advanced Pick routines have identifying addresses such as:
be.err.ptr
entrlnp
date. fmt
ed.ni.top
fm.delete.dptr
get.list
but you will have no reason to inspect these. You may however wish to
inspect the frames within one of your data files where, say, a group
format error has occurred. The C and X commands will let you inspect
a part of a frame of virutal memory. These have the form:
Caddrss;: window
Xaddress; window
There are other commands which will display parts of virtual memory, but
we shall not discuss these here.
On the C and X commands, the address of the data within virtual memory
is specified by means of two pieces of data:
fid.displacement
showing the frame identifier (the FID), and the displacement or offset
of the address from the start of the frame.
The FID is expressed in a form such as:
12345 to identify frame 12345,
12
Thus, to refer to the first byte (byte 0) of frame 12345 (decimal), the
complete address might be specified in any of the forms:
€12345,0
€12345.0
c.3039.0
c.3039,0
and to refer to the thirteenth byte, that is byte 12, of frame 12345
(decimal), the complete address might be specified in any of the forms:
C12345,12
C12345.c
¢.3039.¢c
C.3039,12
There are other features of the address specification, but we shall not
discuss these here.
The third piece of information the window indicates the number of
- -
or as a hexadecimal number:
A
Thus, the commands:
c98765,0;10
would display 10 bytes starting at the first byte of frame 98765. Note
that 0 is the displacement (or offset) of the first byte in the frame.
€12345,12;23
would display 23 bytes starting at byte 12 (the thirteenth byte) of frame
12345.
C61986,374; .58
to display the 88 bytes (88 decimal = 58 hexadecimal) starting at the
375th byte of frame 61986.
C33397.1AE;73
to display the 73 bytes start starting at the 431st byte (430 decimal =
1AE hexadecimal) of frame 33397.
The debugging software 18-17
C.3039.1AE; .58
to display the 88 bytes, starting at the byte 430 of frame 12345.
In each case the current data will be displayed and you would be able to:
The C and X commands of the system debugger are used to display the
contents of virtual memory, C presenting the data in character format, X
presenting the data as pairs of hexadecimal digits. As we have seen,
these have forms such as:
€1234,56;10
to display the contents of the 10 bytes starting at byte 56 of frame
1234 in character format. Non-graphic characters will be shown as
full stops.
X1234,56:10
to display the contents of the 10 bytes starting at byte 56 of frame
1234 in hexadecimal format.
In each case, the system debugger will display the current contents of the
specified window of the frame in the required format (character with the
C command or hexadecimal with the X command), and then invite you to
enter the new contents of that window. For example, if we issue any of
the above commands, the sequence might look like this:
1€12345,56;10 44-7FF°9CO=
1X12345,56;10 .34342D374646FE394330=
prompt, there are several possible courses of action: you may abandon
the process, look at a further window or change the data in the window.
You indicate your choice by one of the following commands:
<Return> to leave the data unchanged and return to the ! prompt.
to leave the data unchanged and display the next window.
18-18 This is Advanced Pick
In the following section, we look briefly at how we might change the data
in the window.
showing that the seven bytes starting at the 57th byte of frame 1234
currently contain the characters:
12..34A
"eceee<Return>
will replace the data in the window by the characters ccccc. The
apostrophe indicates that character data follows.
XXXXXXXX
will replace the data in the window by the hexadecimal string xxxxxxxx
-
there must be an even number of hexadecimal digits. The full stop
indicates that hexadecimal data follows.
specification.
In all these cases, the entire string of new data will be used to overwrite
the original data, irrespective of the size of the window. Thus, if you
specify a window of 10 but only enter five characters, then the last five
characters in the window will be unchanged, and if you specify a window
of 10 and enter 17 characters, then these will overwrite the 10 characters
of the window and the 7 characters beyond the window.
command at TCL.
3) When you get the ! prompt character, enter the display command in
the form:
cf,d:w
or:
Xf,d:w
If not, hit <Return> and try again from step (3), or go to step (7) and
abandon the task.
Don't press the <Return> key until you have checked the data.
The debugging software 18-21
6) When you are satisfied that you have typed the correct data, hit the
<Return> key.
The frame has now been changed.
9) DUMP a copy of the frame after you have made the changes and
confirm that the action has taken place successfully. If not, repeat the
process.
Remember that, as soon as you hit <Return> at step (6) the frame is
changed. There is no second chance.
18.5 Summary
Pick has two pieces of software for locating and fixing programming and
other errors: the Basic debugger and the system debugger. The Basic
debugger is used to report, locate and fix errors within Basic programs.
The system debugger is used with routines written in the Pick Assembly
language.
19
which uses the P option, or by executing a Basic program which uses the:
PRINTER ON
statement to print a report. If all the users were to ask for a report at the
same time, there could be problems Uwithout some means of resolving
the competition for the printer resources.
T Process
e [so x ureR
->
mn
Ju
i
n
a Job on queue
1
Hard disk
The spooler is a standard part of the Advanced Pick system and controls
the production and output of all the reports and other output which the
users send to the printer. Whenever you perform a task which produces
printed output, the spooler collects the output line by line and stores
- -
iton a temporary disk file until the process finishes. When the process is
complete your terminal is released and is free to perform other tasks. In
the meantime, the spooler takes care of the output, holding the various
reports in a queue until the printer is free and your report can be printed.
When the report has been output, the temporary disk file is deleted. This
19-2 This is Advanced Pick
As you can see from Figure 19.1, each user can think of his/her terminal
as being linked directly to the printer; as each printed report is requested,
it seems to go straight to the printer finally being printed when the report
-
process has finished and the printer is free. There is, however, a little
more going on behind the scenes. The diagram in Figure 19.2 shows the
logical linkage between the users and the printer(s) which are available
on the system.
#
User 3 Fqueue Printer 3
F
User 4 Fqueue # Printer 4
Between the users and the printers come the form-queues, the queues
of reports which are currently being processed by the spooler. On your
system, there may be just a single form-queue or there may be several.
If there are several printers available on your system, each printer will
normally be associated with its own form-queue and each user may
assign his/her output to any of these queues and thence to a particular
-
Printing : the spooler 19-3
printer.
Inspect it -
to check the results before printing.
Delete it -
the results may be wrong or it may be a test report.
Move it to another form-queue -
from where it will be output to
another printer.
Printing : the spooler 19-5
o Hold the report until you have had a chance to load and line-up the
stationery on to the printer you may want to print on cheques or
-
For these reasons, it is worth thinking about what the spooler can do for
you.
A number of verbs are provided for the System Manager to handle any
abnormal situations, and to report on the status of the spooler and the
printers, and to control the spooler:
>
p is the port number to which the printer is attached.
STARTPTR 1,2,0,93
to define the serial printer on port 3 as printer 1, associate it with form-
queue 2 and specify that no blank pages are to be skipped between
output reports.
STARTPTR 2,(0,1,3),1,P4,A
to define the parallel printer on port 4 as printer 2, associate it with
form-queues 0, 1 and 3, specify that a single blank page is to be
skipped between output reports, and request the alignment process
at the start of each output report.
STARTPTR 3,0,,.A
to reset the printer 3 for form-queue 0 and specify forms alignment.
STARTPTR 4
to restart printer 4 which has been stopped by STOPPTR command
a
those for printing the various fonts and faces are set up by the
-
Printing : the spooler 19-7
:LISTPTR
PAGE DEV OR
PARALLEL 0 0 0 INACTIVE
SERIAL 1 2 0 3 INACTIVE
:SP-STATUS
: LISTABS
TES #
1 0
1 HS 1 0
2 2 1
3 HST 1 2
0 0
5 $s 0 0
LISTPTR and SP-STATUS are available to all users and will display
details of the printers which are available and the form-queue(s) with
which each is associated, as illustrated in Figure 19.3. The SP-STATUS
output is also included in the WHERE report.
STOPPTR will be used by the System Manager to stop any of the printers
and withdraw them from the system.
19-8 This is Advanced Pick
LISTABS is available to all users and will display the spooler assignments
of all users, as illustrated in Figure 19.3.
19.4 SP-ASSIGN
to be printe
on form-queue 0;
as soon as this is free.
These pieces of information are known as your spooler assignments.
Anyone who wishes to exploit the facilities offered by the spooler must
assign the appropriate spooler assignments. This is done by means of
the SP-ASSIGN command.
The general form of the command is:
SP-ASSIGN {options}
SP-ASSIGN 3
send three copies of all subsequent output to form-queue number 0
(the default form-queue).
SP-ASSIGN F2 3
send three copies of all subsequent output to form-queue number 2.
SP-ASSIGN F2 3 ?
this is identical to the previous command, except that the new spooler
assignments will be displayed.
SP-ASSIGN S
suppress the output (the despooling) of all reports as they are
completed. Since there is no H option to ho/d the reports, they will
simply pass through the spooler without any output being produced or
-held. This is an unusual situation which might be used when testing
a process without any concern for the output produced. Since no
form-queue specification is included, the default (form-queue 0) will
be used.
SP-ASSIGN H
send a single copy of the report to form-queue 0, and the report will
be printed (because no S option is specified) and then held on the
form-queue for further processing. See the SP-EDIT command
below.
SP-ASSIGN H 5
print five copies of the report on form-queue 0, and the report will then
be held on the form-queue for further processing.
SP-ASSIGN HS
SP-ASSIGN H S
SP-ASSIGN S H
These forms are equivalent and request that all output be he/d on the
form-queue until you release it with the SP-EDIT verb. The S option
will suppress the printing of any copies of the report.
SP-ASSIGN R3 F2
assign the output from the Basic PRINT ON 3 statement (and the
output from the RUNOFF PFILE 3 command) to form queue number
2.
1 attach the printer to the user's process and print the report
immediately without spooling to disk. See also the C option.
o leave files open so that all subsequent reports will be output
together as a single report. This is equivalent to the SP-OPEN
command.
1 output to backing storage diskette/tape. The output may be
recovered by means of the SP-TAPEOUT command.
Each SP-ASSIGN command -
except SP-ASSIGN ? -
cancels any
previous spooler assignments.
19.5 SP-KILL
Itmay happen that you have sent a job to be printed and then changed
your mind. The command:
SP-KILL
will cancel the job which is currently printing by terminating any further
output to the printer for that job, and when the printer buffer is empty, the
report will terminate with the message:
ABORT!
SP-KILL N
terminate the current report, as above, but suppress the ABORT
message.
SP-KILL 'DM'
stop all spooler reports produced by user-id DM.
SP-KILL 2
terminate the report which is being output on printer number 2.
Printing : the spooler 19-11
SP-KILL F3
convert report number 3 (that is, spooler entry number 3) to hold
status. As each job is submitted to the spooler, the entry number is
displayed. The LISTPEQS report also shows the report numbers, as
in Figure 19.5.
SP-KILL F3-6
convert reports number 3, 4, § and 6 to hold status.
SP-KILL F40
convert report number 4 which is currently in the queue awaiting
-
SP-KILL F3-60
convert reports 3, 4, 5 and 6 -
which are currently in the queue
awaiting output to hold status.
-
19.6 LISTPEQS .
In order to find out what jobs are currently being processed by the
spooler, any user may issue the:
LISTPEQS
closed
hold file; this job is (or was) a hold file
immediate print (not being spooled)
Pe
locked
19-12 This is Advanced Pick
not closed
currently being output to the printer
waiting for printer
resubmitted for output
s spooled
output to tape
x killed.
19.7 SP-EDIT
command. This allows you to inspect a held report, release it for output,
transfer it to a normal Advanced Pick file, and/or delete it. A large
number of options are available. Most frequently used are:
to edit report number n. The report numbers can be read off
the LISTPEQS display in Figure 19.5.
to edit reports n to m.
L to look at -
but not manipulate -
a report which is being output.
SP-EDIT
edit all held reports sent to the spooler by your user-id.
SP-EDIT 5
edit report number 5.
SP-EDIT 3-7
edit reports 3 to 7 inclusive.
SP-EDIT 5 T
send report number 5 to diskette/tape.
SP-EDIT 9 D
delete report number 9.
SP-EDIT 'DM'
edit all held reports sent by user-id DM.
SP-EDIT MS
SP-EDIT DM
SP-EDIT MD
SP-EDIT MUD
delete all reports currently held by the spooler. The U option applies
the deletion to all users' reports.
SP-EDIT MUS
1 DISPLAY?
Y to display the first 500 bytes of the report. If you wish to view
more of the report, you can do so at step (3).
N to pass to step (2).
s to pass to step (3).
D to pass to step (4).
x to abandon the action.
2 STRING
This allows to you to start printing at a specific point in the report, as you
may want to do if the printer had run out of paper and you need to reprint
just the last part of the report.
At this point, you may enter either of:
<Return> pass to step (3), or
xxxxxax Search for the string xxxxxxx and start printing at that point.
Be sure to enter a suitably unique identifying string. If your report has
page numbers, you may be able to enter a string such as:
Page 34
Remember that spaces are significant and the string should be entered
exactly as it appears in the report.
3 SPOOL?
If you enter F to save the output on a regular file, you will be asked to
enter the name of the file:
FILE NAME?
You should enter the appropriate information and the report will be
transferred in RUNOFF format to the specified file. For example, if you
entered:
FILE NAME? REPORT94
INITIAL ITEM NAME? FRIDAY
the first page will be saved as item FRIDAY on the file REPORT94, the
second page as item FRIDAY0001 the third page as item FRIDAY0002,
and so on. The full report may be output when required by means of a
TCL command such as:
RUNOFF REPORT94 FRIDAY
4 DELETE?
Any other response will pass to the remaining report(s) specified on the
SP-EDIT command, if there are any.
19.8 AP/Unix and the spooler
The features described above apply to all Advanced Pick systems, but
AP/Unix systems are able to interface more closely with the Unix and the
Unix spooler. To exploit this feature, the AP application still directs its
19-16 This is Advanced Pick
19.9 Summary
The spooler is a standard part of the R83 Pick and Advanced Pick
software which handles all reports sent to the printer(s). The spooler
collects output destined for a printer and holds it on a disk file queue until
the job is complete; the job is then released when the appropriate printer
becomes free, or it may be held indefinitely for you to inspect / release /
delete the report.
Backing storage 20-1
20
Backing storage
In addition to the hard disk, your Advanced Pick system will have one or
more magnetic storage devices such as:
The chief use of these devices is in making backup copies of the contents
of the hard disk, using the file-save and account-save features. They are
also used in the archiving of data such as last year's invoices which
- -
are no longer required on the live system, and to transfer data between
one Pick system and another.
When you are using these devices on Advanced Pick releases before 6.1,
itis important to remember that there is only a single-user interface for
handling backing storage this means that only one user may handle
-
backing storage at any one time, and that user can use only one device
at a time. On later releases, the multiuser interface allows a user to
attach two or more devices, and allows two or more users to handfe the
various devices simultaneously.
20.1 Concepts
Advanced Pick regards each volume ~ be it a floppy diskette, a cartridge
tape or a reel of magnetic tape as a sequence of records, as illustrated
-
in Figure 20.1. For a diskette, these records are 500 bytes in size; fora
magnetic tape, their size is set by the T-ATT command.
first record is at the read/write head, as in Figure 20.1 (a). As each record
is read (or written), the volume is positioned at each record in turn, as
20-2 This is Advanced Pick
illustrated in diagram Figure 20.1 (b) where we see the position of the
read/write head after the first record has been read. Figure 20.1 (b)
reminds us that if we are using a floppy diskette and we now remove the
-
diskette and insert a new one the reading/writing of the new diskette will
-
R R R R R
1 2 3 4 5 6 7
- read/write head
R R R R R R
1 2 3 4 5 6 7
- read/write head
or EOF. Most Advanced Pick Figure 20.2: Labels & EOF markers
There are great many TCL commands for handling backing storage
devices, and the same commands are used no matter whether you are
using floppy diskette or magnetic tape. All the commands are of the
form T-0x« and SET-xxx.
If your system has more than one backing storage device, you will first
use one of the SET- commands to indicate which device you wish to use:
SET-8MM
sets the 8mm tape drive as the current backing storage device.
SET-DEVICE
specifies the current backing storage device which is to be used, as
we see below.
SET-FLOPPY
sets the floppy diskette drive as the current backing storage device, as
we see below.
SET-HALF
sets the 0.5" tape drive as the current backing storage device.
SET-SCT
sets the streamer cartridge drive as the current backing storage
device, as we see below.
SET-SCT-DMA
sets the DMA (Direct Memory Access) channel for the streaming
cartridge tape unit.
SET-TAPE-TYPE
specifies the type of half-inch tape drive which is being used.
EPick gives more details of these. Let's look at some of these more
closely.
20.2.1 SET-FLOPPY
To use a floppy diskette, you will issue the:
SET-FLOPPY ({d}{r}
SET-FLOPPY (HB
20-4 This is Advanced Pick
indicates that you are going to use drive B and that the recording density
is to be high. If you only have one diskette drive, then forms such as:
SET-FLOPPY (H
20.2.2 SET-SCT
To use a streamer cartridge tape, you will issue the:
20.2.3 SET-DEVICE
Keywords Options
Having indicated which device you are going to use, you may then need
to attach the device to your processing and/or specify the block size; say
|
may because some forms of the SET command attach the device for you.
This is done by means of the:
T-ATT
verb. If another user already has the device attached to their processing,
then the system will respond with a message such as:
TAPE ATTACHED TO LINE
when you issue a SET- or T-ATT command and you will not be able to
use the device. The U option may be specified if you wish to stea/, the
device from another user by using the U option:
T-ATT (U
When you have finished using the device, you should detach it from your
processing by means of the command:
T-DET
The full range of commands used with the diskette/tape devices includes:
T-ACT {device.number}
make a particular device the active device. On AP 6.1 and later, itis
possible for a user to select and handle more than one backing
storage device at one time. This command implies that all
subsequent T- commands will manipulate this active device.
T-BCK {r}
T-BSR {r}
move the diskette/tape back a specific number of records. Here, as
in other commands shown below, T-BCK is offered for compatibility
with earlier releases, whilst T-BSR is a more memorable form
consistent with the T-BSF command.
T-BSF {files}
move the diskette/tape backwards a specified number of files.
T-CHK
read a file on diskette/tape to check for and report any parity errors.
T-DET
T-DET {device. number}
detach the current diskette/lape and make the backing storage device
available to other users. On AP 6.1 and later, it is possible for a user
to handle more than one backing storage device at one time; in this
case, the T-DET specifies the number of the device to be detached,
if this is omitted, all devices currently attached to the user will be
detached.
T-EOD
move the current volume to the end-of-data marker.
T-ERASE
erase the data on a tape. This is achieved by writing a empty block
which is recognised as the end of data.
T-FSF {f}
Backing storage 20-7
T-FSR {r}
T-FWD{r}
move the diskette/tape forwards a specified number of records.
T-RDLBL
read the label on the current diskette/tape.
T-READ
read and displays records from the current diskette/tape.
T-RET
T-RETEN
retension a cartridge tape by winding and rewinding several times.
T-REW
rewind the current diskette/tape, positioning it at the load point.
T-SELECT
attach a disketteflape. This is the fundamental command used by the
SET-FLOPPY, SET-SCT and SET-HALF commands.
T-SPACE {f}
move the diskette/tape forward, skipping over a specific number of
files,
T-STAT
T-STATUS
display the current status of all backing storage devices.
T-UNLD
T-UNLOAD
rewind the diskette/tape and then unload the volume, making it
inaccessible for further processing.
T-VERIFY
read and verify the contents of a file-save or account-save volume.
T-WEOF
write an end-of-file marker on the diskette/tape. The standard
20-8 This is Advanced Pick
processes write EOFs with their files; the Basic WEOF statement can
be used to write an EOF from a program.
T-WTLBL (xxxx}
write a label with optional text on the diskette/tape. The standard
processes write labels with their files.
:SET-FLOPPY (AH
:T-REW
196] Bot|
1 4500
2 1234
3 5555
4 8000
5 8765
5 ITEMS DUMPED.
:T-REW
(96) BoT
T-DET
There are several facilities which allow Access to handle data held on
backing storage devices.
20.5.1 T-DUMP
The T-DUMP verb will allow you to copy all or selected items from a
regular AP file to the backing storage device. This is often used to archive
the contents of a single file or even a single item and is an alternative
- -
'T-DUMP STOCK
T-DUMP STOCK WITH TYPE "DESK"
T-DUMP STOCK WITH AGE > "300"
T-DUMP STOCK '1000' *2000° *3000°
T-DUMP STOCK 1000 2000 3000
T-DUMP STOCK > '1000°
T-DUMP STOCK BY DESCRIPTION
and so on. The equivalent S-DUMP verb will sort the items into sequence
as they are dumped:
S=-DUMP STOCK
S-DUMP STOCK WITH DATE < "1/1/95" BY DATE BY PRICE
S-DUMP INVOICES = "[95"
20.5.2 T-LOAD
The T-LOAD verb can be used to read a T-DUMP file and load the
contents back on to a file on the hard disk:
T-LOAD STOCK
T-LOAD STOCK (0
to load the entire file, or to find and load only selected items:
The O option will cause any existing items on the disk file to be overwritten
20-10 This is Advanced Pick
Figure 20.5 illustrates the action of the T-READ command and shows
how a T-DUMPed file, its labels and EOFs are held on diskette.
Backing storage 20-11
will produce an Access report using the DICT of the STOCK file to find
the datanames DESCRIPTION and VALUE, but using the data on the
diskette/tape, as illustrated in Figure 20.5. This assumes that the
diskette/tape is positioned at the start of the appropriate T-DUMP file.
20.6 Summary
Advanced Pick will support floppy diskette and magnetic tape devices;
these are known as backing storage devices. Only one user may use the
backing storage at any one time, and only one device may be used at any
one time. The data on these devices is regarded as a sequence of fixed-
length magnetic records, and a range of TCL commands, Access verbs
and Basic statements are available to manipulate / read / write the data
on the devices.
Operations: Saving & restoring data 21-1
21
The actual title of the person (or persons) responsible for these tasks
depends upon the organisation. In this book, use the term System
|
Manager.
Here and in the following Chapter, we shall look at the more important
duties of the System Manager. Let's start by looking at the file-save and
file-restore operations.
21-2 This is Advanced Pick
Selective-restore from
account-save or file-save
An item T-DUMP file item T-LOAD file from T-DUMP
oz items
T-DUMP file ii i2 Selective-restore from
account-save or file-save
21.1.1 File-save
frequently.
The file-save process starts by looking at the MDS file at the head of the
file system, as we saw in Chapter 4, and traverses the tree structure
looking at each file on the system, saving the details of each file such -
as the modulo and the lock-codes and the contents of each file on
-
in a moment.
21.1.2 FILE-SAVE
FILE-SAVE
size and number of items on the files and saves these on the FILE-
-
OF-FILES file. If you want to print a copy of these statistics at the end
of the process, enter Y.
The file-save will then start as instructed. If the file-save requires more
than one diskette or more than one tape, then you must change the
volumes as and when instructed.
21.1.3 Account-save
ACCOUNT-SAVE
Enter any text which will be used to create a magnetic label to identify
the diskette or tape later.
2) Account name
will save just the accounts WAGES, PAYROLL, PAY-STATS together with
the DM account and the MDS file, and:
If we consider the file structure shown in Figure 21.2 during a normal file-
save, the file-save process will display a report like that in Figure 21.3,
and the file-save tape will contain these items in the following sequence:
MDS
FIA
1 MDS
1 339 MDS > FIA 1
1 340 MDS > FIA > F2A |
F1A account-save
21-6 This is Advanced Pick
An account-save tape would contain just items (2) to (15) for the
account. During a file-save, the display might be like that in Figure 21.3.
A typical line of the file-save / account-save display:
1 344 MDS > FIA > F2C > F3B
When going to a lower level, the D-pointers are chosen in their physical
sequence; thus, if the D-pointer for F3C was physically before that for
F3B on the DICT F2C, then F3C would be dumped before F3B.
This is a good place to remind ourselves about the DX-pointers and DY-
pointers which can be used to define a file. These control the way in
which the file and/or its contents are saved (or not saved) during a file-
save or an account-save operation:
© Ifthe D-pointer for a file section includes an X in attribute 1:
Dx
DLX
DPX
psx
and so on, then that file section will be ignored completely during a
file-save or account-save. If the account is subsequently restored
from that save diskette/tape, then the file will no longer exist.
© Ifthe D-pointer includes Y in attribute 1, then the file section itself will
a
from the save diskette/tape, then the file will be restored, but it will be
empty.
MDS file
Look at Figure 21.4. Any of the D-pointers at
D-pointer (a)
(a), (b) or (c) may be a simple D-pointer, a
DX-pointer, or DY-pointer:
a
ADY-pointer on the MD will retain the DICT section of the file but it will
be empty (except for any D-pointers); any data sections and their
contents will be saved in the normal manner.
A DX-pointer on the DICT section of the file will ignore that data
section of the file.
A DY-pointer on the DICT section of the file will retain that data section
but it will be empty.
DM
file-of-files
file-of-files < file pointer is DX'ed
ts.log
test < file pointer is Dx'ted
ts.log < file pointer is DX'ed
21-8 This is Advanced Pick
Every item holds a flag indicating whether it has been created, changed
and/or deleted since the last file-save. The incremental file-save allows
you to save only such flagged items and is performed by issuing the:
FILE-SAVE
and much more. It is essential that the System Manager is familiar with
this file and able to use it to produce reports showing the state of the file
system.
SAVE (FS
to produce the file statistics for the entire system, or
SAVE (FSI
to produce the file statistics for an individual account.
LIST-FILE-STATS
LFS
LIST-FILE-STATS (P
LFS (P
and you can produce the file statistics for a single account by a sequence
such as:
R83 Pick users will recognise that the FILE-OF-FILES has many of the
characteristics and applications of the STAT-FILE. The file has synonyms
FF, FILES, FOF, and STAT-FILE.
21.3 The SAVE verb
SAVE (options
Some of the available options are shown in Figure 21.7. There are other
options for logging and reporting group format errors, for saving a
specified list of items on each file, and for clearing the dirty bits. EPick
will give full details, and it would reward the System Manager to look
more closely at the SAVE options which are available.
save all B-tree indexes. This avoids having to regenerate the indexes
after a restore.
display a list of the names of the files as they are processed. If this
option is omitted, only the account names are displayed.
Operations: Saving & restoring data 21-11
save the data on the diskette/tape. This option will be omitted if, for
example, you simply want to produce the current file statistics by
using the S option.
x save any files which are defined with DX-pointers, overriding the
normal effect of DX-pointers.
save any files which are defined with DY-pointers, overriding the
normal effect of DY-pointers.
:T-REW
:SEL-RESTORE MD *
-
will be reported. If there are any errors, the save operation should be
repeated.
21.5.1 File-restore
Having carried out a file-save and dumped a copy of the entire system
and its files to diskette/tape, it is possible to recover the entire system
from this copy. This process is known as a full-restore or a file-restore.
As a file-restore takes place, the accounts and their files are restored in
the sequence they are held on the file-save diskette/tlape, and they are
loaded sequentially on the system disk. When the file-restore is
complete, the unused disk space will be available as a large block of
contiguous frames.
Hard disk
ABS system frames A1/A2 A3
A4 B1 B21B3IA5IA61B4IA71B5 B6 B7
Operations: Saving & restoring data 21-13
225) 2) D1 103
] 8) ea ae [oe ees
File-save
Backing storage
Al
File-restore
Hard disk
This is illustrated in Figure 21.9 where we see how, before the file-save,
the frames which belong to file A (numbered A1, A2, A3 and so on) are
scattered about the disk, as are those for files B, and D. There are also
C
a number of unused (shaded) frames scattered about the disk; these are
a consequence of some files and items having grown, and others having
been deleted. When the file-save is performed, all the data for each file
is dumped contiguously on backing storage, where we see all the frames
for file A held together. When the file-restore is performed, each file is
then restored to a contiguous set of frames on the hard disk. Note that
the ABS system frames are not dumped to backing storage when file- a
Having completed the file-restore, the process will ask whether you want
to restore further items from an incremental file-save and/or from a
transaction log tape. When these have been done, the system is ready
for use once more.
21.5.2 Account-restore
A file-save tape, or
21-14 This is Advanced Pick
© An account-save tape, or
© Amutliple account-save tape.
In most cases, accounts will be restored because they were deleted from
the system previously; for example, you may have deleted the
DEVELOPMENT account and now wish to restore it back to the system
with the same name. It is, however, perfectly feasible to restore an
account which already exists on the system; for example, you may have
the WAGES account on the system and wish to restore an earlier
account-save of the WAGES account, giving the new version the name
ORIGWAGES, in order to compare the two or recover various pieces of
data from the old copy.
that is, the name by which the account can be identified on the file-save
/ account-save file. If you wish to recover the account with the same
name as it was saved on backing storage, then you may just hit <Return>
here. In our examples, the responses at this point would be
DEVELOPMENT (or null) and WAGES, respectively. The account and
all its files would then be restored back to disk, using up the available
frames as required.
Figure 21.10 shows how the system might look after we had performed
an account-restore from a file-save tape. In this illustration, we restore
account X from account C on the file-save tape. We could not use the
original name C because account C already exists on the system.
- -
Hard disk
ABS system frames 11 A2 A3 before
14 A5 BBIB7IBBIBIIBZIBSIB4IBSIBGIB7
Operations: Saving & restoring data 21-15
Backing storage
Al
Account-rastore
Hard disk
afterwards
21.5.3 RESTORE-ACCOUNTS
where file.name is the file on the system in which items will be placed (this
file must exist on the system, although it need not necessarily be the
same file name as that on which the items are held on the diskette/tape)
and item.list is either the list of items to be restored, or null if you want to
restore all the items saved for that file or if a select-list of item-ids is
available. The available options are shown in Figure 21.11.
account.
makes every item before the next end-of-file a candidate for restore.
This ensures data can be restored even if a D-pointer is damaged on
the diskette/tape.
The SEL-RESTORE process first needs to know the format of the tape
from which the data is being restored:
Restore from F)ull/account, I)ncremental, T)ransaction log
to which you should reply with the name of the account with which the file
was saved; if you specified option A or option N, the process will not ask
for the account name.
The next prompt will be one of the following, depending upon whether the
N option was used on the SEL-RESTORE command:
tere¢ to restore the items from the data section of the file fffff.
pict fffft
to restore the items from the DICT section of the file fff.
fffff sssss
to restore the items from data section sssss of file fff.
The process will display the names of all the accounts and the files which
it encounters as it searches the diskette/tape for the required file.
When that phase is complete and the item(s) have been restored, the
process will ask whether you want to:
Restore from incremental save tape (y/n)?
and:
Restore from transaction log tape (y/n)?
allowing you to apply any later amendments to the items. If you had any
such saves available, you would mount the appropriate diskette/tape and
answer Y to these prompts.
Finally, a
message of the form:
(992] n item(s) have been restored
or, if the end-of-file marker is found and the appropriate account or file or
items have not been found, then the message will be:
(992] 0 item(s) have been restored
c) reads a transaction log save tape to restore all the items from file
number 334 and place these on the DICT of the INVOICES file,
overwriting any existing items.
;'OSSCéiésS
L RESTORE PAY~RATES (0
21-18 This is Advanced Pick
Transaction logging may be switched on/off and the scope of the logging
can be all files or only those files which have DL as the first attribute of
their D-pointer. The system will send the log records directly to backing
storage or hold them on a disk file until the backing storage device is
available.
TXLOG
LOG-STATUS.
to display the status of the transaction logging system.
Operations: Saving & restoring data 21-19
STOPLOG
to terminate the transaction logging system and detach the backing
storage device. Any subsequent log records will be written to a disk
file. When the transaction logging system is restarted, these updates
will be written to the transaction log tape.
TLOG-RESTORE
to restore all the transaction log records from backing storage. The
log records may also be restored optionally after a file-restore /
account-restore / selective restore has been performed.
TXLOG-STATUS
to display the status of the transaction logging system.
UPDATE-LOGGING
to enable / disable / report the status of the transaction logging
system.
One of the System Manager's responsibilities is to ensure that all files are
as efficient as possible in terms of the space they occupy and the speed
with which items are read from the files. Both these factors are affected
by the modulo of the file. The modulo of a file is established when the
file is created and can only be changed when the file is restored to the
system during a file-restore or an account-restore.
(123)
21.7.1 F-RESIZE
modulo. This new modulo is then set in the reallocation field of the D-
pointer for the appropriate file, and will be applied when that file is next
saved at a file-save / account-save and restored to the system at a file-
restore / account-restore. At the moment, there seems to be no way of
restricting the scope of this resizing action.
The F-RESIZE process can be invoked directly from TCL, or via the
standard menus ADMIN or ADMIN.FILES.
21.7.2 RESIZE
original base FID and the FID of the new block. The before and after
appearance of the D-pointer is shown in Figure 21.13. The two blocks of
frames will be consolidated when the next save-restore is performed.
STOCK
STOCK
01
02 12345 12345)34011
03 11 21
04
05
06
07
08
09L
10 10 10
(a) (b)
Itis also possible to change the size of a file more quickly and directly by:
© T-DUMPing the DICT section and the data section(s) to diskette/tape.
© Deleting the original file.
© Recreating the file with the required size for the DICT section and/or
data section(s).
© T-LOADing the contents of all sections of the file back from the
diskette/tape to the newly-created file.
Of course, this should not be done if other users and their application
programs are handling the file at the same time.
21.8 Summary
of the disk space which they occupy and the speed with which their items
can be read and written.
Operations: System administration 22-1
22
data and recover data from these copies. In this Chapter, we look at
some of the other less frequent duties which the System Manager
- -
We shall not discuss the physical process of loading and installing the
Advanced Pick system, nor shall we consider that of starting up the
system; those tasks are described in the literature which accompanies
your new AP system.
There are several points for the System Manager to note about the
initialisation processes which can be performed during the day-to-day use
of the system:
This is a good place to initialise the printers and carry out any other
setup processes. Have a look at SYSTEM-COLDSTART on your
system to see what it does. You may care to add to and/or to remove
some of the processes which are included in the basis coldstart
procedure; on my systems, remove (by inserting COMMENT at the
|
2) When a user logs on, the commands in the MACRO in his/her user
definition on the USERS file are invoked.
We shall discuss many of these topics in this and the following Chapters.
In order to use Advanced Pick, each user must provide two pieces of
information:
When you install a new Advanced Pick system, a number of users are
supplied:
DM
SYSPROG
QA
PA
TUTOR
a Whenever this user logs on, the date, time and usage statistics will
be logged on the ACCOUNTS file.
be thrown into the logon procedure if he/she types END from the
debugger; this can be used to prevent the user from reaching TCL.
macro This is a sequence of TCL commands which are to be executed
whenever that user logs on. When a new user is created, the macro
includes the commands:
TERM-TYPE
SP-ASSIGN
BRK-LEVEL
ESC-DATA
SET-SYM GSYM
SPELLER-OFF
CREATE-ACCOUNT account.name
ADMIN which describes the work done on that account. The update
process will then display the screen shown in Figure 22.2. The standard
<Ctrl> keys are used to maintain account definitions. Remember that you
may enter ? at any point for an explanation of the meaning of that field.
in all cases, the familiar <Ctri> keys are used to maintain the account
definition.
LISTFILES MDS
LISTFILES MDS (P
command. The process will produce a list of the files owned by the
account and then ask you to confirm that the account and all its files are
to be deleted.
You can maintain accounts and the MDS file via the standard menus
ADMIN or ADMIN.MAINT.
and have the format shown in Figure 22.3 (a). Alternatively, they may be
created by means of the CREATE-ACCOUNT command, as follows:
CREATE-ACCOUNT synonym.name
Basic Locks
0 1 2 5 6 7 8 9 A c D
0 #48 FFF HEF att 611 att att att ## ane Fit att ane #44 ant ott
1 #80 HEE OHH att ant att ant att ant ae ## cat Ht ant ant
2 #88 HOE HE ant ant ate a44 ant ate fut aun tat
3 111 HEE HOH att ots #t# HH HER a 111 oat ant
Spooler Locks
mq iq fq peq
22-8 This is Advanced Pick
'uu' to include the WHERE report only for users logged on to user-id wu.
to include the WHERE report for all lines, whether they are in use or
not.
There are several commands for monitoring disk usage and the
fragmentation of the available disk space. As Figure 22.4 illustrates, part
of the WHAT report shows the total number of frames of disk storage
which are unused.
-
it may be that there is no single block of frames sufficiently large to
enable you to create a new file. In such circumstances, it may be
necessary to perform a file-save and file-restore to consolidate the disk
space.
(a) OVERFLOW
(b) OVERFLOW (A
3 2 5 6 1 7 1 1042 3
6 3 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 6 1 428 1 2 6679
(c) OVERFLOW (8
Disk Available
0 1 2 3 4 5 6 7 8 9 100%
EERE
Bytes Frames
Maximum disk space 100% 29 28,536,000 28,536
System usage 8% 2 2,394,000 2,394
Data usage 63% 18 18,019,000 18,019
Available disk space 28% 8 8,123,000 8,123
(d) FREE
These particular OVERFLOW reports indicate that there are 1024 frames
held in reserve. When a file-restore is performed, the reserve pool is set
to this level. In an emergency, frames can be transferred from the
reserve pool to the general pool of available overflow frames by means
Operations: System administration 22-11
would reduce the reserve pool to 500, transferring 524 frames to the
overflow pool. This is a temporary measure and a file-save and file-
restore should be carried out as soon as possible. It is unwise to run the
system with no reserve frames.
Recall that the ABS frames hold the code for all the standard AP facilities.
It is essential that the contents of the ABS frames are correct and, from
time to time, the System Manager should verify them by means of the:
VERIFY-SYSTEM
even whilst there are other users logged on and you can abandon the
-
command should be used to reload the ABS frames from a file-save tape
or from the original Pick system diskettes/tapes. This should not be done
whilst there are other users on the system.
to reach and process data which lies in the group of frames beyond the
site of the error. We shall have more to say about GFEs in Chapter 24.
GFEs are reported as they are encountered during processing and the file
statistics report shows any GFEs detected during a file-save or account-
save.
22-12 This is Advanced Pick
If yoususpect that a certain file may have GFEs you may have been
-
working on it when there was a power failure then you can scan it by
-
LIST STAFF
LIST ONLY STAFF
COUNT STAFF
which forces the Access processor to read all the items on the file. If you
wish to check for any GFEs in the frames used by indirect items, then you
might use a command such as:
You can scan all the files of a suspect account for GFEs by means of the:
CHECK~ACCOUNT
or the equivalent:
SAVE (FI
command; both perform a dummy account-save. You can check the
entire system for GFEs by means of the commands:
CHECK-FILES
Or::
SAVE (F
in all cases, if the process runs to completion without any errors being
reported, then there are no GFEs on the file / account / system.
22.3.4 ERRORS
Whenever any system errors, such as group format errors, forward link
errors, or backward link errors, are detected, Advanced Pick logs these
on the ERRORS file. Any messages logged by the LOG-MSG command
are also recorded on this file. The System Manager should monitor the
ERRORS file on a regular basis, using the command:
LIST ERRORS
When any GFEs are reported and/or fixed by the GFE handler, a dump
of the offending frames will be placed on the ERRORS,GFE data section
Operations: System administration 22-13
Once the date and time of the Advanced Pick calendar/clock have been
set, they should need little attention. The current setting for both date and
time can be checked by means of the:
TIME
command.
The system date can be reset by means of the SET-DATE command.
This has a form such as:
SET-DATE 1 JAN 1999
SET-DATE 1/1/99
which will reset the system calendar until the next coldstart, at which point
the date will be reset from the hardware calendar/clock. If the U option
is specified:
If the form 1/1/99 is used, care should be taken to ensure that the correct
date format European or USA is in force. The external form of the
- -
SET-DATE-EUR
to set the European format: 31/12/99
SET-DATE-STD
to set the American format: 12/31/99.
SET-TIME 09:30:59 (U
SET-TIME 09:31 (U
22.5 Messages
Auser may communicate with any other user by sending a message with
the MESSAGE (or the equivalent SEND-MESSAGE and MSG) command.
Some examples are:
MESSAGE * message
pass the message to all users who are currently logged on, including
the line which issued the MESSAGE command.
MESSAGE !7 message
pass the message to port number 7, even if there is no user logged on
. there.
MESSAGE !* message
pass a message to all ports, whether or not there is a user logged on
there.
Figure 22.7 shows the places within the standard system where the
System Manager may insert messages or modify the standard messages.
These messages are held in the usual MESSAGES file format, as
described in Chapter 4, and will be displayed to all users during the log
on / log off process. The most important of these are:
© Messages 340 and 336 are displayed when the user logs off.
LOGON message
on MDS file
inviting logon
User logs on
q
LOGON message
on MESSAGES file
Message 335
on MESSAGES file
i
Pass to TCL or logon procedure
I
Message 340 Message 340
on MESSAGES file on MESSAGES file
Message 336
on MESSAGES file
There is also the BULLETIN file which ts used to hold messages which
are to be displayed to users. The BULLETIN items are created /
maintained by a command such as:
and contain four attributes: attribute 1 holds the user-id of the sender of
the message; attribute 2 holds a brief title for the messages; attribute 3
holds the text of the message in Output Processor format; attribute 4 is
used by the system. The bulletins are displayed by the command:
BULLETIN. BOARD
to display all available messages, or:
BULLETIN.BOARD NEW
22-16 This is Advanced Pick
to output any messages which have not already been displayed to this
user. In this case, the user-id of the recipient of the message is
placed in attribute 4 of the BULLETIN item.
As each user logs on and logs off the system, Advanced Pick monitors
this by creating and updating certain items. Thus, if user uuuu logs on at
port pppp, the following files are updated:
1) Item pppp on the PIBS file is updated to show the user-id, the
account-name, the logon date and the logon time. This information
is used by the LISTU command.
Unless you actually need to use the accounting information, it is better not
to produce it; recording the information needlessly takes up time and disk
space. Accounting for an individual user may be suppressed by removing
(or not entering) A in the OPTIONS field of the USERS item; accounting
may be suppressed across the system by removing the ACCOUNTS file.
If you do produce the accounting information, it is good practice to print
the LISTACC report and clear the ACCOUNTS file down from time to
time.
As a user logs off, the usage (thatis, the total connect time, the CPU time
and the number of printed pages) will be displayed:
This same information can be displayed at any time during the session by
means of the CHARGES command.
CHARGE-TO wwtools
uuuutwwtools
amend the PIBS file (as in stage (1) above) and (provided that the
accounting information for user-id uuuu is being logged) will create a new
item on the ACCOUNTS file with the item-id uuuu*wwtools and all
subsequent usage will be charged to that item. This extended user-id will
be shown on the WHO command (and by the U50BB and U60BB user-
exits) and should be used in the MESSAGE command, but the original
user-id uuuu will be retained to identify the TCL stacker list of commands
and to identify spooler jobs.
> TERM
Lineskip: 0
Lf delay: 7
Ff delay: 2
Back space: 8
5 TERM-TYPE
details of the escape sequences and other codes which are used to
produce effects, such as cursor positioning and clearing the screen,
on that type of terminal. A set of DEVICES items are provided for the
more frequently-encountered terminais (and printers), and the System
Manager can add to these by means of the DEFINE-TERMINAL utility.
The product name is taken from the MM-MON item on the DEVICES
file.
Width: the number of characters per line for the devices. There are
two width parameters, one for the terminal and one for the
spooler/printer.
Depth: the number of lines per page (or screen) for the device.
Again, there are two depth parameters.
Line skip: the number of lines to be {eft at the foot of the screen. This
is the difference between the page depth value for the screen and the
physical depth of the screen. This parameter is usually set to 0.
Line-feed delay: the number of delay characters which are to be
output after each line-feed when sending output to the screen. This
Operations: System administration 22-19
The terminal characteristics are used to determine the format (width and
depth) of all output reports and also the terminal display protocol. It is,
therefore, essential that the characteristics are set correctly for each port
on the system.
then much of the screen output would be unintelligible. The reason for
this is that, whenever an instruction such as clear the screen is executed,
Advanced Pick looks at your terminal characteristics to determine what
sort of terminal you are using, then it looks to the DEVICES file to see
what sequence of characters will clear the screen on that particular piece
of equipment, and finally it sends the required string of characters to clear
the screen. In this particular instance, the characters:
HEX(1B) HEX(2A) HEX(1)
will clear the screen on terminal type MM-MON, but the character:
HEX(1A)
Compare this with the resultant settings shown in Figure 22.8. Any
parameters which are not to be changed may be omitted (although the
positional commas must be included). So we might issue:
TERM 132
SET-TERM has the same general form and is used to set the default
22-20 This is Advanced Pick
and/or for each account. The DEVICE field of the PIBS file (especially
the terminal name) should be changed whenever the physical device
attached to a port is changed.
The SET-PORT and the SET-BAUD commands are used to set the
communication characteristics and the baud rate for a port. Full details
of these commands can be found in EPick.
Locking
The monitor
0000
Virtual machines
TCL commands: sur-map / BUFFERS / BUFFERS.G / CLEAR-LOCKS / CONFIG
CORE / CONVERSE / DISC / FLUSH / INIT-OVF / MIRROR / MONITOR-STATUS /
SET-BATCH / SET-BATCHDLY / SET-BAUD / SET-FLUSH / SET-PORT / SHPSTAT
TANDEM.
22.9 Summary
23
Security
Beyond this, each user-id, account name or account synonym may have
a password. Passwords may be set and changed by means of the
password Command. This asks:
and then:
Enter user name
or:
Enter account name
Having indicated which user-id / account name you wish to handlem you
must then enter the new password (or null, if you are removing an existing
password), and then enter it once again for confirmation. If you enter null
for the new password, you will be asked to confirm that you wish to
remove the password.
Advanced Pick keeps no record of who has attempted to access the
system or of failed attempts to log on. It is possible, however, to
implement this through a program invoked from the macro of the user
definition or during a logon procedure, as mentioned below.
where uuu is the user-id, and will be any one of SYSO or SYS1 or SYS2.
The SYSn indicator is held in the SYSPRIV field of the items on the
USERS file. The possibilities are:
© SYSO is the lowest level of security and SYSO users:
Cannot use the backing storage devices.
Cannot update the MD or other dictionary files.
Cannot create, clear or delete files.
Cannot create, clear or delete indexes.
Cannot start/stop printers.
Can only use the P, G, END and OFF commands when in the
debugger.
o SYS1 users:
e Can use backing storage devices.
Can use the verbs: CREATE-FILE, DELETE-FILE, CLEAR-FILE,
CREATE-INDEX, CLEAR-INDEX and DELETE-INDEX,
Cannot perform save/restore operations.
Can update the MD and dictionary files.
Cannot amend the MDS file.
Cannot start/stop printers.
Can only use the P, G, END and OFF commands when in the
debugger.
o SYS2 users have access to all Advanced Pick facilities, including file-
save and file-restore operations, use of the Assembler and any
debugger commands. The following can only be performed by a user
with SYS2 privileges:
e DUMP
e CLEAR-LOCKS
INIT-OVF
@ LOGOFF
@ SET-BAUD; SET-PORT; SET-TIME; SET-DATE
e SP-KILL
@ STOPPTR; STARTPTR
@ CONVERSE; MIRROR; TANDEM.
Since there are only three such levels, the distinction is fairly coarse. Ifa
user attempts to perform an action for which his/her privilege level is
Security 23-3
There may also be a SYSPRIV field on the account definition items on the
MDS file, but this is ignored.
23.3 Lock-codes
In the simplest situation, the files which belong to one account are
inaccessible to users of other accounts. For example, a user who is
logged on to the PERSONNEL account cannot look at the contents of the
INVOICES file which has been created on the SALES account.
However, this is not an ideal situation. If accounts were not able to share
files, it might mean that there were several copies of the same information
on the system, each copy being accessible by a certain account; if we did.
this, there would be the added problem of ensuring that the various
copies were up-to-date and consistent. The solution is to create a pointer
which behaves like a D-pointer and is used like a D-pointer, but which
points not to a specific frame of virtual memory but holds the account
name and the file name which you want to access. Such as item is called
a Q-pointer or a file synonym, as we saw in Chapter 4.
File Q-pointers will allow users of one account look at, and use, files
which belong to another account. But how can you restrict the access?
How can you stop people amending files which they are only supposed
to look at? The Advanced Pick answers to these questions are lock-
codes.
By setting lock-codes on your files you can stop other users looking at
your files or changing them. Only users who have matching keys in the
KEYS field of their item on the USERS file will be able to handle any
locked files. Figure 23.1 shows that lock-codes may be held on any or -
all of:
-
© The account definition on the MDS file: a lock-code here will lock
the MD of the account, and hence the dictionaries and data sections
of all files on that account.
© The file definition (the D-pointer) on the master dictionary which
identifies the file: a lock-code here will lock the DICT section of the
file, and hence all data sections which depend upon that DICT
section.
o The data-level identifier (the D-pointer) on the dictionary of the file:
a lock-code here will lock that data section of the file.
A lock-code in any of these positions will lock all linkages below that point,
as the vertical bars in Figure 23.1 indicate.
23-4 This is Advanced Pick
:UD MD file.name
Lock-codes for the data section of a file
are held on the data-level identifier
DICT
:uD file.name file.name
% :up file.name data.section.name
ox
data
Let us imagine that the owner of the WAGES account wishes to restrict
access to the STATISTICS file and has placed the lock-code:
MONDAY
in the file definition for the STATISTICS file (held on the MD of the
WAGES account). Now, in order to access this file from, say, the SALES
account, a user with the user-id FRED logged on to the SALES account
might attempt to use references such as:
LIST WAGES, STATISTICS,
UPDATE WAGES,STATISTICS, '1000'
1) The user-id and password are accepted and validated, and then...
2) Any instructions specified in the MACRO that is, attributes 9 onwards
-
-
of the USERS items are carried out, and then ...
If there is no LOGTO (or TO) command in the MACRO, then the
name of the account (master dictionary) and password are accepted
and validated; if
LOGTO command is included in the MACRO, then
the user is logged to that account, and then ...
3) The MD is scanned for an item which has the same name (item-id) as
the account or as the account synonym. If this is an executable item
(such as a Proc or a macro or a menu or a catalogued program or a
verb), then it will be invoked; if there is no such item, then the user is
passed to the TCL prompt.
For example, if user called FREDA logs to an account called WAGES,
a
any executable item with the item-id WAGES on the MD will be invoked.
If there is no such WAGES item (or there is WAGES item but it is not
a
executable), then the user passes to the TCL prompt. A command which
has the same name as the account is called a logon procedure. A
typical use of the logon procedure is:
© To throw the users straight into an application system,
© To ask for extra identification such as a further password or entry
code,
© Tocarry out a security check that the user / the port / the time of day
are acceptable for work on that account.
The first of these is possibly the most common, with the logon procedure
calling up a standard application program so as to confine the users to
this program. Such a program would guide the users, prompt them,
control them, and vet and restrict the activities which they perform. In this
23-6 This is Advanced Pick
manner, the users need not know about TCL commands or how to use
the TCL language.
Even when they are thrown into a specific application, if the users press
the <Break> key, they may be able to interrupt the processing and reach
TCL level. In the situation where it is required to shield the users
completely from TCL or to prevent them from using the TCL facilities, this
use of the <Break> key is clearly undesirable. However, it can be
arranged that any attempt to break out in this way will be ignored (by
disabling the <Break> key off), or by forcing the user to return to the initial
logon procedure. If you organise your processing in this manner, it is
known as a closed system.
A logon procedure on the MD for the WAGES account might look like that
in Figure 23.2 (a). A closed system Is set up by creating an account
definition on the MDS file, as in Figure 23.2 (b).
00 WAGES
o1 N
04 OFF
oo WAGES
01 D
02 599034
03 37
04
05
06
o7
08 SYS2
og < OPTIONS field
10 10
account from reaching TCL by breaking out of the logon procedure. Ifa
Security 23-7
*
prompt (or possibly the debug prompt or !) will appear. If the user
enters END then control will be passed back to the logon procedure and
not to TCL.
The use of account synonyms means that an account may be reached
via several different account names, and that each synonym will have its
own logon procedure and system privileges even though all users of
the various synonyms are working on the same true account.
Since the MD is the repository for all the commands and verbs which are
available to the users of an account (and its synonyms), it is a simple
matter to remove any verbs, such as:
e EDIT
e UPDATE
e MESSAGE /MSG
and any others which may jeopardise the security of the system or which
ate likely to be hazardous for the inexperienced user.
slistu
zswho *
* O dm dm
1 mary dm
2 bert develop
3 samir develop
where
24
Group 0
the Editor,
the Update Processor,
the Access processor,
the Basic READ/WRITE operations,
the COPY processor,
and others. In fact, the only processing routines which can access all the
24-2 This is Advanced Pick
Note that only the group in which the GFE occurs is affected. The other
groups in the file and any other parts of the system are not directly
affected. use the word directly because if the affected frame(s) hold
|
items such as D-pointers which are used to access other parts of the
- -
Note also that the error affects only the fogical meaning of the data. Itis
not a permanent physical error which will affect that frame indefinitely;
such frames are recognised as faulty and ingored by Advanced Pick.
The top line of each frame shows three pieces of information: the FID of
this frame, the forward link (the FID of the frame into which this frame
overflows, if any), and the backward link (the FID of the frame from which
this frame overflows, if any). This linkage information is actually held in
the final 24 bytes of the frame (or the last 48 bytes on systems which use
2048-byte frames). Look at the data in frame 8000. You can clearly
identify the information relating to item 3333 on the file. You will recall
from Chapter 4 that each item is preceded by an 8-byte control string
(visible as ¢ for item 3333) which tells Advanced Pick about the
item: how big the item is, whether it is held directly or indirectly, whether
or not it has been changed since the last file-save, and so on. You will
also recall that each item is terminated by the end-of-item marker -
shown here as the " followed by one or two characters. There is also
_
the end-of-group marker, shown here as the character, after the data
_
in the group.
The 8-byte control field must contain acceptable values for the
length of the item, and
The control field must contain an acceptable indication of whether
the item is held directly or indirectly.
The expected length (as taken from the control field) must tie up with
the actual physical length (as indicated by the end-of-item marker).
In Figure 24.2 (b), you can see such an invalid control field on the line
starting at byte 450 of frame 8000. This might have been caused by
some electro-mechanical fault as the frame was being written to disk
and would generate a GFE if we later attempted to read item 6000 or
any of the following items.
The position of the final end-of-item marker is inconsistent with the
item length count.
A hardware problem.
Someone physically amending the modulo in a D-pointer.
(a) Group 0
and the GFE handler will then allow you to take appropriate action, as we
shall discuss shortly. Since Advanced Pick only senses a GFE when it
needs to access data in the group which contains the error, GFE may
lie undetected for some time.
In order to search for GFEs, you must force the system to look at what
you suspect to be the offending area. There are several ways in which
you might do this:
1) To look for GFEs in a suspect file, you may use commands such as:
LIST STAFF WITH Al NOPAGE
LIST ONLY STAFF WITH Al NOPAGE
COUNT STAFF WITH Al
CHECK-FILES
SAVE (F
In all cases, any GFEs will be reported. If the process runs to completion
without any errors being reported, then there are no GFEs on the file /
account / system.
Unfortunately, the GFE handler does not show the actual frame where
the GFE occurred. A solution to this can be found in the information
logged on the ERRORS file. When a GFE is logged on the ERRORS file,
the log item contains certain information which does not appear on the
normal LIST ERRORS report. The following datanames are useful here:
DATE
TIME
ore-Frie this shows the name of the file where the GFE occurred.
24-6 This is Advanced Pick
GPE-FID this shows the FID of the frame (in hexadecimal) and the
location of the GFE within the frame.
this shows the commands which were being processed
when the GFE was detected.
and these can be used in your own Access reports to locate the GFE.
When a GFE is detected, Advanced Pick calls up the GFE handler. This
logs the situation on the ERRORS file, dumps the offending frame(s) to
the ERRORS,GFE file, and displays the message:
r this will make the best possible sense of the data up to the site of
the GFE and then set an end-of-group marker to ignore the rest of
the data in the group. A copy of the lost data is dumped to the
ERRORS,GFE file.
t at the time of writing, there appears to be no practical difference
between the effect of the F and the T responses.
If you are in any doubt, you should select the Q option. This will give you
time to think about what to do about the problem.
if you want the process to stop at each GFE so that you may take
appropriate action.
y if you want save all possible data without any user intervention.
This will enable the process to run unattended.
If you enter N, indicating that you want to intercept each GFE, then, as
each GFE is detected, the process will report:
*** GFE encountered
Tstruncate group & continue / S=skip & continue / Q=just quit / <CR>=go to
debugger ?
twill fx the GFE on disk and then continue to save any items which
it can;
will leave the disk data unchanged and save any items which it
can.
If you indicated that you want to bypass any GFEs, this is equivalent to
entering the S option as each GFE is detected.
The same effect is produced by using the G option on the SAVE verb; this
will report any GFEs encountered and then skip that group and continue.
24.7 Summary
24-8 This is Advanced Pick
that the information in the frame cannot be interpreted correctly and the
items at and beyond the site of the GFE are inaccessible to most
Advanced Pick processes. The GFE handler is automatically called up
when a GFE is detected, and this gives you a number of options for fixing,
removing, and clearing the problem.
25
alone will invoke the DOS shell and allow you to work directly at the DOS
prompt line. The DOS EXIT command or the "D character will pass
control back to Advanced Pick. You can use any of . or DOS or PC or
SHELL or SH or SHL as alternatives to the ! identifier for DOS.
The effect is similar on AP/Unix systems. The Advanced Pick command:
!DIR
will invoke the Unix command to display a report of the current directory.
Any Unix command may be invoked in this way and the commands have
their normal Unix form. The command:
alone will invoke the Unix shell and allow you to work directly at the Unix
prompt line. The Unix EXIT command or the "D character will pass
contro! back to Advanced Pick. You can SH as an alternative to the
identifier for Unix.
25-2 This is Advanced Pick
There are a number of TCL commands which invoke the equivalent Unix
command directly. These include: CC / CPIO / ENV/ GREP /LL/LS/
PG /PWD/STTY/SU/ TTY, and the command:
PSH unix.command > {file} item {(T}
The EXPORT verb is used to transfer data from Advanced Pick to the
host operating system. For AP/DOS, this has the form:
specifying the name of the Pick file and the item-id(s) of the items which
are to be exported. The options include:
The process will then ask for the name of the DOS file to which the data
is to be exported.
The EXPORT verb is used to transfer data from Advanced Pick to the
host operating system. For AP/Unix, this has the form:
specifying the name of the Pick file and the item-id(s) of the items which
are to be exported. The options include:
The process will then ask for the name of the host file to which the data
is to be exported.
-
ina form which can be read on DOS systems. The data is copied from
the Advanced Pick file and transferred to the backing storage device
which is currently attached. The EXPORT command to do this has the
orm:
specifying the name of the Pick file and item-ids of the items which are to
be exported. The options include:
The process will then ask for the name of the host file to which the data
is to be copied on the diskette, and this will be entered in the DOS form
but without a drive letter.
The IMPORT verb is used to transfer data to Advanced Pick from the host
operating system. For AP/DOS, this has the form:
IMPORT dos.file.name {(option}
specifying the name of the DOS file including the drive and directory
-
The process will then ask for the name of the Advanced Pick file and the
item-id to which the data is to be copied.
The IMPORT verb is used to transfer data to Advanced Pick from the host
operating system. For AP/Unix, this has the form:
IMPORT pick.file.name item.list { (options)
specifying the name of the Pick file and the item-id(s) of the items to
which the Unix files are to be imported. The options include:
The process will then ask for the name of the Unix files from which the
data is to be imported.
AP/Native systems will import files from a DOS diskette or the DOS
partition into an Advanced Pick file. The IMPORT command to do this
has the form:
IMPORT dos.file.name {(options}
The process will then ask for the name of Advanced Pick file and item-id
to which the file is to be imported.
25.8 Summary
26
26.3 SELECT
26.4 Indexes
26-2 This is Advanced Pick
26.5 Views
26.6 Summary
Appendix A: Glossary Appendix-1
Glossary
Basic: The language which is used to write programs for the computer.
There are many such programming languages available. The standard
Pick system can handle programs written in the Basic language and the
Proc language.
Basic debugger: A standard piece of software which allows the
programmer to identify and locate errors in a Basic program.
Break condition: A state of the data or the execution of a program at
which the execution is to be interrupted and control passed to the
debugger. Break conditions are set by means of the B command, and
the program execution will be interrupted when any one is reached.
Break-point table: That part of the trace table which holds details of the
current break conditions.
Bridging: Advanced Pick facility whereby the integrity between two files
may be maintained as items are added, changed and deleted from a file.
Command: An instruction given to the Pick system when at the TCL level.
Cruising: Advanced Pick facility whereby the user may browse through
the items in a file for which an index is being maintained.
Level pushing: The Advanced Pick facility whereby the current process
may be interrupted (by hitting the <Break> key) and a second process
invoked. In turn, this second process may be interrupted and a further
process invoked. As each low-level process terminates, control is
returned to the process at the previous level.
Open Architecture: A version of the Pick system between R83 Pick and
Advanced Pick.
Out-of-line item: An alternative to the term indirect item.
Output processor: The text processing utility of Advanced Pick which is
provided for the production of printed material and documents. It extends
the features of Runoff and allows control commands to be embedded
within the text lines.
Appendix A: Glossary Appendix-5
single name so that it can easily be recalled in future. The term is also
used to refer to the language which is used to write such processing
routines.
synonym -
which allows an account or a file to be identified by an
alternative name.
R83 Pick: The original version of the Pick system and the predecessor of
Open Architecture and Advanced Pick. Most Pick-like systems are based
upon R83 Pick.
Runoff: The standard text processing software of the R83 Pick and
Advanced Pick systems. Although still available, it has been superseded
by the Output Processor on AP.
Selection criterion: That part of an Access sentence which starts with
the word WITH or IF and which indicates which items are to be included
in the report.
Selective restore: The operation in which one or more items are restored
save held on backing
to a file by taking the data from a file save / account
storage. Usually done when items on the live system have been
(accidentally or otherwise) removed.
Sentence: A command in the Access enquiry language. An Access
sentence must begin with one of the Access verbs.
Sort specification: That part of an Access sentence which starts with
one of the keywords BY / BY-DSND / BY-EXP / BY-EXP-DSND and which
controls the sequence in which the items of the report are to be sorted.
Source program: A sequence of Basic statements written by a
programmer in order to performsome particular process. Before it can
be executed, a source program must be converted into the equivalent
object program by the compiler.
Stacker: A standard piece of software which allows TCL commands to
be saved, changed and maintained, recalled and re-issued.
Subvalue: Any value of an item may hold zero, one or more separate
subvalues. These are held within the value and separated by the
subvalue mark (ASCII character 252). In general, subvalues are not used
to store data in an application system.
Appendix-6 This is Advanced Pick
Symbol table: A list containing references to all the variables, labels and
subroutine calls used in a Basic program, and which the Basic run-time
processor uses to identify the location of each object which it uses. The
table is produced by the Basic compiler and (normally) held with the
object program. It is particularly useful in conjunction with that feature
of the Basic debugger which allows the programmer to interrogate (and
change) the contents of the program variables, identifying them by name.
Symbolic debugger: Another name for the Basic debugger.
Synonym: An item -
such as an account synonym file synonym
/a
-
USERS file: The standard file which holds details of all the authorised
users on the Advanced Pick system. For each individual user, the
USERS file holds an identifying item.
Value: Any attribute may comprise several values separated by the
value-mark.
Zooming: Advanced Pick facility whereby the user, whilst processing one
file, may jump across and browse through the items in a second file.
Appendix-8 This is Advanced Pick
Runoff commands
The following options are generally available with the headings and
footings used in Access sentences, Basic programs, the Output processor
and other areas of Advanced Pick:
pu to output the date, as for D, except that the date of a long report will
be changed if it runs over midnight.
tu to output the date, as for T, except that the date of a long report will be
changed if it runs over midnight.
U to underline subsequent text.
to output:
followed by two blank lines at the top-centre of every page of the report.
\f there are two or more adjacent codes, you will enclose them in one set
of apostrophes:
Basic statements
! Go / GOTO / GO TO PROCWRITE
SINCLUDE GOSUB PROGRAM
SINSERT HEADING PROMPT
* IF READ
ABORT IN READNEXT
BEGIN CASE INCLUDE READT
BREAK INPUT READTL
CALL INPUT @ READTX
CAPTURING INPUTERR READU
CASE INPUTNULL READV
CASING INPUTTRAP READVU
CHAIN INS RELEASE
CLEAR KEY REM
CLEARFILE LET REPLACE
CLOSE LOCATE RETURN
COMMON LOCK REWIND
COMMON /com/ LOOP / REPEAT ROOT
CONVERT MAT ROM
CRT MATBUILD SELECT
DATA MATPARSE SEND
DEBUG MATREAD SLEEP
DEL MATREADU STOP
DELETE MATWRITE SUBROUTINE
DIMENSION MATWRITEU TCL
ECHO NEXT TCLREAD
END NULL UNLOCK
ENTER ON ... GOSUB WEOF
EQUATE ON ... GOTO WRITE
ERROR OPEN WRITET
EXECUTE OUT WRITEU
EXIT PAGE WRITEV
FILE PRECISION WRITEVU
FOOTING PRINT
FOR / NEXT PRINTER
GET PROCREAD
Appendix F : Basic functions Appendix-13
Basic functions
If you are migrating from a system other than R83 Pick, you should note
that the following Basic functions are not available on Advanced
Pick:
Proc statements
A(s}{n}{,m} IF (#} 8 RO
B IHx sP
BO IN{p} ss
c IP(B}{p}{b} ST OFF / ON
D{n}{.m}{+} IP{p} STOFF
F I8{p} STON
Gn IT Sn
con o T
GOTO n P Uxxxx
Hx PH K(x}
H{x}< PP (f 4)
H{x)} << PQ +n
IF A(n}{,m} Pw -n
IF (#} A{n} PX 0)
IF {#} E RI{n} [f 4]
ASCIl characters
This table presents the <Ctrl> keys which are used with the various
Advanced Pick tools. Here and throughout the book, the notation "D
represents <Ctrl>D and so on.
General filing
"XB Return to the previous item
"xc File, compile and catalog the (program) item
"XE Abandon the item without filing
"XF File the item
Rename and file the item
"XK Abandon the item(s) and return to TCL
"XN Exit item and go to a new item
"xO Exit and delete the item
"XP File and print the item
"XR File, compile and run the (program) item
"XR File and invoke the (macro/menu/Proc) item
"xs Save the item and continue
"XX Abandon the item without filing
Spelling checker
zs Disable the spelling checker
+
Index
The references here are of the form 26-1, indicating the chapter and the page-number within
that chapter.
Attribute definition 5-7, 10-5, 10-7, Capturing TCL history 8-10, 23-8
13-1, 13-9 Cartridge tape 3-11, 20-1
Attribute-mark 4-2, App-16 CASE 8-5, 16-28
Attribute-type 13-2, 13-7 Case sensitivity 2-2, 2-12, 4-28, 8-3,
8-5, 16-58
B 10-15, 14-6 CASING 2-13
B-tree 2-16, 15-5 CATALOG 16-90
B/ADD 2-4 Catalogue-pointer 2-12, 16-90
B/LIST 2-12, 16-33 CHAIN 16-69
Backing storage 2-20, 3-2, 3-11, CHAR 16-38
16-83, 20-1, 25-3 CHARGE-TO 22-17
Backup 3-11 CHARGES 22-17
Backward link 4-6, 4-20 CHECK-ACCOUNT 22-12, 24-5
Base FID 4-18, 4-29 CHECK-DX 21-7
Base frame 4-5 CHECK-FILES 22-12, 24-5
Basic 2-11, 16-1 CL 2-11,12-36
BASIC 16-86, 16-92 CLASHES 2-2, 2-4, 2-26
Basic debugger 6-5, 16-87, 18-1, CLEAR 16-36
18-4 CLEAR-FILE 2-5, 4-26
Basic functions 2-13, 16-37, App-13 CLEARFILE 16-77
BASIC options 16-87, 16-92 CLOSE 2-14
Basic statements 2-13, App-12 Closed system 22-4, 23-6
Batch processing 16-77 COL-HDR-SUPP 12-30, 12-40
BEFORE 12-14 Colon in PRINT statements 16-46
Blank lines in programs 2-12, 16-5 Column-width 13-2, 13-8, 13-10
BLIST 2-12 Comma in PRINT statements
BLOCK-CONVERT 4-37 16-46
BP 4-37 COMMENT 8-16,
BREAK-ON 12-21, 12-25, App-10 COMMON 2-14, 16-62, 16-65
BREAK-ON options 12-23 COMPARE 4-50, 12-40
Bridges 10-15, 14-6 COMPARE-LIST 12-38, 12-40
BRK-DEBUG 8-12 Comparison operators 12-14
BRK-LEVEL 8-12 COMPILE 2-12, 16-86, 16-92
BSYM 16-87 COMPILE-CATALOG 2-12, 16-88
Buffer 17-8 COMPILE options 16-87, 16-92
BULLETIN 22-16 COMPILE-RUN 2-12, 16-88
BULLETIN.BOARD 22-2, 22-16 Computed GOSUB 16-30
BY 2-6, 12-19 Computed GOTO 16-30
BY-DSND 12-20 Concatenation 14-7
BY-EXP 12-21 Connective 12-30
BY-EXP-DSND 12-21 Control break 12-21
Control field 4-20
C 14-7 Controlling attribute 13-4
CALL 14-8, 16-60 CONVERSE 2-5
CAPTCL 2-5, 8-4, 8-10, 23-8 Conversion 2-11, 10-30, 13-8,
CAPTURE 8-10 13-11, 14-1
CAPTURING 16-67 CONVERT 2-14
Index iii
MD 4-17
MD (processing code) 14-21 O 14-29
MDS 2-18,4-15, 4-17 OA: See Open Architecture 1-3
Memory 3-2, 22-8 Object program 16-4, 16-88
Menu 8-17 OCCURS 2-16
Menu definition 8-17 OCONV 2-11,10-30, 14-1, 16-38
Message 22-14 ON ... GOSUB 16-30
MESSAGE 2-5 ON ... GOTO 16-30
MESSAGES 2-18, 4-37, 4-39, 4-41, ONERR 2-16, 16-83
12-27 ONLY 2-9, 10-3, 12-13
MI 14-28 OP 11-3,11-5
Microdata 1-1 OP commands 11-5, App-8
ML 14-21 OP macros 11-6
MOD 16-39 OP options 11-5
Modifier 12-30 OPEN 16-72
Modulo 2-19, 4-7, 4-11,4-18, 4-29, Open Architecture 1-3
5-2, 5-4, 21-20 Operations 21-1, 22-1
MOVE-FILE 4-32 Operator assignment 2-13, 16-36
Moving to Advanced Pick 2-1 OPTIONS 22-4, 23-7
MP 14-28 OUT 2-15, 16-56
MR 14-21 Out-of-line item 4-21; See Indirect
MS 14-28 item
MSG 2-5, 22-14 Output-conversion 13-2, 13-6, 14-1
MT 14-22 Output list 2-8, 12-6
Multiple account-save 2-21,21-4 Output-macro 4-29, 12-12
Multiuser interface 2-20, 20-1 Output Processor 2-22, 11-11 See
Multivalue 4-3, 10-13, 12-16 OP
MX 14-29 Overflow 3-6, 4-4
MY 14-29 OVERFLOW 2-5, 22-8, 22-10
Overflow reserve 3-7
Named COMMON 16-65 OVF: See OVERFLOW
Nelson, Don 1-1
NEWAC 4-37 P 14-23
NEXT 16-30 P option 12-27
NFRAME-INDEX 15-4 PA 2-18
NI-SUPP 2-8, 12-30, 12-40 Packed decimal 14-28
Non-columnar output 12-8 PAGE 16-52
NOPAGE 12-30, 12-40 Page number 12-29
Normaiisation 5-1 Parallel printer 3-3
NOT 12-14, 16-39 Parameter 16-62
NSELECT 12-37 Partial string 12-17
NUM 16-39 Password 6-2, 23-1
Number 16-8 PASSWORD 22-3, 22-5
Numeric dataname 12-12, 12-33 Paste 10-25, App-18
Numeric datanames 2-9 Pathname 2-20, 4-36, 12-6
Numeric keypad 7-1 Pattern 14-23
Numeric string 16-11 Pattern matching 14-23, 16-27,
viii This is Advanced Pick
X 14-29
Xe 14-28
XC 13-8
XI 14-29
XO 14-29
XR 12-25, 14-29
XT 14-29
Z 8-22
ZA 14-30
ZC 14-30
ZHS 8-22
Zooming 10-17, 10-19
*
+