.VARIABLE FOA F D



.LM 0;.RM 70;.F;.J;.SP 1;.PS 58,70
.LC
.T ^^DECSYSTEM-10 SIMULA LANGUAGE HANDBOOK, PART I\\
.ST ^^CHAPTER 1\\
^^DECSYSTEM-10 SIMULA\\ ^LANGUAGE ^HANDBOOK, ^PART ^I\\
.BR
---------------------------------------------
.B 1
^^By Graham Birtwistle, Lars Enderin, Mats Ohlin and Jacob Palme\\
.B 3
^ABSTRACT
.BR
--------
.B 1
^THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ ^LANGUAGE ^HANDBOOK CONTAINS THE INFORMATION
NECESSARY FOR AN APPLICATIONS PROGRAMMER WHO INTENDS TO USE ^^SIMULA\\ ON A ^^DEC\\SYSTEM-10 COMPUTER.
.B 1
^PART ^I CONTAINS A DESCRIPTION OF THE ^^SIMULA\\ PROGRAMMING LANGUAGE.
^^It is a guide to the language consisting of four chapters.
The first chapter introduces SIMULA by way of some fully discussed
examples. Chapter two gives the syntax and semantics of SIMULA.
The third chapter describes (with furhter examples) the standard
system classes and text handling facilities. The last chapter
deals with separate compilation of procedures and classes.\\
^PART ^^II\\
CONTAINS SPECIAL INFORMATION FOR ^^DEC\\SYSTEM-10. ^^Part III describes the
SIMULA Utility Library (LIBSIM).\\
.B 1
^^SIMULA\\ IS A GENERAL-PURPOSE HIGH-LEVEL PROGRAMMING LANGUAGE COMPARABLE
IN POWER TO ^^PL/I\\ OR ^ALGOL#68.  ^^SIMULA\\ IS BASED ON ^^ALGOL\\#60
WITH THE ADDITION OF RECORD-ORIENTED DYNAMIC MEMORY ALLOCATION,
REFERENCE (POINTER) STRUCTURES, SETS AND QUEUES, TEXT- AND CHARACTER
HANDLING, SEQUENTIAL AND DIRECT ACCESS INPUT-OUTPUT, QUASI-PARALLEL
SEQUENCING (COROUTINES) AND PROCESS (EVENT) ORIENTED SIMULATION CAPABILITIES.
.B 1
^^SIMULA\\ IS DESIGNED IN A WAY WHICH MAKES IT EASY TO PRODUCE PERSPICIUOUS,
WELL-STRUCTURED, READABLE AND SECURE PROGRAMS.  ^^SIMULA\\
IS WELL ADAPTED TO STRUCTURED PROGRAMMING METHODOLOGY.
.B 1
^^SIMULA\\ WILL OFTEN CONSIDERABLY REDUCE THE PROGRAMMING TIME
COMPARED TO CONVENTIONAL LANGUAGES LIKE ^^FORTRAN, COBOL\\, OR ^^PL/I.\\
.B 1
^^SIMULA\\ ON THE ^^DEC\\SYSTEM-10 CONTAINS TWO MAJOR ADDITIONS TO THE
^^SIMULA\\ LANGUAGE: ^A SYSTEM FOR SEPARATELY COMPILED PROGRAM MODULES
IN ^^SIMULA, FORTRAN\\, OR ^^MACRO\\#10 AND A POWERFUL ON-LINE DEBUGGING SYSTEM, ^^SIMDDT.\\
.B 1
^THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ COMPILER REQUIRES 25 TO 30^K USER AREA AND COMPILES
AT ROUGHLY HALF THE SPEED OF THE ^^DEC\\SYSTEM-10 ^^ALGOL\\ COMPILER.  ^THE ^^CPU\\
TIME WHEN RUNNING ^^SIMULA\\ PROGRAMS IS ABOUT THE SAME AS FOR ^^ALGOL\\,
FASTER FOR INPUT-OUTPUT AND TEXT STRING HANDLING, SLOWER FOR STACK-ORIENTED
MEMORY ALLOCATION.
.B 1
^KEY WORD AND PHRASES: ^COMPUTER, ^PROGRAMMING, ^PROGRAMMING ^LANGUAGE, ^^SIMULA,\\
^^DEC\\SYSTEM-10, ^DIGITAL ^EQUIPMENT, ^^PL/I,\\ ^ALGOL#60, ^ALGOL#68,
^FORTRAN, ^COBOL, ^DYNAMIC ^MEMORY ^ALLOCATION, ^LIST STRUCTURE, ^DATA STRUCTURE,
^RECORD, ^SET, ^QUEUE, ^TEXT, ^STRING, ^CHARACTER, ^COROUTINE, ^PROCESS,
^EVENT, ^SIMULATION, ^STRUCTURED ^PROGRAMMING, ^SEPARATE ^COMPILATION,
^PART-COMPILATION, ^DEBUGGING, ^ON-LINE DEBUGGING.

.IFNOT FOA;.PG;
.ENDIF FOA;.FG 25
^COPYRIGHT (C) ^SWEDISH ^NATIONAL ^DEFENSE ^RESEARCH ^INSTITUTE AND THE ^NORWEGIAN ^COMPUTING ^CENTER.
.B 1
^THIS HANDBOOK MAY NOT BE SOLD, BOUGHT, COPIED OR OTHERWISE DISTRIBUTED FOR USAGE PRIMARILY
AS A MANUAL WITH ANOTHER ^^SIMULA\\ SYSTEM THAN THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ SYSTEM.
.B 1
^THE WORD ^^"SIMULA"\\ IS A REGISTERED TRADEMARK OF THE ^NORWEGIAN ^COMPUTING ^CENTER.
.B 1
^^NTIS N\\UMBER: ^P^B-243 064.
.B 1
.IF FOA;.NUMBER 2;.PAGE;
.ENDIF FOA
^^DECsystem-10 SIMULA was produced and is presently maintained by the Swedish
National Defense Research Institute, Section 142, S-10450 Stockholm 80, Sweden.
.INDEX ^^FOA\\
.INDEX ^^Defense Research Institute (Swedish)\\
.INDEX ^^Address of DECsystem-10 SIMULA maintenance\\
.index ^^Mailing list for users of DECsystem-10 SIMULA\\
.index ^^National Defense Research Institute (Swedish)\\
.index ^^SIMULA maintenance on DECsystem-10, address\\
.index ^^SIMULA on DECsystem-10, how to get info on updates\\
.index ^^Swedish Defense Research Institute\\
.index ^^updates, how to get info on\\
^^If you send your name and address to that address,
you will be put on the mailing list for a newsletter for DECsystem-10
SIMULA users.\\

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 3;.PAGE;
.ENDIF FOA
.LM 0;.RM 70;.F;.J;.SP 1;.PS 58,70;.C
^^CONTENTS\\
.C
--------
.B 3;.LM 10
^^BIBLIOGRAHPHY\\
.B
.I -8
^^CHAPTER 1##BASIC SIMULA
.I -8
-----------------------
.B 1
^COMPILE TIME AND RUN TIME
.B 1
1.1##THE HIGHEST MARK
.B 1
1.2##NUMBERING A CROSSWORD PUZZLE
.B 1
1.3##GEOMETRIC APPLICATIONS
.B 1
1.4##SIMULATION OF A QUEUEING SITUATION
.B 2;.I -8
CHAPTER 2##THE SYNTAX AND SEMANTICS OF SIMULA
.I -8
---------------------------------------------
.B 1
2.1##METHOD OF SYNTAX SPECIFICATION
.B 1
2.2##BASIC SYMBOLS AND SYNTACTIC VARIABLES
.B 1;.LM 13
2.2.1##LANGUAGE CHARACTER SET
.BR
2.2.2##BASIC SYMBOLS
.BR
2.2.3##DATA CHARACTER SET
.BR
2.2.4##THE USE OF BLANKS
.BR
2.2.5##COMMENT CONVENTIONS
.BR
2.2.6##CODING SIMULA PROGRAMS
.B 1;.I -3
2.3##IDENTIFIERS
.B 1;.I -3
2.4##TYPES AND CONSTANTS
.B 1
2.4.1##TYPES
.BR
2.4.2##CONSTANTS
.B 1;.I -3
2.5##DECLARATIONS
.B 1
2.5.1##TYPE DECLARATIONS
.BR
2.5.2##ARRAY DECLARATIONS
.BR
2.5.3##SWITCH DECLARATIONS
.BR
2.5.4##PROCEDURE DECLARATIONS
.BR
2.5.5##CLASS DECLARATIONS
.BR
2.5.6##EXTERNAL DECLARATIONS
.BR
2.5.7##HIDDEN PROTECTED SPECIFICATIONS

.IFNOT FOA;.PG;
.ENDIF FOA;.I -3
2.6##EXPRESSIONS
.B 1
2.6.1##VARIABLES
.BR
2.6.2##FUNCTION DESIGNATORS
.BR
2.6.3##ARITHMETIC EXPRESSIONS
.BR
2.6.4##BOOLEAN EXPRESSIONS
.BR
2.6.5##CHARACTER EXPRESSIONS
.BR
2.6.6##DESIGNATIONAL EXPRESSIONS
.BR
2.6.7##OBJECT EXPRESSIONS
.BR
2.6.8##TEXT EXPRESSIONS AND TEXT VALUES
.B 1;.I -3
2.7##BLOCKS AND STATEMENTS
.B 1
2.7.1##BLOCKS AND COMPOUND STATEMENTS
.BR
2.7.2##STATEMENTS
.B 1;.I -11
CHAPTER 3##SYSTEM CLASSES AND TEXT HANDLING
.I -11
-------------------------------------------
.B 1;.LM 10
3.1##PROGRAM STRUCTURE
.B 1
3.2##CLASS SIMSET
.B 1
3.3##CLASS SIMULATION
.B 1
3.4##TEXT
.B 1
3.5##CLASS BASICIO
.B 1;.LM 2
CHAPTER 4##SEPARATE COMPILATION
.BR
-------------------------------
.B 1
.LM 10
4.1 WHY SEPARATE COMPILATION?
.B 1
4.2 GOOD AND BAD SEPARATE COMPILATION
.IF FOA;.NUMBER 4;.PAGE;
.ENDIF FOA
.B 1
4.3 WHAT SIMULA CONCEPTS CAN BE SEPARATELY COMPILED?
.B 1
4.4 HOW IS SEPARATE COMPILATION SPECIFIED?
.B 1
4.5 EXAMPLES OF PARTITIONING OF SIMULA PROGRAMS
.B 1;.LM 0
APPENDIX A:##ISO-7 (ASCII) CHARACTERS AS USED IN SIMULA
.B 1
APPENDIX B:##SYSTEM PROCEDURES
.B 1
APPENDIX C:##SKELETONS OF THE SYSTEM CLASSES AND SYSTEM PROCEDURES
.B 1
INDEX\\
.IF FOA;.NUMBER 5;.PAGE;
.ENDIF FOA

.IFNOT FOA;.PG
.ENDIF FOA;
.c
^^BIBLIOGRAHPHY
.c
-------------
.b 3
.index ^^Defining document of the SIMULA Language\\
.index ^^SIMULA Language standard definition\\
.index ^^Norwegian Computing Centre\\
.index ^^SIMULA newsletter\\
.index ^^Newsletter on SIMULA\\
.index ^^Textbook on SIMULA\\
.index ^^Primer on SIMULA\\
.index ^^Standardization of SIMULA\\
.INDEX ^^References (= Bibliography)\\
.INDEX ^^Bibliography\\
.INDEX ^^Litterature\\
.index ^^Manuals, list of\\
^^(Defining document of ALGOL part of the SIMULA Language) Revised Report
on the Algorithmic Language ALGOL 60. Comm. ACM, 1963, Vol.#6,
No.#1, pp.#1-17.
.b
(Defining document of SIMULA part of the SIMULA Language) SIMULA 67 Common
Base Language. Publ. no S-22. Norwegian Computing Center, Forskningsveien 1b, Oslo, Norway.
.b
(Beginners textbook on SIMULA) SIMULA BEGIN. Studentlitteratur,
Fack, S-221 01 Lund 1, Sweden, ##or## Mason and Lipscomb,
Petrocelli Book Division, 384 Fifth Avenue, New York,
N Y 10018, U S A.
.b
(Short introduction) A Primer on the CLASS and Pointer Concepts
in SIMULA. Report C 10043, Rapportcentralen, FOA 1, S-104 50 Stockholm 80,
Sweden.
.b
(Regular newsletter for SIMULA users) SIMULA newsletter. Norwegian
Computing Center, Forskningsveien 1b, Oslo, Norway.
.b
(Newsletter for DECsystem-10 SIMULA users) DECsystem-10 SIMULA
Gazette. Section 142, Swedish National Defense Research Institute,
S-104 50 Stockholm 80, SWEDEN.
.b
DEC-system 10 SIMULA Reference Card.
Report C 10039, Rapportcentralen, FOA 1, S-104 50 Stockholm 80,
Sweden.
.b
DEC-system 10 SIMULA Language Handbook:
.break
.left margin 3
Part I: The programming language SIMULA. Report no. C8398.
.break
Part II: DECsystem-10 Dependent information, debugging. Report no. C8399.
.break
Part III: Utility Library. Report no. C10045.
.break
Rapportcentralen, FOA 1, S-104 50 Stockholm 80, SWEDEN.
.left margin 0
.b
The DECsystem-10 SIMULA Handbooks and the primer on the CLASS and
Pointer Concepts will also be available as RUNOFF files
on the SIMULA distribution tape.
.SUBTITLE CHAPTER 1
.IF FOA;.NUMBER 8;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.C
^^CHAPTER 1##BASIC SIMULA\\
.BR;.C
-----------------------
.B 3
.index ^^Examples\\
.index ^^Basic concepts of SIMULA\\
^THE MAIN PURPOSE OF THIS CHAPTER IS TO INTRODUCE THE CONCEPTS
OF THE ^^SIMULA\\ PROGRAMMING LANGUAGE.  ^THIS IS DONE THROUGH
EXAMPLES OF INCREASING SCOPE.
.B 1
^THE FRAMING OF A PROBLEM FOR COMPUTER SOLUTION TAKES PLACE IN
TWO PHASES.  ^THE FIRST DESIGN PHASE CONSISTS OF ANALYSING
THE PROBLEM, DECOMPOSING IT INTO ITS COMPONENTS,
CLASSIFYING THESE COMPONENTS AND PLANNING THE FLOW OF THE
COMPUTATIONS.  ^THE SECOND PHASE IS CODING, THAT IS EXPRESSING
THE PLAN OF PHASE ONE IN A PROGRAMMING LANGUAGE.  ^WITH
MANY PROGRAMMING LANGUAGES THIS WILL AMOUNT TO A COMPLETE
REWRITING, AS THE NATURAL HUMAN MODES OF DECOMPOSITION
AND CLASSIFICATION ARE NOT AVAILABLE WITHIN THE LANGUAGE.
^THIS IS NOT THE CASE WITH ^^SIMULA\\, WHERE CONCEPTS FOR A
GIVEN PROBLEM OR PROBLEM AREA CAN BE FORMULATED DIRECTLY
IN THE LANGUAGE ITSELF.
.B 1
^THUS ^^SIMULA\\ IS MORE THAN JUST A NOTATION FOR DESCRIBING COMPUTING PROCESSES#-#IT
ALSO PROVIDES A FRAMEWORK FOR CONCEPT CREATION AND IS A TOOL OF
THOUGHT IN PROBLEM ANALYSIS.
.IF FOA;.NUMBER 9;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1
^THE MAIN FEATURES OF ^^SIMULA\\ ARE PRESENTED IN EXAMPLES.
.B 3
^WHEN DEVELOPING THE ^^SIMULA\\ PROGRAM WE WILL USE CAPITAL LETTERS
FOR ITEMS WHICH ARE VALID ^^SIMULA\\, AND LOWER CASE LETTERS
OTHERWISE.
.B 1
^THUS
.B 1;.I 5
^^IF\\ THE CARWASH IS IDLE ^^THEN ACTIVATE\\ THE CARWASH
.B 1
HAS TWO PARTS
.B 1;.I 5
THE CARWASH IS IDLE
.I 5
THE CARWASH
.B 1
WHICH HAVE YET TO BE PUT INTO ^^SIMULA\\.
.IF FOA;.NUMBER 10;.PS 80,80;.PAGE;
.ENDIF FOA

.IFNOT FOA;.PG
.ENDIF FOA;
^^COMPILE TIME AND RUN TIME\\
.index ^^Run time\\
.index ^^Compile time and run time\\
.index ^^Compile time\\
.BR
-------------------------
.B 1
^WHEN A PROGRAM IS PRESENTED TO A COMPUTER IT IS PROCESSED
IN TWO DISTINCT PHASES.  ^IN THE FIRST PHASE, THE PROGRAM
WRITTEN IN ^^SIMULA\\ (THE SOURCE PROGRAM) IS TRANSLATED INTO
.index ^^Source program\\
ITS EQUIVALENT IN ANOTHER LANGUAGE ALREADY "KNOWN" BY THE
COMPUTER.  ^DURING THIS TRANSLATION STAGE, KNOWN AS COMPILE
TIME, THE SOURCE PROGRAM IS CHECKED FOR SYNTACTIC AND
SEMANTIC ERRORS (ILLEGAL CONSTRUCTIONS, UNDECLARED VARIABLES,
ETC.) AND, IF ANY ARE FOUND, THE EXECUTION PHASE IS
OMITTED.  ^^SIMULA\\ HAS BEEN DESIGNED TO TRAP AS MANY ERRORS
AS POSSIBLE AT COMPILE TIME.
.B 1
^AFTER SUCCESSFUL COMPILATION, THE SOURCE PROGRAM IS NO LONGER
NEEDED AND THE COMPUTER OPERATES ON ITS TRANSLATED FORM CALLED
.index ^^Object program\\
THE OBJECT PROGRAM.  ^SINCE THE TWO PROGRAMS ARE EQUIVALENT,
THERE IS NO NEED FOR US TO THINK OF PROGRAM EXECUTION IN TERMS
OF THE OBJECT PROGRAM#-#WE CAN RETAIN A MENTAL PICTURE OF ITS
EXECUTION IN TERMS OF THE ^^SIMULA\\ SOURCE PROGRAM.  ^THE OBJECT
PROGRAM IS EXECUTED SUPPORTED BY PREWRITTEN ROUTINES CALLED
.index ^^Run time system\\
THE RUN TIME SYSTEM (^^RTS\\).  ^THIS STEP IS CALLED RUN TIME.  ^AT
RUN TIME, THE PROGRAM DATA IS READ IN WHEN NEEDED AND RESULTS PRINTED
OUT WHEN REQUESTED IN THE PROGRAM.  ^ANY ERRORS OCCURRING AT
RUN TIME ARE CALLED RUN TIME ERRORS.
.SUBTITLE ^^CHAPTER\\ 1.1
.IF FOA;.NUMBER 11;.PS 80,80;.PAGE;
.ENDIF FOA
.B 3
1.1##^^THE HIGHEST MARK\\
.BR
#####----------------
.B 1
^A CLASS OF STUDENTS SITS AN EXAMINATION AND MARKS ARE AWARDED
IN THE RANGE 0-100 AS WHOLE NUMBERS (^^INTEGERS\\).  ^A LIST OF
THESE MARKS IS PRESENTED TO THE COMPUTER.  ^WRITE A PROGRAM TO
FIND THE HIGHEST MARK.
.B 1
^A SIMPLE PLAN FOR THE PROBLEM IS THIS.  ^TRACE DOWN THE LIST
OF NUMBERS AND PROCESS THEM ONE BY ONE#-#AT EACH STAGE COMPARING
THE PRESENT VALUE WITH THE HIGHEST VALUE MET SO FAR.
(^IT IS CONVENIENT TO CARRY ALONG THE HIGHEST VALUE SO FAR MET
TO AVOID REPEATED BACK-CHECKING).  ^IF THE PRESENT VALUE IS
THE HIGHER, THEN IT REPLACES THE OLD HIGHEST-VALUE-MET, OTHERWISE
IT HAS NO SIGNIFICANCE.  ^AS THE ONLY INFORMATION WE NEED
RETAIN IS NOW NOTED, THE PRESENT LIST VALUE CAN BE DISCARDED.
^THUS IT IS NOT NECESSARY TO RETAIN THE WHOLE LIST OF NUMBERS
IN THE COMPUTER.  ^THE PROCESS IS REPEATED TAKING THE REMAINING
LIST MEMBERS IN TURN UNTIL THE LIST IS EXHAUSTED WHEN THE LAST
HIGHEST-VALUE-MET IS THE NUMBER WE REQUIRE.

.IFNOT FOA;.PG
.ENDIF FOA;
^TO FOLLOW THIS SCHEME WE NEED NOTE AND COMPARE THE VALUES OF
TWO VARIABLES (CALLED "VARIABLES" BECAUSE THEIR VALUES VARY
DURING THE CALCULATIONS).  ^THESE WE CALL "^^PRESENT"\\ AND "^^HIGHEST\\",
THE PRESENTLY CONSIDERED LIST VALUE AND THE HIGHEST VALUE MET SO
FAR, RESPECTIVELY.  ^A PARTIAL DESCRIPTION OF THESE ACTIONS COULD
BE:
.B 1;.LM 20;.I -9
STEP 1:##LET "^^PRESENT\\" BE THE NEW INPUT VALUE
.B 1;.I -9
STEP 2:##IF "^^PRESENT\\" IS GREATER THAN "^^HIGHEST\\" THEN COPY
THE FORMER'S VALUE INTO "^^HIGHEST\\".
.B 1;.LM 0
^THE MOST CONCISE AND TEXTUALLY CLEAR WAY OF WRITING THESE ACTIONS
IS TO WRITE THEM IN A PROGRAMMING LANGUAGE#-#IN THIS CASE ^^SIMULA\\.
.IF FOA;.NUMBER 12;.PS 80,80;.PAGE;
.ENDIF FOA
.LM 12;.B 1;.NF;.NJ;.TS 57,60
	LINE#NO.
	--------
.B 1;.I -12
^^READ:##PRESENT#:= ININT;		1
.BR
IF PRESENT > HIGHEST THEN HIGHEST := PRESENT;	2
.BR
GOTO READ;		3\\
.B 1;.LM 0;.F;.J
^THIS PIECE OF PROGRAM CONTAINS THREE BASIC STATEMENTS OF
DIFFERENT TYPES:
.B 3
.index ^^Statement\\
ASSIGNMENT-STATEMENT##(LINE 1)
.index ^^Assignment\\
.BR
--------------------
.B 1;.I 5
VARIABLE#:=#EXPRESSION
.B 1
WHERE THE VALUE OF THE EXPRESSION ON THE RIGHT IS COMPUTED
AND ASSIGNED TO THE VARIABLE ON THE LEFT, I.E., THE VARIABLE TAKES
ON THE VALUE OF THE EXPRESSION.

.IFNOT FOA;.PG
.ENDIF FOA;
CONDITIONAL-STATEMENT##(LINE 2)
.index ^^Conditional statement\\
.BR
---------------------
.B 1;.I 5
^^IF\\ CONDITION ^^THEN\\ STATEMENT
.B 1
WHERE THE STATEMENT IS EXECUTED ONLY IF THE CONDITION IS ^^TRUE\\.
.B 1
^ANOTHER FORM OF CONDITIONAL STATEMENT IS
.B 1;.I 5
^I^F CONDITION ^^THEN\\ STATEMENT 1
.I 18
^^ELSE\\ STATEMENT 2
.B 1
WHICH IS EVALUATED AS:
.B 1;.LM 9;.I -4
1)##EVALUATE THE CONDITION
.B 1;.I -4
2)##IF IT IS ^^TRUE\\ EXECUTE STATEMENT 1 AND SKIP STATEMENT 2,
IF IT IS ^^FALSE\\ THEN SKIP STATEMENT 1 AND EXECUTE STATEMENT 2.
.IF FOA;.NUMBER 13;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.LM 0
E.G.:
.B 1;.I 5
^^IF X < 0 THEN Y := -X ELSE Y := X\\
.B 1
WILL ASSIGN THE MAGNITUDE OF ^X TO ^Y.
.B 2;.LM 0;.RM 70
.index ^^GO TO statement\\
^^GOTO\\-STATEMENT##(LINE 3)
.BR
--------------
.B 1;.I 5
^^GOTO READ\\
.B 1
WHICH ALTERS THE SEQUENCE OF EXECUTION OF THE STATEMENTS FROM
THE TEXTUAL SEQUENCE TO THE ONE LABELLED "^^READ\\" (IN THIS CASE).
.B 1
^ASSIGNMENTS ARE COMPUTATIONAL STATEMENTS WHERE DATA VALUES ARE
ALTERED.  ^^GOTO\\ AND ^^IF-THEN-ELSE\\ CONSTRUCTIONS ARE CONTROL STATEMENTS
WHICH RESPECTIVELY ALTER THE PROGRAM FLOW, AND CAUSE STATEMENTS
TO BE SKIPPED IF THE GIVEN CONDITION DOES NOT HOLD.
.B 1
^THE COMMON OPERATION OF READING IN THE NEXT ^^INTEGER\\ (WHOLE NUMBER)
VALUE IS ACHIEVED BY WRITING "^^ININT\\" WHOSE VALUE IS THAT
NEXT WHOLE NUMBER IN THE INPUT STREAM.  "^^ININT\\" IS THUS A VALUE
WHICH CAN BE ASSIGNED TO A VARIABLE.

.IFNOT FOA;.PG
.ENDIF FOA;
^TO SEPARATE OUT ONE STATEMENT FROM ANOTHER IN A PROGRAM SEMICOLONS
.index ^^Semicolon (;)\\
(';') ARE USED.  ^REMEMBER THAT STATEMENTS DO NOT THEMSELVES
CONTAIN SEMICOLONS.  ^THE OTHER PUNCTUATION MARK USED
.index ^^Colon (:)\\
HERE IS THE COLON (':') WHICH SEPARATES OUT A LABEL FROM THE
STATEMENT IT IDENTIFIES.  ^ANY STATEMENT MAY BE LABELLED, BUT THE LABEL
IS UNNECESSARY UNLESS IT IS THE OBJECT OF A ^^GOTO\\-STATEMENT.
.B 1
^THIS PROGRAM SEGMENT IS NON-TERMINATING AND WILL GO ON ASKING
FOR MORE AND MORE INPUT, WHICH IS NOT QUITE WHAT WE INTENDED.
^ONE METHOD OF OVERCOMING THIS IS TO TERMINATE THE INPUT STREAM
.IF FOA;.NUMBER 14;.PS 80,80;.PAGE;
.ENDIF FOA
WITH AN "IMPOSSIBLE NUMBER" (SAY, ANY NEGATIVE NUMBER) AND TEST
FOR THIS NUMBER AT THE HEAD OF THE LOOP.  ^WHEN THE IMPOSSIBLE
NUMBER IS MET, IT IS A SIGNAL TO GO OUT OF THE MAIN LOOP, PRINT
OUT THE CONTENTS OF ^^"HIGHEST"\\ AND TERMINATE THE PROGRAM.
.B 1
^USING THIS TECHNIQUE, THE WHOLE PROGRAM IS:
.B 1;.NF;.NJ;.LM 5;.TS 12,55,59
		LINE#NO.
		--------
.B 1
^^BEGIN	INTEGER PRESENT, HIGHEST;		1
READ:	PRESENT := ININT;		2
	IF PRESENT < 0 THEN GOTO PRINT;		3
	IF PRESENT > HIGHEST THEN HIGHEST := PRESENT;	4
	GOTO READ;		5
PRINT:	OUTTEXT ("THE HIGHEST VALUE = ");		6
	OUTINT (HIGHEST, 3);		7
END\\			8
.B 1;.LM 0;.RM 70;.F;.J
^SAMPLE DATA SET
.BR
---------------
.B 1
INPUT:##14##63##17##-2
.BR
-----
.B 1
OUTPUT:##^^THE HIGHEST VALUE#=#63\\
.BR
------

.IFNOT FOA;.PG
.ENDIF FOA;
^THE UNEXPLAINED LINES ARE:
.B 1
LINE 1:##^^INTEGER PRESENT, HIGHEST\\
.BR
DECLARES TWO VARIABLES IDENTIFIED BY ^^PRESENT\\ AND ^^HIGHEST\\.
^THE KEY WORD ^^INTEGER\\ GIVES THE TYPE OF THESE VARIABLES AND
INTRODUCES A MEASURE OF SECURITY INTO THE LANGUAGE.
.IF FOA;.NUMBER 15;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1
^^INTEGER\\ VARIABLES MAY ONLY HOLD WHOLE NUMBERS.  ^OTHER TYPES
INCLUDE ^^REAL\\ (FOR FRACTIONAL NUMBERS), ^^BOOLEAN\\ (WHICH CAN ONLY
TAKE THE VALUES ^^TRUE\\ AND ^^FALSE\\)#......#^BY GIVING VARIABLES
TYPES WE HAVE THE POSSIBILITY TO SPOT SUCH ERRORS AS
.B 1;.I 5
^^PRESENT#:=#TRUE##(TRUE\\ IS NOT AN ^^INTEGER\\ VALUE)
.B 1
OR
.B 1;.I 5
^^IF HIGHEST THEN#....#(HIGHEST\\ CAN NOT HAVE THE
.I 27
VALUE ^^TRUE\\ OR ^^FALSE\\).
.B 1
.index ^^Initial value, introduction\\
^ON DECLARATION, VARIABLES TAKE INITIAL VALUES ACCORDING TO
THEIR TYPE.  ^^INTEGER\\ VARIABLES TAKE THE VALUE 0, ^^REAL\\ VARIABLES
0.0 AND ^^BOOLEAN\\ VARIABLES ^^FALSE\\.  ^THE INITIAL VALUES OF OTHER
TYPES WILL BE NOTED WHEN THEY ARE INTRODUCED.
.B 2
LINE 3:##^^IF PRESENT < 0 THEN GOTO PRINT\\
.index ^^Arithmetic IF statement\\
.BR
TRANSFERS CONTROL TO THE STATEMENT LABELLED "^^PRINT\\" IF THE
INPUT VALUE IS NEGATIVE.  ^OTHERWISE THE NEXT STATEMENT TO BE
EXECUTED IS THAT ON LINE 4.
.B 2
LINE 6:##^^OUTTEXT ("THE HIGHEST VALUE = ")\\
.BR
CAUSES THE TEXT CONSTANT TO BE OUTPUT#-#TEXT CONSTANTS ARE ENCLOSED
IN DOUBLE QUOTES (") SO THAT THERE CAN BE NO CONFUSION
BETWEEN, FOR EXAMPLE
.B 1;.I 5
"12"##A TEXT CONSTANT#####12 A NUMBER
.I 5
^^"END\\"#A TEXT CONSTANT#####^^END\\ A KEY WORD
.B 1
.IF FOA;.NUMBER 16;.PS 80,80;.PAGE;
.ENDIF FOA
^THIS PROGRAM TAKES THE FORM OF A BLOCK.  ^WRITING A TYPICAL
DECLARATION AS "^D", AND A TYPICAL STATEMENT AS "^S", THEN A
.index ^^Block\\
BLOCK HAS THE FORM
.B 1;.I 5
^^BEGIN##D;#D;#.....;#D;#S;#S;#S;#.....;#S;#END\\
.B 1
^NOTICE THAT DECLARATIONS ARE ALWAYS GROUPED AT THE HEAD OF
A BLOCK AND THE STATEMENTS (ACTIONS UPON THEM) COME AFTERWARDS.
^AS SEMICOLONS ARE USED TO TERMINATE THE VARIOUS COMPONENTS
OF THE BLOCK, IT IS THUS POSSIBLE TO MAKE THE TEXT VISUALLY
CLEAR AND AS APPEALING AS POSSIBLE BY ALIGNING, PUTTING LABELS
WELL TO THE LEFT, ETC.
.IF FOA;.NUMBER 17;.PS 80,80;.PAGE;
.ENDIF FOA

.IFNOT FOA;.PG
.ENDIF FOA;
^THE PROGRAM JUST WRITTEN WAS NOT CAREFULLY PLANNED#-#IT WAS
BUILT UP ATOM BY ATOM AND FITTED TOGETHER.  ^THIS IS REFLECTED
IN THE FINAL RESULT WHICH IS AWKWARD TO FOLLOW.  ^FOR PROGRAMS
TO BE EASILY READ AND UNDERSTOOD IT IS ESSENTIAL TO DECOMPOSE
THE PROBLEM INTO ITS DISTINCT COMPONENTS AND THEN DECOMPOSE
THESE STILL FURTHER INTO SMALLER COMPONENTS, UNTIL THE ATOMS
OF THE PROBLEM ARE REACHED.  ^IN THIS WAY A CLEAR OVERALL
FRAMEWORK IS GUARANTEED.  ^A FRESH SET OF ACTIONS FOR THIS
PROBLEM COULD BE PLANNED BY SPLITTING THE PROBLEM INTO TWO
PHASES AS FOLLOWS:
.B 1;.I 5
READ/COMPUTE#;##WRITE
.B 1
WHICH LEADS DIRECTLY TO A FORMULATION ALONG THE LINES
.B 1
^^FOR PRESENT\\#:=#NEXT VALUE ^^WHILE PRESENT\\ NOT NEGATIVE ^^DO\\
.I 5
REPLACE ^^HIGHEST\\ BY ^^PRESENT \I\F PRESENT\\ IS THE GREATER;
.BR
^^WRITE (HIGHEST)\\
.B 1
^EXPRESSED IN ^^SIMULA\\, THE CORRESPONDING PROGRAM IS:
.B 1;.LM 2;.NF;.NJ;.TS 9,57,60
		LINE#NO.
		--------
.B 1
^^BEGIN	INTEGER PRESENT, HIGHEST;		1
	FOR PRESENT := ININT WHILE PRESENT >= 0 DO		2
	###IF PRESENT > HIGHEST THEN HIGHEST := PRESENT;	3
	OUTTEXT ("THE HIGHEST VALUE = ");		5
	OUTINT(HIGHEST,9);		6
END\\			7
.IF FOA;.NUMBER 18;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.LM 0;.RM 70;.F;.J
.index ^^FOR statement\\
^THE ONLY NEW FEATURE IS THE ^^FOR\\-STATEMENT SPANNING LINES 2-3.
.B 1
^THIS ^^FOR\\-STATEMENT IS A CONTROL STATEMENT USED FOR ORGANISING
A REPETITION WHILE A CONDITION IS MET (^^PRESENT >= 0, PRESENT\\
GREATER THAN OR EQUAL TO 0).  ^THE GENERAL FORM IS:
.B 1;.I 5
^^FOR#\\ ASSIGNMENT ^^WHILE\\ CONDITION ^D^O
.I 10
CONTROLLED-STATEMENT
.B 1;.LM 0
WHICH IS UNDERSTOOD AS FOLLOWS:
.B 1;.LM 9;.I -6
^F1:##THE ASSIGNMENT IS MADE (^^PRESENT := ININT\\)
.B 1;.I -6
^F2:##IF THE CONDITION IS ^^TRUE\\ THE CONTROLLED STATEMENT (LINE 3)
IS EXECUTED, AND THEN CONTROL RETURNS BACK TO ^F1 (THE NEXT
VALUE IS READ IN ...).  ^IF THE CONDITION IS ^^FALSE\\, CONTROL
LEAVES THE ^^FOR\\-STATEMENT AND THE STATEMENT FOLLOWING
THE CONTROLLED STATEMENT (LINE 4) IS EXECUTED.
.B 1;.LM 0
^THE COMMENTS IN PARENTHESES REFER TO THE GIVEN EXAMPLE.
.IF FOA;.NUMBER 19;.PS 80,80;.PAGE;
.ENDIF FOA

.IFNOT FOA;.PG
.ENDIF FOA;
^WHEN THE SOURCE PROGRAM HAS BEEN COMPILED AND EXECUTION BEGINS,
AN INSTANCE OF THE PROGRAM BLOCK IS CREATED, THE DATA SPACES
CREATED, THEIR VALUES INITIALIZED ACCORDING TO THEIR TYPE AND
THEN EXECUTION OF THEIR ACTIONS BEGINS.  ^A CONVENIENT PICTURE
.index ^^Block instance\\
OF A BLOCK INSTANCE IS:
.B 1
.LM 10;.NF;.NJ
----------------
_!   ^R^T^S INFO   !
----------------
_! DECLARATIONS !
----------------
_!   ACTIONS    !
----------------
.B 1;.LM 0;.RM 70;.F;.J
.index ^^RTS info\\
.index ^^Run time system information\\
^SOME ASPECTS OF THE ^^RTS\\ INFO (RUN TIME SYSTEM INFORMATION) WILL
BE EXPLAINED LATER.
.B 1
^WHEN THE ACTIONS ARE EXECUTED, EACH OCCURRENCE OF AN IDENTIFIER
IN THE ACTIONS MAY BE CONSIDERED MATCHED WITH THE OCCURRENCE
OF THE SAME IDENTIFIER IN THE BLOCK INSTANCE HEAD, AS BELOW:
.B 1;.LM 10;.NF;.NJ
------------------------
_!       ^^RTS\\ INFO       !
------------------------
_! ^^INTEGER PRESENT    0 !
_!                      !
_! INTEGER HIGHEST    0 ! <----
------------------------     !
_!                      !     !
_!  FOR PRESENT :=...   ! >----
------------------------\\
.B 1;.LM 0;.RM 70;.F;.J
(^IN PRACTICE, THE MATCHING IS MOSTLY DONE IN THE COMPILE STEP
TO MINIMIZE RUNNING-TIME, BUT CONCEPTUALLY WE MAY THINK OF THE
MATCHING AS A LOOK-UP AMONG THE DECLARED VARIABLES AS ILLUSTRATED
IN THE FIGURE).  ^THIS METHOD OF MATCHING IS KNOWN AS THE 
.index ^^Binding rule\\
^BINDING ^RULE FOR VARIABLES.  (^IT IS EXTENDED LATER).  ^IT
FOLLOWS THAT ALL SUCH QUANTITIES MUST BE DECLARED AND THAT AN
IDENTIFIER CAN BE DECLARED ONLY ONCE IN ANY BLOCK.  ^BY PICTURING
BLOCK INSTANCES IN THIS FASHION, THESE POINTS SEEM VERY OBVIOUS.
.SUBTITLE ^^CHAPTER\\ 1.2
.IF FOA;.NUMBER 20;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
1.2###^^NUMBERING A CROSSWORD PUZZLE\\
.BR
######_----------------------------
.B 1
^SUPPOSE WE ARE GIVEN AN ^N#X#^N CROSSWORD PUZZLE FILLED WITH BLANK AND BLOCKED
OFF OUT SQUARES AND ARE FACED WITH THE PROBLEM OF LOCATING AND
NUMBERING THOSE SQUARES FROM WHICH WORDS CAN BEGIN.
.B 2;.LM 10;.TS 10;.NJ;.NF;.I -10
E.G.	---------------------
!   !   !   !!!!!   !
! 1 !   ! 2 !!!!! 3 !
!   !   !   !!!!!   !
---------------------
!   !!!!!   !   !   !
!   !!!!! 4 !   !   !
!   !!!!!   !   !   !
---------------------
!   !!!!!   !!!!!   !
!   !!!!!   !!!!!   !
!   !!!!!   !!!!!   !
---------------------
!   !   !   !   !   !
! 5 ! 6 !   ! 7 !   !
!   !   !   !   !   !
---------------------
!   !   !   !   !   !
! 8 !   !   !   !   !
!   !   !   !   !   !
---------------------
.B 1;.LM 0;.F;.J
^A LITTLE TESTING BY HAND WILL SOON SHOW THAT AN ACROSS CLUE CAN BEGIN IF
THREE CONSECTIVE SQUARES HAVE THE PATTERN
.B 2;.LM 10;.TS 10;.NF;.NJ;.I -10
^A:	-----------------
!!!!!     !     !
!!!!!  _^  !     !
!!!!!  !  !     !
-------!---------
       !
   ACROSS CLUE CAN BEGIN HERE

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
AND A DOWN CLUE WHERE THREE CONSECUTIVE SQUARES HAVE THE PATTERN
.B 1;.LM 10;.NF;.NJ
-----
!!!!!
!!!!!
.TS 10;.I -10
^B:	-----
!   !
! <-!--- DOWN CLUE CAN BEGIN HERE
!   !
-----
!   !
!   !
!   !
-----
.B 1;.LM 0;.F;.J
^THUS BY SWEEPING THROUGH THE BOARD AND MATCHING PATTERNS, ALL THE CLUE-STARTING SQUARES CAN BE FOUND.
^THIS PATTERN MATCHING FAILS IF PART OF EITHER PATTERN ^A OR ^B
FALLS OUTSIDE THE BOARD, WHICH CAN HAPPEN ONLY IF THE CENTRE SQUARE
.IF FOA;.NUMBER 21;.PS 80,80;.PAGE;
.ENDIF FOA
IS MATCHED WITH AN EDGE SQUARE OF THE BOARD, AS BELOW:
.B 2;.LM 10;.TS 22;.NF;.NJ
	+++++#^B
	+++++
	+++++
oooooooooooo+++++oooo
o   o   o   +   +   o
o   o   o   +   +   o
.I -6
^A#+++++++++++++ooo+++++oooo
.I -4
+++++   +   +   +   +   o
.I -4
+++++   +   +   +   +   o
.I -4
+++++++++++++ooo+++++oooo
o   o   o   o   o   o
o   o   o   o   o   o
ooooooooooooooooooooo
o   o   o   o   o   o
o   o   o   o   o   o
ooooooooooooooooooooo
o   o   o   o   o   o
o   o   o   o   o   o
ooooooooooooooooooooo
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
^INSTEAD OF COMPLICATING THE PROGRAM BY MAKING THE EDGES A SPECIAL CASE,
IT IS MUCH EASIER TO EXTEND THE CROSSWORD BY BLOCKED OUT SQUARES ALL
THE WAY ROUND ITS EDGE.
.B 2;.LM 10;.NF;.NJ
###0#-------#^N+1
.B 1
^^
##**************
##**************
##**************
##***        ***
##*** 1----N ***
##***        ***
##***        ***
##**************
##**************
##**************\\
.B 1;.LM 0;.F;.J
^IN THIS WAY, THE METHOD OF MATCHING PATTERNS HOLDS GOOD FOR
EVERY SQUARE IN WHICH WE ARE INTERESTED EXCEPT FOR ONE SPECIAL CASE.  ^THIS
IS WHEN A BLANK SQUARE IS SURROUNDED BY BLOCKED OUT SQUARES:
.B 2;.LM 10;.NF;.NJ
    *****
    *****
    *****
*****   *****
*****   *****
*****   *****
    *****
    *****
    *****
.B 1;.LM 0;.F;.J
WHICH FOR OBVIOUS REASONS DOES NOT SEEM TO OCCUR IN PRACTICE.  ^ITS
OCCURRENCE IS NOT CATERED FOR IN OUR PROGRAM, BUT IT IS A SIMPLE MATTER TO ALLOW FOR IT.
.B 1
.IF FOA;.NUMBER 22;.PS 80,80;.PAGE;
.ENDIF FOA
^THE REPRESENTATION OF THE CROSSWORD NEEDS SOME BACKGROUND EXPLANATION.  ^WHEN
A MATHEMATICIAN IS ENGAGED ON A PROBLEM CONCERNED WITH A SINGLE TRIANGLE,
THERE IS A STRONG POSSIBILITY OF HIS IDENTIFYING THE SIDES OF THE TRIANGLE BY "A", "B"
AND "C".  ^WHEN FACED WITH A PROBLEM INVOLVING MANY TRIANGLES, THE METHOD
OF IDENTIFICATION WILL USUALLY CHANGE TO THE USE OF SUBSCRIPTED VARIABLES,
NAMING THE SIDES OF THE FIRST TRIANGLE "A1", "B1", "C1", OF THE SECOND "A2",
"B2", "C2",#...#OF THE J'TH.  "AJ", "BJ", "CJ", ETC.  ^BESIDES SAVING THE TROUBLE
OF INVENTING MANY UNIQUE NAMES, THE NOTATION ALSO INVITES THE GROUPING OF LIKE DATA
UNDER ONE IDENTIFIER.  ^THE NOTATION IS EASILY EXTENDED#-#IF WE REQUIRE
VARIABLES WITH TWO, OR THREE,#....#SUBSCRIPTS, WE SIMPLY WRITE
.B 1;.LM 10;.TS 17,30;.NF;.NJ
B	C
 I,J	 I,J,K	...
.B 1;.LM 0;.F;.J
RESPECTIVELY, USING COMMAS TO SEPARATE OUT THE VARIOUS COMPONENTS.

.IFNOT FOA;.PG
.ENDIF FOA;
^IN PROGRAMS DEMANDING THE STORAGE OF MUCH DATA OF THE SAME TYPE, IT IS INCONVENIENT
TO DECLARE VARIABLES ONE AT A TIME, AND THE CONCEPT OF AN ^^ARRAY\\
.index ^^ARRAY\\
IS INTRODUCED TO ALLOW THE SIMULTANEOUS SPECIFICATION OF MANY VARIABLES
ALL OF THE SAME TYPE AND WITH THE SAME IDENTIFIER, DISTINGUISHABLE ONLY
THROUGH THE USE OF "SUBSCRIPTS".  ^WE CAN NOT USE THE MATEMATICIAN'S NOTATION OF
SUBSCRIPTED VARIABLES AS IT OCCUPIES MORE THAN ONE PHYSICAL LINE.
.B 1
.IF FOA;.NUMBER 23;.PS 80,80;.PAGE;
.ENDIF FOA
^BUT WE CAN WRITE ON ONE LINE AND SEPARATE OUT THE IDENTFIER AND THE
COMPONENTS BY USE OF SQUARE BRACKETS '[' AND ']'.  ^IN THIS WAY, THE MATHEMATICAL
.B 1;.LM 10;.TS 20,30;.NF;.NJ
^^A	B	C
 I	 I,J	 I,J,K\\
.B 1;.LM 0
ARE WRITTEN AS:
.B 1;.LM 10;.TS 20,30
^^A[I]	B[I,J]	C[I,J,K]\\
.B 1;.LM 0;.F;.J
RESPECTIVELY.
.B 1;.LM 0;.F;.J
^WHEN AN ARRAY IS DECLARED, THE FOLLOWING INFORMATION IS NEEDED:
.B 1;.LM 5;.I -5
1.###AN IDENTIFIER FOR THE ARRAY,
.B 1;.I -5
2.###THE TYPE OF THE ARRAY, WHICH FIXES THE TYPE OF EACH COMPONENT,
.B 1;.I -5
3.###HOW MANY DISTINCT VARIABLES THE DECLARATION INVOLVES.  ^THIS CAN
BE FOUND BY GIVING THE RANGE OF EACH SUBSCRIPT.
.B 1;.I -5
^A SIMPLE ARRAY DECLARATION IS
.B 1
^^INTEGER ARRAY LONGSIDE[0:6]\\
.B 1;.LM 0
WHICH GIVES FOR USE SEVEN SUBSCRIPTED VARIABLES, EACH OF TYPE ^^INTEGER\\ AND
EACH INITIALIZED TO ZERO.  ^THEY MAY BE REFERRED TO AS
.B 1;.I 5
^^LONGSIDE[0],#LONGSIDE[1],#.....,#LONGSIDE[6]\\
.B 1
.IF FOA;.NUMBER 24;.PS 80,80;.PAGE;
.ENDIF FOA
^TO MAKE THE USE OF SUBSCRIPTED VARIABLES FLEXIBLE, ONE IS ALLOWED TO
WRITE ARITHMETIC EXPRESSIONS IN THE SUBSCRIPT POSITIONS, SO THAT IF ^I#=#2, FOR EXAMPLE,
THEN ^^LONGSIDE[2*I]\\ AND ^^LONGSIDE[4]\\ REFER TO THE SAME QUANTITY.

.IFNOT FOA;.PG
.ENDIF FOA;
^A ^^CHARACTER ARRAY\\ IS USED TO REPRESENT THE CROSSWORD.  ^A BLANK
IS REPRESENTED BY THE ^^CHARACTER\\ CONSTANT ' ' AND A BLOCKED OUT SQUARE BY '*'.
^THE DECLARATION OF THE ^^ARRAY\\ IS:
.B 1;.I 5
^^CHARACTER ARRAY CWORD [0:N+1, 0:N+1]\\
.B 1
REPRESENTING THE CROSSWORD (DIMENSIONS 1 THROUGH ^N), AND THE RIM (DIMENSIONS 0 AND ^N+1).  ^THIS
WILL MAKE AVAILABLE (^N+2)_^2 VARIABLES OF TYPE ^^CHARACTER\\ EACH INITIALIZED TO THE INITIAL
VALUE ' ', BINARY ZERO (^^CHAR(0)).\\  ^^N.B.\\ SEVERAL ^^CHARACTERS\\ ARE NOT
VISIBLE WHEN PRINTED#-#THIS IS ONE OF THEM.
.B 1
^THE STRATEGY IS (IN WORDS):
.B 1;.LM 5;.I -5
1.###^N, THE NUMBER OF ROWS AND COLUMNS OF THE CROSSWORD ITSELF IS GIVEN ON THE FIRST INPUT LINE
.B 1;.I -5
2.###^READ IN THE DATA#-#EACH ROW BEING REPRESENTED ON A FRESH INPUT LINE
.B 1
^CHARACTERS MAY BE READ IN ONE BY ONE BY SUCCESSIVE CALLS ON ^^INCHAR\\.
.B 1;.I 5
.IF FOA;.NUMBER 25;.PS 80,80;.PAGE;
.ENDIF FOA
^^C##:=#INCHAR\\
.B 1
WILL ASSIGN THE CURRENT INPUT CHARACTER TO ^C AND MAKE THE NEXT CHARACTER
THE NEW CURRENT.  ^IN THIS WAY, REPEATED CALLS ON ^^INCHAR\\ SUCCESSIVELY SWEEP ACROSS THE INPUT LINE.
.B 1;.I -5
3.###^SCAN THROUGH THE CROSSWORD ALONG EACH INTERNAL ROW IN TURN AND MATCH THE PATTERNS
^A AND ^B ON EACH INTERNAL SQUARE.  ^IF A MATCH IS FOUND, PRINT OUT THE ROW
NUMBER, COLUMN NUMBER AND SERIAL NUMBER OF THE CORRESPONDING CLUE.
.B 1
^THIS PROSAIC DESCRIPTION SUGGESTS THE PLANNING STAGES:
.B 1;.I 5
READ IN THE CROSSWORD;
.I 5
.IF FOA;.NUMBER 27;.PS 80,80;.PAGE;
.ENDIF FOA
SCAN THROUGH THE CROSSWORD AND WRITE WHERE NECESSARY;
.B 2;.LM 0
READ IN THE CROSSWORD;
.BR
_----------------------
.B 1
^THIS PLANNING STAGE IS ITSELF FURTHER DIVISIBLE INTO TWO PARTS:
.B 1;.I 5
SET THE RIM VALUES; READ THE INTERNAL VALUES;
.B 1
WHICH ARE DISCUSSED IN TURN.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 5
SET THE RIM VALUES;
.BR
_-------------------
.B 1
^THE RIM MAY BE DIVIDED INTO FOUR PARTS, EACH OF ^N+1 SQUARES AS SHOWN:
.B 2;.LM 20;.TS 20;.NF;.NJ
###^^ROWNO#=#0
###COLNO#=#0#-->#N
#####!
#####!
-----V-------------------------
_!                      !      !
_!                      !      !
-----------------------!      !
_!     !                !      !
_!     !                !      !
.I -20
ROWNO#=#1#->#N#+#1#-->    !                !    <----ROWNO#=#0#->N
.I -20
COLNO#=#0	!     !                !      !##COLNO#=#N#+#1
_!     !                !      !
_!     !                !      !
_!     !                !      !
_!     !------------------------
_!     !                       !
_!     !        _^              !
_!     !        !              !
_---------------!---------------
               !
      ROWNO#=#N#+#1
      COLNO#=#1#->#N#+#1\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
.IF FOA;.NUMBER 26;.PS 80,80;.PAGE;
.ENDIF FOA
^THIS LEADS TO THE FORMULATION:
.B 1
^^FOR ROWNO\\ IS 0 THROUGH ^^N DO\\
.B 1;.LM 10;.NF;.NJ
^^CWORD[0,ROWNO]#:=#'*';
CWORD[ROWNO,N+1]#:=#'*';
CWORD[N+1,ROWNO+1]#:=#'*';
CWORD[ROWNO+1,0]#:=#'*';
\\
.B 1;.LM 0;.F;.J
READ THE INTERNAL VALUES;
.BR
_-------------------------
.B 1
^FOR THE KERNEL POSITION 1 THROUGH ^N, THIS IS:
.B 1;.LM 5
^^FOR ROWNO\\ IS 1 THROUGH ^^N DO\\
.B 1;.LM 10;.NF;.NJ
NEXT INPUT LINE;
.B 1
SWEEP ACROSS THE ROW FOR ^^COLNO\\ IS 1 THROUGH ^N
.B 1
AND AT EACH STAGE READ IN THE NEXT CHARACTER
.B 1
AND ASSIGN IT TO ^^CWORD [ROWNO, COLNO];\\
.B 1;.LM 0;.F;.J
^BUT THE CONTROLLED STATEMENT CAN JUST AS WELL BE WRITTEN BY USING A ^^FOR\\-STATEMENT:
.B 1;.LM 5
^^FOR ROWNO\\ IS 1 THROUGH ^^N DO\\
.B 1;.LM 10;.NF;.NJ
NEXT INPUT LINE;
.B 1
^^FOR COLNO\\ IS COL 1 THROUGH ^^N DO\\
.B 1
####^^CWORD#[ROWNO, COLNO]#:=#INCHAR\\;

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
^SCAN ^THROUGH THE ^CROSSWORD AND ^WRITE ^WHERE ^NECESSARY;
.BR
-----------------------------------------------------
.B 1
^THIS STAGE CONSISTS OF SCANNING THE CROSSWORD AND MATCHING PATTERNS. ^IF THE CURRENT
SQUARE IS NOT A BLANK, IT CAN NOT START A CLUE AND MAY BE SKIPPED.
.B 1;.LM 5;.NF;.NJ
^^FOR ROWNO\\ IS 1 THROUGH ^^N DO\\
^^FOR COLNO\\ IS 1 THROUGH ^^N DO\\
.LM 15
^^IF CWORD [ROWNO, COLNO]#=#'#' THEN
.LM 20
.B 1
IF\\ PATTERN ^A FITS OR PATTERN ^B FITS ^^THEN
.B 1
#####WRITE (ROWNO, COLNO,\\ SERIAL NUMBER)
.B 1;.LM 0;.F;.J
^WE ARE NOW IN A POSITION TO WRITE THE PROGRAM.
.B 3
^PROGRAM:
.BR
_-------
.B 1
^WE CAN NOT START THE PROGRAM BY:
.B 1;.LM 10;.TS 15;.NF;.NJ
^^BEGIN	INTEGER N;
	CHARACTER ARRAY CWORD [0:N+1, 0:N+1];
	N#:=#ININT;
	_.....\\
.B 1;.LM 0;.F;.J
BECAUSE THE BLOCK IS CREATED AND INITIALIZED BEFORE ANY ACTIONS ARE EXECUTED.  ^THUS,
THE ARRAY BOUNDS WILL NOT HAVE THE DESIRED VALUE AS ^N=0 AT THIS TIME.
.B 1
^AGAIN,
.B 1;.LM 10;.TS 15;.NF;.NJ
^^BEGIN	INTEGER N;
	N := ININT;
	CHARACTER ARRAY CWORD [0:N+1, 0:N+1];
	_.....\\
.B 1;.LM 0;.F;.J
IS ILLEGAL AS THE DECLARATIONS ARE NOT GROUPED AT THE HEAD OF THE BLOCK.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
.IF FOA;.NUMBER 28;.PS 80,80;.PAGE;
.ENDIF FOA
^THE WAY OUT IS TO CREATE AN INNER BLOCK THUS:
.index ^^Inner block\\
.B 1;.LM 10;.TS 15;.NF;.NJ
^^BEGIN	INTEGER N;
	N := ININT;
	BEGIN  CHARACTER ARRAY CWORD [0:N+1, 0:N+1];
	_.....
	END;
END\\
.B 1;.LM 0;.F;.J
.index ^^Outer block\\
^AN INNER BLOCK IS COUNTED AS A SPECIAL TYPE OF STATEMENT, SO THAT THE OUTER BLOCK HAS THE FORM:
.B 1;.LM 10;.TS 15,30;.NF;.NJ
^^BEGIN	\\DECLARATION
	STATEMENT;	(^^N := ININT)\\
	STATEMENT;	(INNER BLOCK)
^^END\\
.B 1;.LM 0;.F;.J
WHICH IS LEGAL.
.B 1
.IF FOA;.NUMBER 29;.PS 80,80;.PAGE;
.ENDIF FOA
^THE WHOLE PROGRAM IS:
.PAGE
.PS 58,75;.B 3;.LM 65;.RM 75
LINE#NO.
.BR
_--------
.B 2;.LM 0;.TS 8,68
^^BEGIN	INTEGER#N,#EDGE;	#1
.BR
	N#:=#ININT;#EDGE#:=#N+1;	#2
.BR;.LM 13;.TS 13,68;.I -8
BEGIN	INTEGER#ROWNO,#COLNO,#SERIALNO;	#3
.BR
CHARACTER#ARRAY#CWORD[0:EDGE,#0:EDGE];	#4
.BR
COMMENT#***WE#NOW#OUTPUT#THE#HEADING***#;	#5
.BR
OUTTEXT#("CROSSWORD#NUMBERING");	#6
.BR
OUTIMAGE;	#7
.BR
OUTTEXT#("##ROW##COL##SER.NO");#OUTIMAGE;	#8
.BR
COMMENT#***THE#READING#PHASE#FOLLOWS#-#	#9
.BR
###########EACH#ROW#IS#ON#A#NEW#CARD***#;	10
.BR
FOR#ROWNO#:=#0#STEP#1#UNTIL#N#DO	11
.BR
####CWORD[0,#ROWNO]#:=#CWORD[ROWNO,#N+1]#:=	12
.BR
####CWORD[N+1,#ROWNO+1]#:=#CWORD[ROWNO+1,#0]#:=#'*';	13
.BR
FOR#ROWNO#:=#1#STEP#1#UNTIL#N#DO	14
.BR
BEGIN#INIMAGE;	15
.BR
######FOR#COLNO#:=#1#STEP#1#UNTIL#N#DO	16
.BR
##########CWORD[ROWNO,#COLNO]#:=#INCHAR;	17
.BR
END;	18\\
.IF FOA;.NUMBER 30;.PS 80,80;.PAGE;
.ENDIF FOA
^^COMMENT ***THE NUMBERING PHASE FOLLOWS*** ;	19
.BR
FOR ROWNO := 1 STEP 1 UNTIL N DO	20
.BR
####FOR COLNO := 1 STEP 1 UNTIL N DO	21
.BR
########IF CWORD[ROWNO, COLNO] = ' ' THEN	22
.BR
########BEGIN##IF (CWORD[ROWNO, COLNO-1] = '*' AND	23
.BR
##################CWORD[ROWNO, COLNO+1] = ' ')	24
.BR
###############OR (CWORD[ROWNO-1, COLNO] = '*' AND	25
.BR
##################CWORD[ROWNO+1, COLNO] = ' ') THEN	26
.BR
###############BEGIN##SERIALNO := SERIALNO+1;	27
.BR
######################OUTINT(ROWNO, 5);	28
.BR
######################OUTINT(COLNO, 5);	29
.BR
######################OUTINT(SERIALNO, 8);	30
.BR
######################OUTIMAGE;	31
.BR
########END;	32
.BR
###END;	33
##END;	34
.BR
##OUTTEXT ("CROSSWORD DIMENSION = ");	35
.BR
##OUTINT (N, 2);	36
.BR
##OUTIMAGE;	37
.BR
END	38\\
.B 2;.PS 58,70;.LM 0;.RM 70;.F;.J
^IN WHICH THE VARIABLE ^^EDGE\\ HAS BEEN USED TO AVOID REPEATED EVALUATION OF ^N+1.  ^DESCRIPTIVE
TEXT HAS BEEN INSERTED BETWEEN THE SYMBOL ^^COMMENT\\ AND THE SUCCEEDING SEMICOLON.  ^A
.index ^^COMMENT\\
COMMENT IS NOT EXECUTED - IT SERVES TO MAKE THE PROGRAM MORE UNDERSTANDABLE.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 10;.TS 10;.NF;.NJ;.I -10
.IF FOA;.NUMBER 31;.PS 80,80;.PAGE;
.ENDIF FOA
^SAMPLE DATA:
.B 1;.I -10
^INPUT:	7
.B 1
_.......#########(Dot '.' denotes space)
_.*.*.*.
_.....*.
_.*..**.
_...*...
_.*...*.
_.......
.B 2;.I -10
^OUTPUT:
.B 1;.LM 10;.NF;.NJ
^^CROSSWORD NUMBERING
  ROW  COL   SER.NO
    1    1        1
    1    3        2
    1    5        3
    1    7        4
    3    1        5
    3    4        6
    4    3        7
    5    1        8
    5    5        9
    6    3       10
    6    4       11
    7    1       12
.B 1
CROSSWORD DIMENSION = 7\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
.IF FOA;.NUMBER 32;.PS 80,80;.PAGE;
.ENDIF FOA
^DISCUSSION
.BR
_----------
.B 1
^THE NEW FEATURES ARE CONSIDERED IN THE ORDER OF THEIR TEXTUAL APPEARANCE:
.B 1;.LM 10;.TS 10;.I -10
LINE NO
.I -10
_-------
.B 1;.I -5
5	^DESCRIPTIVE TEXT MAY BE INSERTED BETWEEN THE KEY WORD ^^COMMENT\\ AND THE
NEXT SEMICOLON.
.B 1;.I -6
11	^WHEN A PIECE OF PROGRAM IS TO BE REPEATED A KNOWN NUMBER OF TIMES
A SECOND TYPE OF ^^FOR\\-STATEMENT MAY BE USED.  ^THIS IS:
.B 1
^^FOR#\\CONTROLLED-VARIABLE := ^^A1 STEP A2 UNTIL A3 DO\\
.BR
####CONTROLLED-STATEMENT
.B 1
WHERE ^^A1, A2, A3\\ ARE ARITHMETIC EXPRESSIONS.  ^HERE THE CONTROLLED-STATEMENT
IS EXECUTED ^N+1 TIMES WITH ^^ROWNO\\ TAKING THE VALUES 0, 1, 2, ....., ^N IN TURN.
.B 1;.I -6
12	^THIS IS AN EXAMPLE OF A MULTIPLE ASSIGNMENT STATEMENT.  ^IT IS EQUIVALENT TO
.index ^^Multiple assignment\\
.B 1;.LM 17;.TS 17;.I -7
^^BEGIN	CWORD[ROWNO+1, 0] := '*';
.BR
CWORD[N+1, ROWNO+1] := CWORD[ROWNO+1, 0];
.BR
CWORD[ROWNO, N+1] := CWORD[N+1, ROWNO+1];
.BR
CWORD[0,ROWNO] := CWORD[ROWNO, N+1];
.B 1;.I -7
END\\
.B 1;.LM 10;.TS 10
BUT IS MORE READABLE.
.B 1;.I -6
15	^^INIMAGE\\
.BR
WHICH SKIPS TO THE BEGINNING OF THE NEXT INPUT LINE.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -9
.IF FOA;.NUMBER 33;.PS 80,80;.PAGE;
.ENDIF FOA
23-25	^^OR\\ AND ^^AND\\
.index ^^OR\\
.index ^^AND\\
.BR
WHICH ARE USED IN CONDITIONS.
.B 1
^^C1 OR C2 OR _... OR CN\\
.B 1
IS ^^TRUE\\ IF ANY OF THE CONDITIONS ^^C1, C2, _... CN\\ ARE ^^TRUE\\, OTHERWISE IT IS ^^FALSE\\.
.B 1
^^C1 AND C2 _... AND CN\\
.B 1
IS ^^TRUE\\ ONLY IF EVERY ONE OF THE CONDITIONS ^C1 THROUGH ^^CN\\ IS ^^TRUE\\.
.B 1
^IN THE GIVEN EXAMPLE WHICH IS OF THE TYPE
.B 1
(^^C1 AND C2) OR (C3 AND C4)\\
.B 1
PARANTHESES HAVE BEEN USED TO GROUP ^^C1 AND C2\\ AS ONE SUBEXPRESSION,
^^C3 AND C4\\ AS ANOTHER.  ^PARENTHESES CAN BE USED TO GROUP EXPRESSIONS OF ANY TYPE.
.B 2;.I -9
27-32	^A GROUPING OF THE FORM
.B 1
^^BEGIN\\##STATEMENT;
.BR
#######STATEMENT;
.BR
#######STATEMENT;
.B 1
^^END\\
.B 1
IS CALLED A COMPOUND-STATEMENT AND IS YET ANOTHER FORM OF STATEMENT.  ^IF
.index ^^Compound statement\\
THE ^^FOR\\-STATEMENT OF LINES 14-18 HAD BEEN WRITTEN:
.B 1
^^FOR#ROWNO := 1 STEP 1 UNTIL N DO
.BR
####INIMAGE;
.BR
####FOR COLNO := .....\\
.B 1
THEN ONLY THE INPUT STATEMENT ^^INIMAGE\\ WOULD BE EXECUTED ^N TIMES BEFORE PASSING ON TO THE NEXT STATEMENT
.B 1
####^^FOR COLNO :=\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 34;.PS 80,80;.PAGE;
.ENDIF FOA
^WHEN THE PROGRAM IS EXECUTED, THE ^^RTS\\ INITIALLY CREATES ONLY THE
OUTER BLOCK.  ^A VISUALISATION OF THIS OUTER BLOCK IS:
.B 2;.LM 20;.NF;.NJ
_-------------------
_!                 !
_! ^^RTS\\ INFORMATION !
_!                 !
_-------------------
_!                 !
_! ^^INTEGER  N   0  !
_! INTEGER EDGE 0  !
_!                 !
_-------------------
_!                 !\\
.I -15
CURRENT -----> ! ^^N := ININT      !\\
.I -15
STATEMENT      ! ^^EDGE := N + 1   !
_! <INNER BLOCK>   !
_! OUTTEXT ...     !
_! OUTINT (N,2)    !
_! OUTIMAGE        !
_-------------------\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.F;.J
^AT THIS STAGE ONLY THE TWO VARIABLES DECLARED IN THE OUTER BLOCK, I.E. ^N AND
^^EDGE\\ EXIST.  ^THE INNER BLOCK IS CREATED WHEN THE THIRD STATEMENT IS ENCOUNTERED.  ^ASSUMING
AN INPUT VALUE FOR ^N OF 7, THE NEW SNAPSHOT WHEN THE INNER BLOCK HAS BEEN CREATED IS:
.B 2;.LM 20;.RM 75;.TS 20;.NF;.NJ
.index ^^RTS block\\
_-------------------
_!                 !
_! ^^RTS\\ INFORMATION !<--------
_!                 !        !
_-------------------        !  ^^TEXTUAL LINK\\
_!                 !        !  TO TEXTUALLY
_! ^^INTEGER  N   7\\  !        !  ENCLOSING BLOCK.
.I -20
OUTER BLOCK         ! ^^INTEGER EDGE 8\\  !        !
_! _....            !        !
_!                 !        !
.I -4
_--->! <^^INNER BLOCK\\>   !        !
.I -4
_!   ! _....            !        !
.I -4
_!   !                 !        !
.I -4
_!   _-------------------        !
.I -4
_!                              !
.I -4
_!                              !
.I -4
_!                              !
.I -4
_!                              !
.I -4
_!   _------------------------   !
.I -4
_!   !            !         !   !
.I -4
_----------^^O      !     O--------\\
_!            !         !
_------------------------
_! ^^INTEGER ROWNO    0   !
_! INTEGER COLNO    0   !\\
.I -20
INNER BLOCK         ! ^^INTEGER SERIALNO 0   !     _-------------------
_! CHARACTER ARRAY CWORD----->!A\\RRAY            !
_!                      !     !CHARACTER        !
_!                      !     !VARIABLES        !
_------------------------     !ALL INITIALIZED  !
_!                      !     !TO "BINARY ZERO" !
.I -20
CURRENT  ---------->!_....                  !     _-------------------
.I -20
STATEMENT           !                      !
_------------------------

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 35;.PS 80,80;.PAGE;
.ENDIF FOA
^NOTE THAT THE LAYOUT OF ALL BLOCKS IS THE SAME.  ^WE USE DOTS _.... WHERE THE ACTIONS OF
BLOCKS ARE IRRELEVANT TO THE IMMEDIATE POINT AT HAND.
.B 1
^THE BOUNDS OF THE ARRAY ARE GIVEN AS
.B 1;.I 10
^^[#0#:#EDGE,#0#:#EDGE#]\\
.B 1
^^EDGE\\ IS NOT DEFINED IN THE INNER BLOCK ALTHOUGH IT CLEARLY EXISTS AS A PROGRAM
ELEMENT.  ^ACCORDINGLY, THE PRIMITIVE ^BINDING ^RULE FOR FINDING MEANINGS
FOR IDENTIFIERS GIVEN IN SECTION 1 IS MODIFIED TO:
.B 1;.LM 5;.I -5
1.###^LOOK IN THE IMMEDIATE BLOCK HEAD FOR A MATCH.  ^IF FOUND, THEN
THAT IS THE IDENTIFIER WE ARE AFTER.
.B 1;.I -5
.index ^^Textual link\\
2.###^IF NO MATCH IS FOUND, THEN CONTINUE THE SEARCH VIA THE TEXTUAL LINK
TO THE TEXTUALLY SURROUNDING BLOCK AND TRY TO FIND A MATCH THERE.
.B 1;.LM 0
^FOR PROGRAMS WITH MANY NESTED BLOCKS, STEP 2 IS REPEATED UNTIL THE MATCH IS FOUND.
.B 1
^WHEN THE ACTIONS OF THE INNER BLOCK ARE COMPLETED, IT IS DELETED AND
CONTROL RETURNS TO THE OUTER BLOCK RESUMING AT ITS NEXT STATEMENT WHICH IS
.B 1;.I 10
^^OUTTEXT\\#_.....
.B 1
^THE SNAPSHOT AFTER RETURN IS:
.B 1;.LM 15;.TS 15;.NF;.NJ
_-------------------
_! ^^RTS\\ INFORMATION !
_-------------------
_!                 !
_! ^^INTEGER    N  7 !
_! INTEGER EDGE  8 !
_! _....            !
_! <INNER BLOCK\\>   !
.I -15
CURRENT  ----->! ^^OUTTEXT\\         !
.I -15
STATEMENT      ! _....            !
_-------------------

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 36;.PS 80,80;.PAGE;
.ENDIF FOA
^A MORE COMPLETE PICTURE COULD BE GIVEN AS FOLLOWS.  ^ON CREATION OF THE OUTER BLOCK, WE HAVE:
.B 1;.LM 15;.TS 15;.NF;.NJ
_------------------
_!       !        !<---
_------------------   !
_! ^^ININT          !   !
_! INIMAGE        !   !
_! OUTINT         !   !     RTS\\ BLOCK
_! ^^OUTIMAGE       !   !
_! _....           !   !
_------------------   !
                     !
                     !
                     !
                     !
_------------------   !
_!       !        !   !
_!       !  O----------
_!       !        !
_------------------
_! INTEGER  N   0 !
_! INTEGER EDGE 0\\ !        PROGRAM OUTER BLOCK
.I -15
CURRENT  ----->! ^^N := ININT   0 !\\
.I -15
STATEMENT      ! _.....          !
_------------------
.B 1;.LM 0;.RM 70;.F;.J
.index ^^Standard system PROCEDURES\\
WHICH SHOWS THAT THE STANDARD SYSTEM PROCEDURES FOR INPUT AND OUTPUT (MANY MORE
WILL BE GIVEN LATER) ARE FOUND IN THE NORMAL WAY, AND THAT ALL THE USER-DEFINED
BLOCKS COLLAPSE IN THE SAME WAY.  ^WE SHALL NOT USE THIS MORE COMPLETE
SNAPSHOT IN THE FUTURE (JUST TO SAVE SPACE), BUT IT IS AS WELL TO REMEMBER
ITS SIGNIFICANCE.
.SUBTITLE ^^CHAPTER\\ 1.3
.IF FOA;.NUMBER 37;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.F;.J
1.3###^^GEOMETRIC APPLICATIONS\\
.index ^^Plotting\\
.index ^^Graphical applictions\\
.index ^^Diagram\\
.index ^^Figure\\
.index ^^Geometrical application\\
.BR
######_----------------------
.B 1
^AS AN ILLUSTRATION OF HOW ^^SIMULA\\ ALLOWS FOR CONCEPT DESCRIPTION WE TURN TO THE PROBLEM
OF AUTOMATIC DRAWING - WHERE THE PROGRAM DESCRIBES AND GENERATES FIGURES, AND THEIR
PLOTTING IS DONE MECHANICALLY.  (^IT IS BEYOND OUR SCOPE TO DEFINE THE LAST
STAGE).  ^WE CONSIDER THE TASK OF GENERATING THE FOLLOWING FIGURE FOR OUTPUT:
.B 2;.LM 10;.NJ;.NF
         * * * 
     *     *     *
   *       *       *
  *        *        *
 *         *         *
*          *          *
*          *          *
*        * * *        *
*      *   *   *      *
*    *     *     *    *
 * *       *       * *
  *        *        *
   *       *       *
     *     *     *
         * * * 
.B 2;.LM 0;.F;.J
^THE PROGRAM CAN BE DECOMPOSED INTO 4 STAGES:
.B 1;.LM 9;.I -4
1.##CLASSIFICATION
.BR
--------------
.B 1
^WHAT ARE THE COMPONENTS IN THE PROGRAM - SUCH AS POINTS, LINES, CIRCLES?
.B 1;.I -4
2.##GENERATION
.BR
----------
.B 1
^GENERATE REPRESENTATIONS OF THESE COMPONENTS:
.B 1;.LM 11;.NF;.NJ
^L   ^RIGHT LEG
 1
.B 1
^L   ^LEFT LEG
 2
.B 1
^L   ^VERTICAL BAR
 3
.B 1
^C   ^CIRCLE

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.F;.J;.LM 9;.I -4
.IF FOA;.NUMBER 38;.PS 80,80;.PAGE;
.ENDIF FOA
3.##ASSEMBLE THE FIGURES
.BR
--------------------
.B 1
^LINK THE COMPONENTS TOGETHER INTO A FIGURE
.B 1;.NF;.NJ
^^F
 _\
  _\
   >L1--->L2--->L3--->C\\
.B 1;.I -4
4.##OUTPUT
.BR
------
.B 1
^PLOT THE FIGURE.
.B 1;.LM 0;.F;.J;.SP 1
^THE COMPLETE PROGRAM INTRODUCES SEVERAL NEW FEATURES WHICH ARE
INTRODUCED AS NEEDED.
.B 3
.TP 10
^CLASSIFICATION AND GENERATION
.BR
-----------------------------
.B 1
^TO DESCRIBE COMPOUND PATTERNS SUCH AS POINTS, LINES AND CIRCLES,
WE BUILD UPON THE MOST GENERAL CONCEPT WE HAVE MET SO FAR#-#THE
BLOCK.  ^A BLOCK IS A DESCRIPTION OF A STRUCTURE AND IT WRITTEN,
IN GENERAL, BY
.B 1;.I 5
^^BEGIN\\###DECLARATIONS;#ACTIONS;###^^END\\
.B 1
^WHEN A BLOCK INSTANCE IS GENERATED ITS ACTIONS ARE EXECUTED AND
WHEN THEY ARE EXHAUSTED THAT INSTANCE IS DELETED NEVER TO REAPPEAR.
.B 1
^HERE WE HAVE A NEED TO DESCRIBE PATTERNS FOR POINTS, LINES AND
CIRCLES AND CREATE INSTANCES OF THEM WHICH REMAIN AVAILABLE.
^WE NEED THAT ABILITY TO CREATE REPRESENTATIONS OF SEVERAL POINTS,
SEVERAL LINES,#.....#TO BUILD UP THE FIGURE.  ^IT IS ESSENTIAL
THAT ONCE CREATED THEIR STRUCTURES REMAIN AVAILABLE, AND SO THEY
WILL HAVE TO BE GIVEN NAMES SO THAT THEY MAY BE REFERRED TO.
.B 1
.index ^^CLASS\\
.index ^^CLASS (Simple introduction)\\
.index ^^Reference variables (Simple introduction)\\
.index ^^Reference variable\\
.index ^^REF variables, use of (Simple introduction)\\
^THESE ARE ACHIEVED IN ^^SIMULA\\ BY THE ^^CLASS\\ AND ^R^E^FERENCE VARIABLE
CONCEPTS.
.B 1
.IF FOA;.NUMBER 39;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE:
.BR
-------
.B 1
^THE FOLLOWING PROGRAM GENERATES THE REPRESENTATIONS OF TWO POINTS
^R(2,0) AND ^S (WHICH IS DISPLACED FROM ^R BY (-1,2)) AND THE LINE
^L THROUGH ^S WITH LENGTH 2 AND AT AN ANGLE OF 45 DEGREES TO THE
POSITIVE X-AXIS.

.IFNOT FOA;.PG
.ENDIF FOA;
^FIGURE:
.BR
------
.B 2;.LM 5;.NJ;.NF
^^
               Y          *
               _^        *
               !      *
             2 +    *
               !    S
               !
             1 +
               !
    -2   -1    !    1    2
-----+----+----!----+----*----->
               !         R     X
               !
               !\\
               !
               !
               !
.B 3;.LM 0;.RM 70;.F;.J
^PROGRAM
.BR
-------
.B 1;.LM 12;.NF;.NJ;.TS 12,55,59
		LINE#NO.
		--------
.B 1;.I -12
^^BEGIN	CLASS POINT(X,Y); REAL X,Y;		####1
BEGIN ................ END;		####2
CLASS LINE(P,LENGTH,ANGLE); REF(POINT) P;		####3
.I 20
REAL LENGTH, ANGLE;		####4
BEGIN ................ END;		####5
REF(POINT)R,S; REF(LINE)L;		####6
R :- NEW POINT (2,0);		####7
S :- NEW POINT (R.X-1,R.Y+2);		####8
L :- NEW LINE (S,2,45);		####9
_............		###10
.I -12
END			###11
.IF FOA;.NUMBER 40;.PS 80,80;.PAGE;
.ENDIF FOA

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J;.C
^SNAPSHOT IMMEDIATELY BEFORE THE PROGRAM END
.BR;.C
-------------------------------------------
.B 2;.LM 0;.NJ;.NF
^^                                         -------------------
                                         !        !        !
                                    ---->! POINT1 !   PB   !
                                    !    !        !        !
                                    !    -------------------
           -------------------      !    !                 !
           !        !        !      !    ! REAL  X     2   !
           !   PB   !    .   !      !    ! REAL  Y     0   !
           !        !        !      !    !                 !
           -------------------      !    -------------------
           !                 !      !
           ! CLASS POINT     !      !
           ! CLASS LINE      !      !    -------------------
           ! REF (POINT) R .-!-------    !        !        !
           ! REF (POINT) S .-!---------->! POINT2 !   PB   !<---
           ! REF (LINE)  L .-!-------    !        !        !   !
           !                 !      !    -------------------   !
           ! L :- .....      !      !    !                 !   !
           !                 !      !    ! REAL  X     1   !   !
\\CURRENT^^    !                 !      !    ! REAL  Y     2   !   !
       --->! .....           !      !    !                 !   !
\\STATEMENT^^  !                 !      !    -------------------   !
           -------------------      !                          !
                                    !                          !
                                    !    -------------------   !
                                    !    !        !        !   !
                                    ---->! LINE1  !   PB   !   !
                                         !        !        !   !
                                         -------------------   !
                                         !                 !   !
                                         ! REF (POINT) P .-!----
                                         ! REAL LENGTH   2 !
                                         ! REAL ANGLE   45 !
                                         !                 !
                                         -------------------\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
^N.^B.\\##TO SAVE A MULTITUDE OF LINKS, WE HAVE ADOPTED THE
.index ^^RTS info\\
FOLLOWING NOTATION FOR THE ^R^T^S INFORMATION AT THE HEAD OF
EACH BLOCK:
.B 1;.LM 10;.NF;.NJ
------------------------------------
! ^NAME OF THIS ! ^NAME OF TEXTUALLY !
!    BLOCK     !  ENCLOSING BLOCK  !
------------------------------------
.B 1;.I -10
SO THAT
.B 1
------------------------
^^! POINT 1 !    PB\\      !
------------------------
.B 1;.LM 10;.F;.J;.TS 10;.I -10
MEANS:	THIS IS THE FIRST ^^POINT\\ TO BE CREATED, AND THE TEXTUAL
LINK IS TO THE BLOCK NAMED ^P^B, I.E. THE ACTUAL PROGRAM
BLOCK.
.B 1;.LM 0;.RM 70
.IF FOA;.NUMBER 41;.PS 80,80;.PAGE;
.ENDIF FOA
^NOTICE ALSO THE WAY THE PARAMETERS ARE TRANSMITTED.  ^THE ^^REAL\\#(1)
.FN 4
.B 1
-------------
.BR
(1)##^THIS ALSO HOLDS FOR ^^INTEGER, BOOLEAN\\ AND ^^CHARACTER\\
VARIABLES#-#THE SO-CALLED VALUE TYPES.
!
.index ^^Actual parameter, introduction\\
PARAMETERS, A COPY OF THE VALUE OF ACTUAL PARAMETER IS MADE 
LOCAL TO THE OBJECT.  ^THE ^^REF(POINT)\\ VARIABLE IN THE LINE
OBJECT, THE REFERENCE VALUE OF THE ACTUAL PARAMETER (THE OBJECT ^^POINT\\2)
IS COPIED.  ^ANY SUCCEEDING OPERATION ON A PARAMETER WORKS WITH
THESE LOCAL COPIES.

.IFNOT FOA;.PG
.ENDIF FOA;
^DISCUSSION
.BR
----------
.B 1
.index ^^CLASS declaration\\
^THE DECLARATION OF A CLASS MAY TAKE THE FORMS (RATHER SIMPLIFIED):
.B 1;.LM 9;.I -4
1)##^^CLASS A\\ (FORMAL PARAMETERS); SPECIFICATIONS;
.BR
^^BEGIN\\##DECLARATIONS;
.BR
#######ACTIONS;
.BR
^^END\\
.B 1
OR, IF IT HAS NO PARAMETERS,
.B 1;.I -4
2)##^^CLASS B;
.BR
BEGIN\\##DECLARATIONS;
.BR
#######ACTIONS;
.BR
^^END\\
.B 1;.LM 0;.RM 70
^IF THE CLASS HAS PARAMETERS THEN EACH ONE MUST HAVE ITS TYPE
SPECIFIED.  ^THE SPECIFICATIONS MAY BE IN ANY ORDER.  ^INSTANCES
OF THE CLASSES MAY BE GENERATED BY
.B 1;.I 5
.index ^^NEW (Simple introduction)\\
1)##^^NEW A\\ (ACTUAL-PARAMETERS)
.B 1
.index ^^Dynamic memory allocation, introduction\\
^WHERE THE ACTUAL PARAMETERS CORRESPOND IN NUMBER, ORDER AND
TYPE TO THOSE IN THE DECLARATION, OR
.B 1;.I 5
.IF FOA;.NUMBER 42;.PS 80,80;.PAGE;
.ENDIF FOA
2)##^^NEW B\\
.B 1
^WHEN A CLASS INSTANCE (HENCEFORTH "AN OBJECT" FOR DISTINCTION)
IS GENERATED, ITS PARAMETER VALUES ARE TRANSFERRED, ITS ACTIONS
EXECUTED AND THEN CONTROL RETURNS TO ITS PLACE OF GENERATION.
^THEN ITS WHEREABOUTS (A REFERENCE TO IT) MAY BE ASSIGNED SO
.index ^^Accessing\\
THAT THE OBJECT HAS AN IDENTIFICATION AND IT MAY BE ACCESSED.
.B 1
E.G.##IN#^^R#:-#NEW#POINT#(2,0)\\
.B 1
THE REFERENCE VALUE OF THE ^^POINT\\ OBJECT IS ASSIGNED TO ^R AFTER
IT HAS BEEN GENERATED.

.IFNOT FOA;.PG
.ENDIF FOA;
.index ^^Attribute\\
^PARAMETERS AND DECLARATIONS TOGETHER ARE CALLED ATTRIBUTES.
^THE ATTRIBUTES OF AN OBJECT MAY BE ACCESSED FROM INSIDE THE
OBJECT BY THEIR IDENTIFIER.  ^FROM WITHOUT, THE OBJECT MUST BE
NAMED FIRST FOLLOWED BY A SEPARATING DOT ('.') THEN THE ATTRIBUTE, AS
.B 1;.LM 10;.I -5
^^R.X##REAL X\\#-#COORDINATE OF THE ^^POINT R\\
.B 1;.I -5
^^L.P##REF(POINT)\\ QUANTITY, THE POINT OF APPLICATION OF ^L.
.B 1;.LM 0
^NOTE THAT FROM THE PROGRAM BLOCK THERE ARE TWO REFERENCES TO
THE SECOND POINT (^^POINT 2)\\#-#EITHER ^S OR ^L.^P.  ^IT FOLLOWS THAT
THE ATTRIBUTES OF ^S MAY BE REFERRED TO AS
.B 1;.TS 5,10,14,22
	^S.^X	OR	^L.^P.^X,	AND
.BR
.index ^^Access into a CLASS object (Simple introduction)\\
.index ^^Remote accessing\\
	^S.^Y	OR	^L.^P.^Y
.B 1
FROM THE PROGRAM BLOCK.
.B 1
.index ^^Qualification\\
.index ^^Security\\
.IF FOA;.NUMBER 43;.PS 80,80;.PAGE;
.ENDIF FOA
^REFERENCE VARIABLES ARE GIVEN A QUALIFICATION FOR SECURITY
REASONS.  ^FOR EXAMPLE,  IF ^R IS ^^REF(POINT)\\ AND ^L IS ^^REF(LINE)\\
THEN:
.B 1;.LM 10;.I -5
^R.^X##IS VALID AS ^R IS ^^REF(POINT)\\ AND ^^POINT\\ OBJECTS
HAVE AN ATTRIBUTE ^X.  ^FURTHER THE TYPE OF ^R.^X IS ^^REAL.\\
.B 1;.I -5
^L.^P##IS VALID AND IS OF TYPE ^^REF(POINT)\\
.B 1;.LM 0
BUT NEITHER ^R.^P NOR ^L.^X WILL BE VALID BACAUSE ^R CAN NEVER
REFERENCE AN OBJECT HAVING A ^P ATTRIBUTE (AND SIMILARLY FOR
^L.^X).  ^BY DESIGNING ^^SIMULA\\ IN THIS WAY, ILLEGAL ATTEMPTS AT
ACCESSING CAN BE DETECTED AS EARLY AS POSSIBLE#-#I.E. AT
COMPILE TIME.
.B 1
.index ^^Run time error\\
^AT RUN TIME, ERRORS CAN STILL OCCUR#-#FOR EXAMPLE, IF ^R REFERENCES
NO OBJECT (^^NONE\\) AND A REQUEST FOR ^R.^X OCCURS.  ^^NONE\\
.index ^^NONE\\
CLEARLY HAS NO ATTRIBUTES.  ^TO GUARD AGAINST SUCH ERRORS TWO
REFERENCE COMPARATORS == AND =/= ARE A PART OF ^^SIMULA\\.
.B 1;.LM 10;.I -8
^R#==#^S##IS ^^TRUE\\ ONLY IF BOTH ^R AND ^S REFERENCE THE SAME OBJECT,
OR BOTH REFERENCE ^^NONE\\.
.B 1;.LM 0
^THE OPPOSITE HOLDS FOR ^R =/= ^S.
.B 1
^ONE CAN NOW TEST
.B 1;.I 5
^^IF R =/= NONE THEN R.X := ......
.I 15
ELSE OUTTEXT ("R IS CURRENTLY NONE")\\
.B 1
AND USE THE ^^ELSE\\ OPTION TO GIVE A SUITABLE WARNING MESSAGE OR
ALTERNATIVE ACTION.

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 44;.PS 80,80;.PAGE;
.ENDIF FOA
^THE INITIAL VALUE OF ALL ^R^E^F VARIABLES IS ^^NONE\\, I.E. NO OBJECT.
.B 1
^BEFORE PROCEEDING TO OUTLINE THE ASSEMBLY STAGE, WE TAKE TIME
.index ^^PROCEDURE\\
TO INTRODUCE ANOTHER CONCEPT#-#THAT OF A ^^PROCEDURE\\.
.B 1
^A COMMON TASK IN MANIPULATING LINES IS TO ROTATE A LINE THROUGH
A CERTAIN NUMBER OF DEGREES.  ^TO GENERATE A NEW ^^LINE\\ REFERENCED
BY ^L2 WHICH "ROTATES" ^L1 THROUGH SAY 75 DEGREES, WE COULD
WRITE
.B 1;.I 5
^^L2#:-#NEW#LINE(L1.P,L1.LENGTH,L1.ANGLE+75)\\
.B 1
WHICH IS BOTH TEDIOUS TO WRITE AND NOT VERY CLEAR.  ^THE ^^PROCEDURE\\
CONCEPT ENABLES US TO WRITE
.B 1;.I 5
^^L2#:-#L1.ROTATED(75)\\
.B 1
BY DEFINING A SUITABLE ^^PROCEDURE "ROTATED"\\ AS A PART OF THE
.index ^^CLASS body\\
BODY OF ^^CLASS LINE\\.
.B 1
^THE ^^PROCEDURE \\MUST DO THE FOLLOWING:
.B 1;.LM 9;.I -4
1)##GENERATE A NEW ^^LINE\\ OBJECT
.B 1;.I -4
2)##PASS AS PARAMETERS THE ^^POINT\\ AND ^^LENGTH\\ ATTRIBUTES OF
^L1 (IT IS ^L1'S ATTRIBUTE ^^ROTATED\\ SO THESE ARE AVAILABLE
DIRECTLY), AND ADD 75 TO THE ^^ANGLE\\ OF ^L1
.B 1;.I -4
3)##RETURN A REFERENCE TO THE NEW ^^LINE\\ OBJECT
.B 1;.LM 0
.IF FOA;.NUMBER 45;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS LINE \\IS NOW WRITTEN:
.B 1;.LM 9
^^CLASS LINE(P,LENGTH,ANGLE); REF(POINT)P;
.I 20
REAL LENGTH,ANGLE:
.BR
BEGIN REF(LINE) PROCEDURE ROTATED(THETA); REAL THETA;
.I 6
ROTATED :- NEW LINE(P,LENGTH,ANGLE+THETA);
.BR
END\\
.B 1;.LM 0
.index ^^PROCEDURE declaration\\
^THE ^^PROCEDURE\\ CONCEPT ENABLES COMMON ACTION CLUSTERS TO BE
DESIGNED AND TESTED AS COMPONENTS, AND REPLACES MANY ACTIONS
BY A SINGLE IDENTIFIER.  ^THIS MAKES PROGRAMS EASY TO DECOMPOSE
AND CONSIDERABLY MORE READABLE.

.IFNOT FOA;.PG
.ENDIF FOA;
^PROCEDURES ARE USED IN TWO SENSES:##EITHER AS STATEMENTS, SUCH
AS
.B 1;.I 5
^^OUTTEXT("THE HIGHEST VALUE = ")\\
.B 1
OR###^^INIMAGE\\  ,
.B 1
OR AS VALUES, AS IN
.B 1;.I 5
^^PRESENT#:=#ININT\\
.B 1
OR###^^L2#:-#L1.ROTATED(90)\\
.B 1;.LM 0;.RM 70
^IN BOTH CASES, THE PROCEDURE IS ACTIVATED BY THE OCCURRENCE OF
ITS IDENTIFIER AND ACTUAL PARAMETERS (IF ANY).  ^IF THE PROCEDURE
IS TO BE USED AS A STATEMENT THEN ITS DECLARATION HAS THE FORM
.B 1;.I 5
.index ^^PROCEDURE body\\
^^PROCEDURE\\ IDENTIFIER; ^^PROCEDURE\\-BODY
.B 1
OR##^^PROCEDURE\\ IDENTIFIER PARAMETER-DESCRIPTION
.I 10
^^PROCEDURE\\-BODY
.B 1
WHERE A ^^PROCEDURE\\-BODY IS A STATEMENT.
.B 1
.IF FOA;.NUMBER 46;.PS 80,80;.PAGE;
.ENDIF FOA
^IF THE ^^PROCEDURE\\ IS TO RETURN A VALUE THEN THE PROCEDURE IS
.index ^^RETURN value from a procedure\\
GIVEN A TYPE AND THE VALUE TO BE RETURNED IS ASSIGNED TO A
SPECIAL VARIABLE OF THAT TYPE BY THE ACTIONS OF THE ^^PROCEDURE\\-BODY.
.B 1
E.G.
.B 1;.I 5
^^REF(LINE)PROCEDURE#ROTATED(THETA);#REAL THETA;
.I 8
ROTATED#:-#NEW#LINE(P,LENGTH,ANGLE+THETA)\\
.B 1
WHERE THE RESULT IS ASSIGNED TO A ^^REF(LINE)\\ VARIABLE "^^ROTATED\\"
INSIDE THE ^^PROCEDURE\\-BODY.
.B 1
.TP 6
.index ^^VALUE parameter transmission, introduction\\
^ON ACTIVATION OF A PROCEDURE, COPIES OF THE VALUES OF THE ACTUAL
PARAMETERS ARE TRANSFERRED TO THE PROCEDURE IF THE "MODES" PART
IS EMPTY (AS HERE).  ^A RATHER DIFFERENT METHOD OF PARAMETER
.index ^^NAME parameter transmission, introduction\\
TRANSMISSION (BY ^^NAME\\) IS ALSO AVAILABLE FOR PROCEDURES AND ITS
USE WILL BE EXPLAINED SHORTLY.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^ASSEMBLE THE FIGURES
.BR
--------------------
.B 1
^THE GROUPING OF THE LINES AND CIRCLES INTO FIGURES IS NOT
TRIVIAL BECAUSE:
.B 1;.LM 9;.I -3
-##FIGURES CAN HAVE A VARIABLE NUMBER OF COMPONENTS
.B 1;.I -3
-##THE TYPE OF COMPONENTS VARIES (IT CAN EITHER BE ^^REF(LINE)
\O\R REF(CIRCLE))\\.
.B 1;.LM 0
.index ^^Stack\\
^ONE NEAT WAY OF ASSEMBLING THE COMPONENTS IS BY USING A STACK.
^IN A STACK, EACH PIECE OF INFORMATION IS STORED ON THE TOP AND
PUSHES PREVIOUS MEMBERS LOWER DOWN.  ^IGNORING THE QUALIFICATION
.IF FOA;.NUMBER 47;.PS 80,80;.PAGE;
.ENDIF FOA
ASPECT FOR THE MOMENT, WE CAN PICTURE A STACK ^S BEFORE AND
AFTER A NEW MEMBER HAS BEEN INSERTED BY:
.B 1
BEFORE
.BR
------
.B 1;.LM 10;.NF;.NJ
        ---       ---
^S !---->!2!------>!1!
        ---       ---
   
      ---
      !3!
      ---
.B 2;.I -10
AFTER
.I -10
-----
.B 1
        ---        ---        ---
^S !---->!3!------->!2!------->!1!
        ---        ---        ---
.B 1;.LM 0;.RM 70;.F;.J
^WHATEVER OBJECT IS STACKED, THE ACTUAL MECHANISM FOR SO DOING
IS THE SAME.  ^IT FOLLOWS THAT WE SHOULD BE ABLE TO ISOLATE
STACKABLE QUALITIES, DEFINE THEM, AND BE ABLE TO BUILD THEM
ONTO OTHER CONCEPTS.  ^THE CONCEPT OF STACKABLE NEEDS ONE REFERENCE
.index ^^List processing (Simple introduction)\\
VARIABLE "^^NEXT\\" TO REFERENCE THE NEXT LOWER MEMBER OF
THE STACK (OR ^^NONE\\ IF THE BOTTOM MEMBER).  ^SO WE CAN BEGIN
WITH THE OUTLINE:
.B 1;.I 5
^^CLASS STACKABLE;
.I 5
BEGIN  REF(?) NEXT; .......... END\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^TO BUILD STACKABILITY INTO INFORMATION CARRYING OBJECTS SUCH
AS ^^LINES\\ AND ^^CIRCLES\\, WE USE A PREFIX NOTATION AND WRITE THEIR
.index ^^Prefix sequence\\
CLASS DECLARATIONS AS:
.B 1;.LM 5;.NF;.NJ
          ^^CLASS STACKABLE ......;
STACKABLE CLASS LINE ...........;
STACKABLE CLASS CIRCLE .........;\\
.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 48;.PS 80,80;.PAGE;
.ENDIF FOA
^NOW ^^LINE\\ AND ^^STACKABLE\\ OBJECTS HAVE THE APPEARANCES:
.B 1;.LM 10;.NF;.NJ
^^        ------------------   ------------------
        !        !       !   !        !       !
        ------------------   ------------------
\\PREFIX^^  * REF ( ? ) NEXT *   * REF ( ? ) NEXT *
        ------------------   ------------------
        !                !
        ! REF (POINT) P  !
\\MAIN^^    !                !
\\PART^^    ! REAL LENGTH    !
        !                !
        ! REAL ANGLE     !
        ------------------
.B 1
            LINE OBJECT       STACKABLE OBJECT\\
.B 1;.LM 0;.RM 70;.F;.J
^IN OTHER WORDS, ^^LINE\\ OBJECTS NOW HAVE THE CONCEPT OF STACKABILITY
BUILT INTO THEM.
.B 1
^WE ARE NOW IN A POSITION TO RESOLVE THE QUESTION OF THE QUALIFICATION
OF ^^NEXT\\.  ^CLEARLY, IF WE HAVE A STACK THEN EACH OBJECT
IN THE STACK MUST HAVE A ^^STACKABLE\\ PART OR ELSE IT COULD NOT
BE INSERTED.  ^IF WE DEFINE ^^NEXT\\ TO HAVE THE QUALIFICATION
^^REF(STACKABLE)\\, WE ARE THEN SURE THAT EACH VARIABLE "^^NEXT\\" IN
THE STACK CHAIN WILL REFERENCE EITHER ^^NONE\\ OR ELSE AN OBJECT
WHICH IS AT LEAST "^^STACKABLE\\ SIZED".  ^THIS DOES MEAN THAT WE HAVE
TO RELAX OUR STRICT RULES OF REFERENCING TO ALLOW THE ^^NEXT\\
VARIABLES TO REFERENCE ANY MEMBER OF A CLASS PREFIXED BY ^^STACKABLE\\.
^LET US SEE HOW THIS WORKS.  ^SUPPOSE WE HAVE:
.B 1;.LM 15;.I -6
^^BEGIN REF(STACKABLE)ST;
.BR
REF(LINE)L;
.BR
L#:-#NEW LINE(NEW POINT(0,0), 1,0);
.BR
ST#:-#L;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^THE ASSIGNMENTS ARE VALID BUT THE RANGE OF DIRECT ATTRIBUTE
ACCESSING IS RESTRICTED TO THE QUALIFICATION LEVEL OF THE
REFERENCE VARIABLE CONCERNED.
.IF FOA;.NUMBER 49;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.LM 10;.NF;.NJ
^^
       ----------------------------
       !             !            !
       ----------------------------
ST---->! REF (STACKABLE) NEXT     !
       ----------------------------
       ! REF (POINT) P         ---!------>
       ! REAL      LENGTH     1.0 !
L ---->! REAL      ANGLE      0.0 !
       ----------------------------\\
.B 1;.LM 0;.RM 70;.F;.J
^THUS
.B 1;.I 5
^^ST.NEXT
.I 5
L.ANGLE
.I 5
L.LENGTH
.I 5
L.P\\
.B 1
ARE VALID.  ^SO ALSO IS ^^L.NEXT\\ AS, IF ^L REFERENCES AN OBJECT,
IT MUST BE AT LEAST "^^LINE\\ SIZED" AND THUS CONTAIN A ^^STACKABLE\\
PART AND SO AN ATTRIBUTE ^^NEXT\\.  ^BUT WE CAN NOT ALLOW
.B 1
#######^^ST.LENGTH#########ST.ANGLE###########ST.P\\
.B 1
SO EASILY, AS ^S^T MAY ALSO REFERENCE ^^STACKABLE\\ OR ^^CIRCLE\\ OBJECTS
WHICH HAVE NO SUCH PROPERTIES.
.B 1
^ON THE OTHER HAND WE DO NOT WISH TO DISALLOW ACCESSING THE
^^LINE\\ OBJECT AT THE ^^LINE\\ LEVEL VIA ^S^T#-#WHAT WE DO IS TO MAKE
IT MANIFEST THAT WE ARE ENTERING A ^^LINE\\ OBJECT BY REQUIRING
THE USER TO WRITE
.B 1;.I 5
^^ST QUA LINE.P
.I 5
ST QUA LINE.LENGTH
.I 5
ST QUA LINE.ANGLE\\
.B 1
^THIS ENABLES COMPILE TIME CHECKING:##"^^ST QUA LINE\\"#-#CAN ^S^T
REFERENCE A ^^LINE \\OBJECT ?  ^YES, AS ITS QUALIFICATION IS ^^REF(STACKABLE)\\
AND ^^STACKABLE\\ PREFIXES ^^LINE\\.  ^^ST QUA LINE.P\\#-#HAVE ^^LINE OBJECTS
AN ATTRIBUTE "^P" ? ^YES.\\

.IFNOT FOA;.PG
.ENDIF FOA;
^BEFORE WRITING THE ACTUAL PROGRAM, WE TAKE TIME TO INTRODUCE THE
CONCEPT OF CALL BY ^^NAME\\.  ^SUPPOSE WE WISH TO INSERT A ^^LINE\\ OBJECT
(^L) AND ^^CIRCLE\\ OBJECT (^C) INTO A STACK (^S^T).
.B 1
.IF FOA;.NUMBER 50;.PS 80,80;.PAGE;
.ENDIF FOA
^THE CODING IS:
.B 1;.LM 5
^^L.NEXT := ST;
.BR
ST :- L;
.BR
COMMENT ***NOW L IS INSERTED*** ;
.BR
C.NEXT :- ST;
.BR
ST :- C;
.BR
COMMENT ***NOW C IS INSERTED***;\\
.B 1;.LM 0
^SNAPSHOTS BEFORE AND AFTER THE INSERTION OF ^L ARE:
.B 1
BEFORE
.BR
------
.B 2;.LM 5;.NJ;.NF
^^               ----------
               !        !
      ST .---->!     .  !
               !        !
               ----------
               !        !
               !        !<--- Z
               !        !
               ----------
                      
       ----------
       !        !
L ---->!     .  !
       !        !
       ----------
       !        !
       !        !
       !        !
       ----------\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
AFTER
.BR
-----
.B 1;.LM 5;.NJ;.NF
^^                  ----------
                  !        !
             ---->!     .  !
      ST .   !    !        !
         !   !    ----------
         !   !    !        !
         !   !    !        !<--- Z
         !   !    !        !
         !   !    ----------
         V   !
       ----------
       !     !  !
       !     .  !
       !        !
       ----------
       !        !
L ---->!        !
       !        !
       ----------\\
.B 1;.LM 0;.F;.J
.LM 0
^THE CODING IS A REPEAT EXCEPT FOR A PARAMETER SAYING WHICH
OBJECT IS TO BE INSERTED.  ^THE ^^PROCEDURE\\ CONCEPT ENABLES US
TO GIVE ^^CLASS STACKABLE\\ PROCEDURE ATTRIBUTE "^^INTO\\", AND THEN
WE CAN WRITE
.B 1;.LM 5
^^L.INTO (ST)
.BR
C.INTO (ST)\\
.B 1;.LM 0
FOR THE SAME EFFECT.  ^THIS IS NOT ONLY MORE CONCISE, BUT MORE
READABLE THAN BEFORE.  ^THIS TIME WE HAVE TO BE RATHER CAREFUL
.IF FOA;.NUMBER 51;.PS 80,80;.PAGE;
.ENDIF FOA
ABOUT HOW THE PARAMETER IS TRANSMITTED.  ^IT IS THE PURPOSE OF
THE PROCEDURE TO ACTUALLY ALTER THE VALUE OF THE VARIABLE ^S^T
ITSELF TO REFERENCE NOT ITS CURRENT VALUE ^Z BUT THE NEW ENTRY.
^IN OTHER WORDS, WE DO NOT WANT TO OPERATE UPON THE VALUE OF ^S^T
(ITS OBJECT REFERENCE) BUT MANIPULATE VARIABLE ^S^T ITSELF.  ^THIS
CAN BE DONE BY SPECIFYING THE PARAMETER TO BE CALLED BY ^^NAME\\,
AS FOLLOWS.  ^THE NEW DEFINITION OF ^^CLASS STACKABLE\\ IS:
.B 1;.LM 5;.NF;.NJ
^^CLASS STACKABLE;
BEGIN  REF(STACKABLE)NEXT;
       PROCEDURE INTO(H); NAME H; REF(STACKABLE)H;
       BEGIN  NEXT :- H;
              H :- THIS STACKABLE;
       END;
END\\
.B 1;.LM 0;.F;.J
(^THE NEW KEYWORD ^^THIS\\ REFERS TO THE "LOCAL OBJECT", I.E. ^L
IF WE CALL ^L.^^INTO\\, AND ^C IF WE CALL ^^C.INTO\\).
.IFNOT FOA;.PG
.ENDIF FOA
^IT IS WORTHWHILE SPENDING EXTRA TIME TO SHOW HOW THE ^^NAME\\
PARAMETER MECHANISM WORKS.  ^CONSIDER THE PROGRAM SKELETON:
.B 1;.LM 5;.NF;.NJ
^^BEGIN  CLASS STACKABLE...........;
         STACKABLE CLASS LINE......;
         REF(LINE)L,Z;
         REF(STACKABLE)ST;
         ..........
         COMMENT ***L AND Z ARE NOW GENERATED, AND Z
                    SET "INTO" ST*** ;
         L.INTO(ST)
END\\
.B 1;.LM 0;.RM 70;.F;.J
.TP 10
.IF FOA;.NUMBER 52;.PS 80,80;.PAGE;
.ENDIF FOA
^A SNAPSHOT BEFORE THE CALL IS MADE IS:
.B 2;.LM 5;.RM 70;.NF;.NJ
^^----------------------
! PB      !          !
----------------------
! CLASS STACKABLE    !
! CLASS LINE         !      -----------
! REF (STACKABLE) ST-!----->! L1 ! PB !
!                    !      !    !    !
! REF (LINE) Z-------!----->-----------
! REF (LINE) L-------!---   !   NEXT  !
----------------------  !   !   INTO  !
                        !   -----------
                        !
                        !   -----------
                        --->! L2 ! PB !
                            -----------
                            !   NEXT  !
                            !   INTO  !
                            -----------\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^AFTER ACTIVATION OF THE PROCEDURE, WE HAVE:
.B 1;.LM 5
^^----------------------      --------------
! PB      !          ! ---->!  L1  ! PB  !
!         !          !      !      !     !
---------------------- ! !->--------------
! CLASS STACKABLE    ! ! !  ! NEXT  NONE !
! CLASS LINE         ! ! !  !    INTO    !
! REF (STACKABLE) ST-!-- !  --------------
! REF (LINE) Z-------!----
! REF (LINE) L-------!--    --------------
!      ...           ! !--->!  L2  ! PB  !<---
!    L.INTO(ST)      !      --------------   !
----------------------      ! NEXT  NONE !   !
             _^              !    INTO    !   !
             !              --------------   !
             !                               !
             !              --------------   !
             !              !     !   .--!----
             !              --------------
             ---------------!--H         !
                            ! NEXT :- H  !
                            ! H :- THIS  !
                            --------------\\
.B 1;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 53;.PS 80,80;.PAGE;
.ENDIF FOA
^NOTE THE TEXTUAL LINKS OF THE VARIOUS BLOCKS#-#THOSE OF THE
^^LINK\\ OBJECTS ARE TO THE PROGRAM BLOCK, THAT OF THE PROCEDURE
BLOCK IS TO THE OBJECT REFERENCED BY ^L (I.E. ^L2).  ^H IS NOT
GIVEN A VALUE BUT A LINK BACK TO THE ACTUAL PARAMETER.  ^EVERY
OCCURRENCE OF ^H MEANS "RE-EVALUATE THE CORRESPONDING QUANTITY".
.B 1
^FOR THE FIRST STATEMENT:
.B 1;.I 5
^^NEXT :- H\\
.B 1
^^NEXT\\ IS FOUND BY THE NORMAL BINDING RULE IN THE BLOCK ^L2 (IT
IS ^L'S ^^NEXT\\) AND THIS IS SET TO REFERENCE ^H.  ^BUT ^H IS CALLED
BY ^^NAME\\, SO THE ACTUAL PARAMETER CORRESPONDING TO ^H IS LOOKED
UP AND ITS CURRENT VALUE RETURNED.  ^THIS IS ASSIGNED TO ^^NEXT\\.
.B 1
^THE NEXT STATEMENT
.B 1;.I 5
^^H :- THIS STACKABLE\\
.B 1
ASSIGNS A REFERENCE TO THE "NEAREST" ^^STACKABLE\\ OBJECT (THE ONE
TO WHICH THE PROCEDURE IS TEXTUALLY LINKED) TO ^H.  ^BUT AGAIN ^H
IS CALLED BY ^^NAME\\ AND SO THIS MEANS ASSIGNING TO ^S^T THE OBJECT
^L2.

.IFNOT FOA;.PG
.ENDIF FOA;
^THESE STATEMENTS ARE THEN EQUIVALENT TO
.B 1;.I 5
^^NEXT :- ST;
.I 5
ST :- THIS STACKABLE;\\
.B 1
^ANOTHER WAY OF EXPLAINING CALL BY ^^NAME\\ IS TO SAY THAT
EVERY OCCURRENCE OF THE FORMAL PARAMETER IS TEXTUALLY REPLACED BY
THE ACTUAL PARAMETER IN THE PROCEDURE INSTANCE.
.B 2
.IF FOA;.NUMBER 54;.PS 80,80;.PAGE;
.ENDIF FOA
^THE PROGRAM:
.BR
-----------
.B 1
^WE AIM TO PRODUCE THE FOLLOWING STRUCTURE PRIOR TO PLOTTING:
.B 1;.LM 10;.NF;.NJ
^^             --------
DRAW ------->! NEXT-!----
             --------   !
             !      !   !
             !      !   !
        L1   --------   !
                        !
                        !
             --------<---
             ! NEXT-!----
             --------   !
             !      !   !
             !      !   !
        L2   --------   !
                        !
                        !
             --------<---
             ! NEXT-!----
             --------   !
             !      !   !
             !      !   !
        L3   --------   !
                        !
                        !
             --------<---
             ! NEXT !
             --------
             !      !
             !      !
        C    --------\\
.B 1;.LM 0;.RM 70;.F;.J
^THE FOLLOWING CONCEPTS ARE NEEDED
.B 1;.LM 5
^^STACKABLE
.BR
POINT
.BR
LINE
.BR
CIRCLE\\
.B 1;.LM 0
-#ONCE THESE HAVE BEEN DEFINED WE CAN PROCEED WITH OBJECT
GENERATION.

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 55;.PS 80,80;.PAGE;
.ENDIF FOA
^OUTLINES OF THE CLASSES ARE
.B 1;.LM 5;.NF;.NJ
^^CLASS STACKABLE;
BEGIN  REF(STACKABLE)NEXT;
       PROCEDURE INTO ............;
END;
.B 1
STACKABLE CLASS LINE(P,LENGTH,ANGLE);
          REF(POINT)P; REAL LENGTH,ANGLE;
BEGIN .............................. END;
.B 1
STACKABLE CLASS CIRCLE(CP,RAD);
          REF(POINT)CP; REAL RAD;
BEGIN .............................. END;
.B 1
CLASS POINT(X,Y); REAL X,Y;
BEGIN ................ END;\\
.B 2;.LM 0;.RM 70;.F;.J
^THE COMPONENTS ARE:
.B 2;.LM 10;.NJ;.NF
^^
         * * * 
     *     *     *
   *       *       *
  *        *        *
 *         * L       *
*          *   3      *
*          *          *   C
*        * * *        *
* L    *   *   * L    *
*  2 *     *     * 1  *
 * *       *       * *
  *        *        *
   *       *       *
     *     *     *
         * * * \\
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 56;.PS 80,80;.PAGE;
.ENDIF FOA
AND ONE PIECE OF CODING TO GENERATE THEM COULD BE:
.B 1;.LM 5
^^ORIGO :- NEW POINT(0,0);
.BR
L1 :- NEW LINE(ORIGO,1,-45);
.BR
L2 :- NEW LINE(ORIGO,1,225);
.BR
L3 :- NEW LINE(NEW POINT(0,-1),2,90);
.BR
C##:- NEW CIRCLE(ORIGO,1);\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^ALTHOUGH THIS CODING IS QUITE TERSE, WE CAN IN FACT MAKE IT
MUCH MORE READABLE BY USE OF PROCEDURES LOCAL TO CLASSES ^^POINT\\
AND ^^LINE\\.  ^DEFINING SUITABLE PROCEDURES, WE CAN REPLACE THE
ABOVE CODING BY:
.B 1;.LM 5
^^ORIGO :- NEW POINT(0,0);
.BR
L1 :- ORIGO.RAY(1,-45);
.BR
L2 :- L1.ROTATED(-90);
.BR
L3 :- NEW POINT(0,-1).RAY(2,90);
.BR
C##:- ORIGO.RING(1);\\
.B 1;.LM 0
^THE CLEARNESS OF THIS PIECE OF PROGRAM MEANS THAT IT IS NOT
ONLY EASY TO READ AND UNDERSTAND, BUT ALSO EASY TO WRITE.  ^FROM
A WIDER POINT OF VIEW THIS IS IDEAL BECAUSE IT INVITES DRAUGHTSMEN
WHO ARE NOT (EXPERT) PROGRAMMERS TO USE THE CONCEPTS WE HAVE
DEVELOPED.
.B 1
.IF FOA;.NUMBER 57;.PS 80,80;.PAGE;
.ENDIF FOA
^WE EXPLAIN ONLY ONE OF THE PROCEDURES ^^RAY, ROTATED, RING\\ AS
THEY ARE FAIRLY SIMILAR.  ^LET US CHOOSE "^^RING\\".
.B 1;.I 5
^^ORIGO.RING(1)\\
.B 1
HAS REPLACED THE ORIGINAL
.B 1;.I 5
.index ^^NEW (Example)\\
^^NEW CIRCLE(ORIGO,1)\\
.B 1
AND MUST, THEREFORE, ACHIEVE THE SAME EFFECTS.  ^THESE ARE:
.B 1;.LM 9;.I -4
1.##GENERATE A NEW ^^CIRCLE \\OBJECT
.B 1;.I -4
2.##SET IN ^^ORIGO\\ AND 1 AS ACTUAL PARAMETER VALUES
.B 1;.I -4
3.##RETURN A REFERENCE TO THE NEW ^^CIRCLE\\ OBJECT.
.B 1;.LM 0
^THE PROCEDURE IS WRITTEN LOCAL TO CLASS ^^POINT\\ AND IS AVAILABLE
.index ^^Dot (.), for remote accessing into class objects\\
THROUGH THE DOT NOTATION.  ^THE DECLARATION OF ^^CLASS POINT\\ BECOMES:
.B 1;.LM 5
^^CLASS POINT(X,Y); REAL X,Y;
.BR
BEGIN  REF(CIRCLE) PROCEDURE RING(R); REAL R;
.BR
#############RING :- NEW CIRCLE(THIS POINT,R);
.BR
END\\
.B 1;.LM 0
^THIS PROCEDURE IS GIVEN THE TYPE ^^REF(CIRCLE)\\ AS IT IS TO RETURN
A NEW ^^CIRCLE\\ OBJECT AS VALUE.  ^THE TYPE OF THE CALLING EXPRESSION
.B 1;.I 5
^^ORIGO.RING(1)\\
.B 1
IS ^^REF(CIRCLE)\\.  ^^THIS POINT\\ IS A REFERENCE TO THE ^^POINT\\ OBJECT
TO WHICH THE ^^PROCEDURE RING\\ IS AN ATTRIBUTE, IN THIS CASE ^^ORIGO\\.

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 58;.PS 80,80;.PAGE;
.ENDIF FOA
^THE WHOLE PROGRAM IS:
.B 2;.I 63
LINE#NO.
.I 63
--------
.B 1;.LM 0;.TS 7,13,20,26,66;.NF;.NJ
^^BEGIN	CLASS PLOTTING;		1
	BEGIN	CLASS STACKABLE;	2
		BEGIN	REF(STACKABLE)NEXT;	3
			PROCEDURE INTO(H); NAME H; REF(STACKABLE)H;	4
			BEGIN  NEXT :- H;	5
				H :- THIS STACKABLE;	6
			END ***OF INTO*** ;	7
		END *STACKABLE*** ;	8
.B 1
		CLASS POINT(X,Y); REAL X,Y;	9
.TS 7,13,20,26,65
		BEGIN  REF(LINE) PROCEDURE RAY(L,A); REAL L,A;	10
			  RAY :- NEW LINE(THIS POINT,L,A);	11
			REF(CIRCLE) PROCEDURE RING(R); REAL R;	12
			  RING :- NEW CIRCLE(THIS POINT,R);	13
		END ***OF POINT*** ;	14
.B 1
   STACKABLE CLASS LINE(P,LENGTH,ANGLE); REF(POINT)P;	15
				         REAL LENGTH,ANGLE;	16
		BEGIN	REF(LINE) PROCEDURE ROTATED(THETA);	17
				REAL THETA;	18
			ROTATED :- NEW LINE(P,LENGTH,ANGLE+THETA);	19
		      IF P == NONE OR LENGTH <= 0 THEN	20
			BEGIN  OUTTEXT("BAD POINT");	21
				OUTIMAGE;	22
			END;		23
		END ***OF LINE*** ;	34

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.NF;.NJ;.TS 65
.IF FOA;.NUMBER 59;.PS 80,80;.PAGE;
.ENDIF FOA
STACKABLE CLASS CIRCLE(CP,RADIUS); REF(POINT)CP;	25
                                   REAL RADIUS;	26
          BEGIN  IF CP == NONE OR RADIUS <= 0 THEN	27
                    BEGIN  OUTTEXT("BAD CIRCLE");	38
                           OUTIMAGE;	29
                    END;	30
          END ***OF CIRCLE*** ;	31
.B 1
          PROCEDURE PLOT ......;	32
.B 1
          REF(STACKABLE)DRAW;	33
          REF(POINT)ORIGO;	34
          ORIGO :- NEW POINT(0,0)	35
  END ***OF PLOTTING*** ;	36
.B 1
PLOTTING BEGIN  REF(LINE)L1,L2,L3,	37
                REF(CIRCLE)C;	38
GENERATE:       INSPECT ORIGO DO	39
                BEGIN  L1 :- RAY(1,-45);	40
                       L2 :- L1.ROTATED(-90);	41
                       L3 :- NEW POINT(0,-1).RAY(2,90);	42
                        C :- RING(1)	43
                END;	44
ASSEMBLE:        C.INTO(DRAW);	45
                L1.INTO(DRAW);	46
                L2.INTO(DRAW);	47
                L3.INTO(DRAW);	48
                PLOT;	49
        END ***OF PREFIXED BLOCK*** ;	50
END	51\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 60;.PS 80,80;.PAGE;
.ENDIF FOA
^DISCUSSION
.BR
----------
.B 2
LINE NO
.BR
-------
.B 1;.LM 10;.TS 10;.I -9
1-36	^DEFINES THE CONCEPTS NEEDED FOR THE PLOTTING OF FIGURES
AS ^^CLASS PLOTTING\\.
.B 1
-#STACKING###LINES#2-8
.BR
-#POINTS#####LINES 9-14
.BR
-#LINES######LINES 15-24
.BR
-#CIRCLES####LINES 25-31
.BR
-#PLOT#######LINE 32
.B 1
AND CONTAINS AS ACTIONS THE GENERATION OF THE ORIGIN
LINE 35.  ^NOTE THAT ^^LINE\\ AND ^^CIRCLE\\ ARE PREFIXED BY
^^STACKABLE\\ AND THAT THEIR DEFINITIONS CONTAIN ACTIONS
WHICH WILL GIVE A WARNING MESSAGE IF THE OBJECTS UNDER
GENERATION ARE BADLY DESCRIBED.
.B 1;.I -9
.index ^^Prefixed block\\
37-50	^^PLOTTING\\ IS USED TO PREFIX A BLOCK.  ^WHEN THIS BLOCK
IS ENTERED ALL THE CONCEPTS OF ^^PLOTTING\\ ARE AVAILABLE
FOR USE, AND THE USER OPERATES IN A BUILT IN ENVIRONMENT.
.B 1;.I -9
39-44	^THE CONSTRUCTION
.B 1;.I 5
^^INSPECT X DO\\ STATEMENT
.index ^^INSPECT\\
.B 1
IS ANOTHER METHOD OF ACCESSING OBJECTS.  ^IF ^^X#==#NONE\\
THE STATEMENT IS SKIPPED, OTHERWISE AN ATTRIBUTE ^A OF
THE OBJECT ^X IS AVAILABLE WITHOUT THE NEED TO WRITE ^^X.A.\\
.B 1
^HERE ^^RING(1)\\ IS EQUIVALENT TO ^^ORIGO.RING(1)\\ WRITTEN OUTSIDE
THIS CONSTRUCTION AS ^^ORIGO\\ HAS AN ATTRIBUTE ^^RING\\.
^ON THE OTHER HAND, AS ^^ORIGO\\ HAS NO ATTRIBUTE ^L1, ^L1
STANDS FOR THE ^^REF(LINE)\\ QUANTITY DECLARED IN LINE 37.
.B 1;.I -7
49	^THE PLOTTING PROCEDURE IS CALLED AND THE APPROPRIATE
OUTPUT DISPLAYED.
.SUBTITLE ^^CHAPTER\\ 1.4
.IF FOA;.NUMBER 61;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.index ^^Simulation capabilities of SIMULA (Introduction)\\
1.4##^^SIMULATION OF A QUEUING SITUATION\\
.BR
#####---------------------------------
.B 1
^WE CAN BEST MOTIVATE THE NEED FOR, AND USES OF, SIMULATION BY
MEANS OF AN EXAMPLE.  ^CONSIDER THE CASE OF A GARAGE OWNER WHO
.index ^^Car wash simulation\\
HAS INSTALLED AN AUTOMATIC CAR WASH WHICH SERVICES CARS ONE AT
A TIME.  ^AS HIS EFFICIENTLY RUN SERVICE GETS MORE AND MORE POPULAR,
THE OWNER IS FACED WITH A DILEMMA.  ^AS MORE CUSTOMERS USE
THE CAR WASH THEIR AVERAGE WAITING TIME WILL TEND TO INCREASE AND
THE SERVICE BECOMES LESS ATTRACTIVE.  ^THE OWNER MAY NOW REACT IN
TWO WAYS#-#BUILD FURTHER CAR WASHES WHICH WILL KEEP THE PRESENT
CUSTOMERS HAPPY (AND PROBABLY ATTRACT MORE), OR DO NOTHING AND
LET THE CUSTOMER FLOW STABILIZE ITSELF AT A LOWER LEVEL.  ^AS THE
BUILDING OF FURTHER CAR WASHES ENTAILS CONSIDERABLE EXPENSE, THIS
IS NOT A DECISION TO BE TAKEN LIGHTLY AND DEMANDS SOME INVESTIGATION.
.B 1
^IT IS AT THIS POINT THAT SIMULATION CAN HELP.  ^SIMULATION IS A
TECHNIQUE FOR REPRESENTING A DYNAMIC SYSTEM BY A MODEL AND EXPERIMENTING
WITH THE MODEL IN ORDER TO GAIN INFORMATION ABOUT
THE SYSTEM.  ^THE APPROACH IS USEFUL IF THE SYSTEM IS NOT
AMENABLE TO ANALYTIC TECHNIQUES AND DIRECT EXPERIMENTATION WITH THE SYSTEM
(SUCH AS BUILDING THE CAR WASHES AND SEEING WHAT HAPPENS) IS
IMPRACTICAL.
.B 3
^CAR ^WASH ^SIMULATION
.BR
-------------------
.B 1
^SUPPOSE THE CAR WASH SERVICES CARS ONE AT A TIME AND EACH SERVICE
TAKES 10 MINUTES.  ^WHEN A CAR ARRIVES IT GOES STRAIGHT INTO
THE CAR WASH IF THE LATTER IS STANDING IDLE, OTHERWISE IT MUST
WAIT IN THE QUEUE.  ^AS LONG AS CARS ARE WAITING, THE CAR WASH
IS IN CONTINUOUS OPERATION SERVING ON THE FIRST-COME, FIRST-SERVED
PRINCIPLE.
.B 1
.IF FOA;.NUMBER 62;.PS 80,80;.PAGE;
.ENDIF FOA
^IF THE ARRIVAL TIMES OF THE CARS HAVE BEEN RECORDED FOR ONE DAY
THEN A VERY SIMPLE MODEL IS CAPABLE OF REPRODUCING THE ESSENTIAL
ASPECTS OF THE SYSTEM ON THAT DAY.  ^THIS MODEL CAN GENERATE DATA
WHICH DESCRIBES THE PERFORMANCE OF THE INSTALLATION#-#SUCH AS
USE OF EQUIPMENT, AVERAGE NUMBER OF WAITING CARS, TIME SPENT BY
EACH CAR.
.B 1
^THE OPERATION OF THE SYSTEM CONSISTS OF TWO CRITICAL EVENTS:
.B 1;.LM 9;.I -4
1.##^^THE ARRIVAL OF A CAR\\.  ^THE ARRIVAL TIME IS NOTED.  ^IF THE
CAR WASH IS IDLE A TEN MINUTE SERVICE STARTS AT ONCE.
^OTHERWISE THE CAR GOES TO THE END OF THE QUEUE.
.B 1;.I -4
2.##^^END OF SERVICE\\.  ^THE ELAPSED TIME FOR THAT CAR IS NOTED
AND THE CAR LEAVES THE SYSTEM.  ^IF CARS ARE WAITING, THE
FIRST ONE IN THE QUEUE IS SERVED AND ANOTHER 10 MINUTE
SERVICE IS STARTED.  ^OTHERWISE THE MACHINE BECOMES IDLE.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0
^THE CAR WASH, OF COURSE, STARTS IN THE IDLE STATE AND AWAITS
THE FIRST ARRIVAL.
.B 1
.index ^^Trace of a model\\
^IN ORDER TO UNDERSTAND THE MODEL BETTER, WE CONSIDER A TRACE
OF HISTORY OF THE MODEL OVER A SHORT PERIOD WHEN CARS ARRIVE
AT THE TIMES (IN MINUTES) 6, 10, 13, 28, 42, 43, 48.  ^THE STATE
OF THE MODEL ONLY CHANGES AT THE TWO CRITICAL TIMES NOTED ABOVE:
WHEN A CAR ARRIVES, WHEN A SERVICE IS FINISHED.  ^ACCORDINGLY WE
.IF FOA;.NUMBER 63;.PS 80,80;.PAGE;
.ENDIF FOA
NEED ONLY TRACE AT THESE TIMES.
.B 3;.C
^CAR WASH TRACE
.BR;.C
--------------
.B 2;.LM 5;.TS 15
TIME	EVENT
.BR
----	-----
.B 1;.LM 6;.TS 10
#0	THE CAR WASH AWAITS THE FIRST ARRIVAL
.BR
#6	CAR 1 ARRIVES AND GOES INTO THE CAR WASH
.BR
10	CAR 2 ARRIVES AND MUST WAIT
.BR
13	CAR 3 ARRIVES AND WAITS IN THE QUEUE
.BR
16	CAR 1 LEAVES THE SYSTEM
.BR
	CAR 2 IS SERVED
.BR
26	CAR 2 LEAVES THE SYSTEM
.BR
	CAR 3 ENTERS THE CAR WASH
.BR
28	CAR 4 ARRIVES AND WAITS IN THE QUEUE
.BR
36	CAR 3 LEAVES THE SYSTEM
.BR
	CAR 4 ENTERS THE CAR WASH
.BR
42	CAR 5 ARRIVES AND MUST WAIT
.BR
43	CAR 6 ARRIVES AND MUST WAIT
.BR
46	CAR 4 LEAVES THE SYSTEM
.BR
	CAR 5 ENTERS THE CAR WASH
.BR
48	CAR 7 ARRIVES AND MUST WAIT
.BR
56	CAR 5 LEAVES THE SYSTEM
.BR
	CAR 6 ENTERS THE CAR WASH
.BR
66	CAR 6 LEAVES THE SYSTEM
.BR
	CAR 7 ENTERS THE CAR WASH
.BR
76	CAR 7 LEAVES THE SYSTEM

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 64;.PS 80,80;.PAGE;
.ENDIF FOA
^THE DATA RECORDED BY THE CARS IS:
.B 2;.LM 5;.TS 19,23,27,31,35,39,43
^CAR	#1	#2	#3	#4	#5	#6	#7
.B 1
^ARRIVAL	#6	10	13	28	42	43	48
.B 1
^DEPARTURE	16	26	36	47	56	66	76
.B 1
^ELAPSED TIME	10	16	23	18	14	23	28
.B 1
^AVERAGE TIME SPENT IS##132/7#=#18.8#MINUTES
.B 1;.LM 0;.RM 70
^BY COMPARING THESE RESULTS WITH THOSE FROM THE ACTUAL SYSTEM,
IT CAN BE VERIFIED THAT THE MODEL IS SUFFICIENTLY ACCURATE.
^THE MANAGEMENT WISHES TO REDUCE THE AVERAGE TIME SPENT.  ^THE
MODEL CAN BE USED AGAIN, THIS TIME WITH TWO CAR WASHES OPERATING
ON THE SAME DATA.  ^WE ADD THE DECISION RULE THAT MACHINE 1
SHOULD BE USED IF BOTH ARE IDLE.  ^THE RESULTS OF THE TRACE ARE:
.B 2;.LM 5;.TS 19,23,27,31,35,39,43
^CAR	#1	#2	#3	#4	#5	#6	#7
.B 1
^ARRIVAL	#6	10	13	28	42	43	48
.B 1
^DEPARTURE	16	20	26	38	52	53	62
.B 1
^ELAPSED TIME	10	10	13	10	10	10	14
.B 1
^SERVED BY
.BR
MACHINE	#1	#2	#1	#1	#1	#2	#1
.B 1
^AVERAGE TIME SPENT IS##77/7#=#11 MINUTES
.B 1;.LM 0;.RM 70
.IF FOA;.NUMBER 65;.PS 80,80;.PAGE;
.ENDIF FOA
^FOR THIS SAMPLE, THEN, THE AVERAGE TIME SPENT WAITING IN THE
QUEUE PRIOR TO SERVICE IS REDUCED FROM NEARLY 9 MINUTES TO 1
MINUTE BY THE BUILDING OF AN EXTRA CAR WASH.  ^NOTE HOW IMPORTANT
IT IS TO HAVE BOTH MODELS WORKING ON EXACTLY THE SAME DATA.
.B 1
^CLEARLY NO MANAGEMENT SHOULD BASE ITS DECISIONS UPON SUCH A
SMALL SAMPLE.  ^TO ARRIVE AT BETTER ESTIMATES IT IS NECESSARY
TO SIMULATE THE SYSTEM FOR SEVERAL DAYS.  ^IF THE NECESSARY DATA
CANNOT BE COLLECTED, IT MAY BE APPROPRIATE TO USE A STATISTICAL
MODEL TO REPRESENT THE ARRIVAL OF THE CARS.
(^Moreover THE CHARACTERISTICS OF THE CAR ARRIVAL PROCESS - I.E. THE
CUSTOMER BEHAVIOR - MAY VARY WITH THE SERVICE CAPACITY AS WELL AS WITH
OTHER FUTURE CHANGES IN THE CAR WASHING MARKET).

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.index ^^SIMULATION, a SIMULA CLASS (Introduction)\\
.index ^^CLASS SIMULATION\\
^THE ^^CLASS SIMULATION\\
.BR
--------------------
.B 1
^^SIMULA\\ IS PROVIDED WITH A PREDEFINED SYSTEM ^^CLASS SIMULATION\\,
.index ^^Active\\
WHICH CONTAINS ALL THE NECESSARY CONCEPTS FOR QUEUES AND ACTIVE
.index ^^Passive\\
AND PASSIVE COMPONENTS.
.B 1
^WHEN THE IDENTIFIER ^^SIMULATION\\ IS USED TO PREFIX A BLOCK THESE
CONCEPTS BECOME AVAILABLE TO THE USER.  (^THE DETAILS ARE NOT
GIVEN HERE).
.B 1
^THERE ARE THREE ^^CLASSES\\ WITHIN ^^SIMULATION\\ OF PRIME IMPORTANCE:
.B 1;.LM 17;.TS 14,17;.I -12
.index ^^PROCESS (Introduction)\\
.index ^^CLASS PROCESS\\
^^PROCESS\\	-	WHICH IS USED TO PREFIX CLASSES WHOSE OBJECTS
HAVE ACTIVE AND PASSIVE PHASES.
.B 1;.I -12
.index ^^CLASS LINK in SIMSET\\
^^LINK\\	-	WHICH PREFIXES CLASSES WHOSE OBJECTS ARE TO BE
PLACED IN, AND REMOVED FROM, QUEUES.
.B 1;.I -12
.index ^^CLASS HEAD\\
^^HEAD\\	-	WHICH SERVES AS THE HEAD OF A QUEUE
.B 1;.LM 6;.I -6
^N.^B.##^^PROCESS\\ IS ITSELF PREFIXED BY ^^LINK\\, SO THAT ^^PROCESS\\
OBJECTS HAVE THE QUEUE MEMBERSHIP ATTRIBUTES.
.B 3;.LM 0
.IF FOA;.NUMBER 66;.PS 80,80;.PAGE;
.ENDIF FOA
^THE PROGRAM FOR ONE CAR WASH
.BR
----------------------------
.B 1
^ONE CAN VIEW THE SYSTEM WITH THE CARS AS PASSIVE OBJECTS BEING
PUSHED THROUGH THE SYSTEM BY THE CAR WASH.  ^THE OUTLINE OF
^^CLASS CAR\\ IS
.B 1;.LM 5;.NF;.NJ
^^LINK CLASS CAR (NUMBER); INTEGER NUMBER;
BEGIN\\  RECORD ENTRY TIME;
       GO INTO QUEUE;
       ^I^F CAR WASH IDLE ^^THEN ACTIVATE\\ CAR WASH;
^^END\\
.B 1;.LM 0;.RM 70;.F;.J
^PREFIXING THE ^^CLASS\\ WITH ^^LINK\\ GIVES EACH ^^CAR\\ OBJECT THE ABILITY
TO BE PLACED IN A QUEUE.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^HAVING RECORDED THE ENTRY TIME, THE ^C^A^R OBJECT GOES IN AT THE
END OF THE QUEUE.  (^IF THE CAR WASH IS IDLE THEN THIS MEANS THAT
THIS ^C^A^R IS THE FIRST MEMBER OF THE QUEUE).  ^IF THE CAR WASH IS
IDLE IT IS ACTIVATED (WHEREUPON IT SERVICES THE FIRST MEMBER IN
THE QUEUE), IF THE CAR WASH IS NOT IDLE THEN THIS ^C^A^R AWAITS
ITS TURN.
.B 1;.LM 5;.NF;.NJ
^^PROCESS CLASS WASH (QUEUE); REF(HEAD)QUEUE;
BEGIN
SERVE:\\  TAKE THE FIRST CAR OUT OF THE QUEUE;
        SERVICE IT FOR TEN MINUTES;
        RECORD THE SERVICED CAR'S EXIT TIME;
        SEND THE CAR OUT OF THE SYSTEM;
        ^I^F THE QUEUE IS EMPTY ^^THEN PASSIVATE\\;
        ^^GOTO SERVE;\\
^^END\\
.B 1;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 67;.PS 80,80;.PAGE;
.ENDIF FOA
^BY PREFIXING ^^CLASS WASH\\ WITH "^^PROCESS"\\, ^^WASH\\ OBJECTS ARE GIVEN
THE ABILITY TO BE ACTIVE COMPONENTS IN THE ^^SIMULATION\\.  ^THE
INITIALLY IDLE ^^WASH\\ OBJECT IS ACTIVATED BY THE FIRST CAR.
.B 1
^THE ACTIVE CYCLE OF A CAR WASH STARTS BY TAKING THE FIRST ^C^A^R
OUT OF THE QUEUE.  ^AFTER A TEN MINUTE PAUSE, THE SERVICED ^C^A^R
HAS ITS EXIT TIME RECORDED (THE PRESENT SIMULATION TIME) AND
IS DESPATCHED FROM THE SYSTEM.  ^IF THE QUEUE IS NOT EMPTY, THESE
ACTIONS ARE REPEATED (^^GO TO SERVE\\), OTHERWISE THE MACHINE BECOMES
IDLE (^^PASSIVATE\\) AND IS ACTIVATED BY THE NEXT ^^CAR\\'S ARRIVAL,
WHEREUPON THE CYCLE STARTS AGAIN.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
.IF FOA;.NUMBER 68;.PS 80,80;.PAGE;
.ENDIF FOA
^THE COMPLETE PROGRAM IS:
.B 1;.I 63
LINE#NO.
.I 63
--------
.B 1;.NF;.NJ;.TS 7,14,21,66
^^SIMULATION			1
BEGIN	LINK CLASS CAR (NUMBER); INTEGER NUMBER	2
	BEGIN	INTEGER INAT;	3
		INAT := TIME;	4
		INTO(CARWASH.QUEUE);	5
		IF CARWASH.IDLE THEN ACTIVATE CARWASH;	6
	END ***OF CAR*** ;	7
	PROCESS CLASS WASH(QUEUE); REF(HEAD)QUEUE;	8
	BEGIN	REF(CAR)SERVED;	9
.TS 7,14,21,65
	SERVE:	SERVED :- QUEUE.FIRST	10
		SERVED.OUT;	11
		HOLD(10);	12
		INSPECT SERVED DO	13
		BEGIN	OUTINT(NUMBER, 10);	14
			OUTINT(INAT, 10); OUTINT(TIME, 10);	15
			OUTINT(TIME-INAT, 10);	16
			OUTIMAGE;	17
		END;		18
		SERVED :- NONE;	19
		IF QUEUE.EMPTY THEN PASSIVATE;	20
		GOTO SERVE	21
	END ***OF WASH***;	22
.IF FOA;.NUMBER 69;.PS 80,80;.PAGE;
.ENDIF FOA
	REF(WASH)CARWASH;	23
	INTEGER I,J,U;	24
	CARWASH :- NEW WASH(NEW HEAD);	25
	U := ININT;		26
	J := ININT;		27
	OUTTEXT("       SIMULATION OF ONE CAR WASH");	28
	OUTIMAGE;		29
	OUTTEXT("   CAR NO.    INTIME   OUTTIME  ELAPSED TIME");	30
	FOR I := 1 STEP 1 UNTIL J DO	31
	BEGIN	NEW CAR(I);	32
		HOLD(POISSON(12,U));	33
	END;			34
	HOLD(10000);		35
END\\				36
.B 3;.LM 0

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 70;.PS 80,80;.PAGE;
.ENDIF FOA
^SAMPLE INPUT:
.BR
------------
.B 1
3#######100
.B 3;.LM 0
^SEGMENT OF OUTPUT:
.BR
-----------------
.B 2;.LM 0;.RM 70;.F;.J;.C
^^SIMULATION OF ONE CAR WASH\\
.BR;.C
--------------------------
.B 2;.TS 5,14,22,31
	^^CAR NO.	INTIME	OUTTIME	ELAPSED TIME\\
.B 1;.LM 8;.TS 15,24,36;.NF;.NJ
 1	  0	 10	10
 2	 14	 24	10
 3	 29	 39	10
 4	 37	 49	12
 5	 50	 60	10
 6	 67	 77	10
 7	 81	 91	10
 8	#96	106	10
 9	108	118	10
10	121	131	10
11	131	141	10
12	142	152	10
13	154	164	10
14	163	174	11
15	180	190	10
16	186	200	14
17	194	210	16
18	208	220	12
19	218	230	12
20	233	243	10
21	252	262	10
22	256	272	16
23	263	282	19
24	273	292	19
25	287	302	15
.B 3;.LM 0;.RM 70;.F;.J

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 71;.PS 80,80;.PAGE;
.ENDIF FOA
^DISCUSSION:
.BR
----------
.B 2;.LM 5
^LINE
.BR
----
.B 1;.LM 15;.TS 15;.I -10
##1	^THE PROGRAM BLOCK IS PREFIXED BY ^^CLASS SIMULATION\\
WHICH GIVES THE PROGRAMMER THE PREDEFINED CONCEPTS
OF QUEUES, AND ^^PROCESS\\ OBJECTS WHICH CAN BE ACTIVE
OR PASSIVE.
.B 1;.I -10
2-36	^THE USER-DEFINED PROGRAM
.B 1;.I -10
2-7	^^CLASS CAR\\ IS DEFINED.  ^EACH ^C^A^R IS DISTINGUISHED
BY ITS ^^NUMBER\\.  ^ON GENERATION OF A ^^CAR\\
.B 1;.I -10
##3	^THE ENTRY TIME IS RECORDED.  "^^TIME\\" IS A SYSTEM
DEFINED PROCEDURE RETURNING THE CURRENT SYSTEM TIME.
.B 1;.I -10
##4	^THE ^^CAR\\ ENTERS THE QUEUE AS LAST MEMBER.  ^^INTO\\
IS A PROCEDURE PROPERTY OF ALL ^^LINK\\ OBJECTS.
.B 1;.I -10
##5	^IF THE CAR WASH IS IDLE THEN IT IS ACTIVATED.
^^IDLE\\ IS ANOTHER SYSTEM DEFINED PROCEDURE, LOCAL TO ALL
^^PROCESS\\ OBJECTS.
.B 1
^THIS IS THE LAST ACTION OF A ^^CAR\\ OBJECT, THEREAFTER IT
IS PUSHED THROUGH THE SYSTEM BY THE ^^WASH\\.
.B 1;.I -10
8-22	^^CLASS WASH\\ IS DEFINED.
.B 1;.I -10
##9	^^SERVED\\ IS USED TO REFERENCE THE CURRENTLY SERVICED CAR.
.B 1;.I -10
10-11	^WHEN THE CAR WASH IS MADE ACTIVE IT STARTS TO SERVE
THE NEXT CAR,  ^^SERVED\\ IS SET TO REFERENCE THE NEXT CANDIDATE
FOR SERVICE AND THAT CAR IS REMOVED FROM THE QUEUE.
.B 1;.I -10
#12	^^HOLD(T)\\ IS A CALL ON A SYSTEM PROCEDURE WHICH SUSPENDS
THE ACTIONS OF THE CAR WASH (IN THIS CASE) FOR A LENGTH
OF TIME ^T.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -10
.IF FOA;.NUMBER 72;.PS 80,80;.PAGE;
.ENDIF FOA
13-18	^THE CAR WASH IS ACTIVE AGAIN, 10 MINUTES LATER.  ^THE
RELEVANT DATA IS OUTPUT.
.B 1;.I -10
#19	^THE ONLY REFERENCE TO THE ^^CAR SERVED\\ IS LOST#-#IT
DISAPPEARS FROM THE SIMULATION.
.B 1;.I -10
#20	^IF THE QUEUE IS EMPTY, THE CAR WASH BECOMES IDLE
(PASSIVATES ITSELF).  ^IT WILL ONLY BECOME ACTIVE
ON COMMAND FROM THE NEXT CAR.
.B 1;.I -10
#21	^THE ACTIONS ARE REPEATED.
.B 1;.I -10
#25	^^A WASH\\ OBJECT IS GENERATED AND REFERENCED BY ^^CARWASH\\.
^IT HAS A ^^NEW HEAD\\ AS PARAMETER (WHICH SERVES TO HOLD
THE WAITING ^^CAR\\ OBJECTS).
.B 1;.I -10
27-30	^N, THE NUMBER OF ^^CAR\\ OBJECTS TO BE GENERATED, IS READ
IN, AND SUITABLE TEXT HEADINGS ARE OUTPUT.
.B 1;.I -10
31-34	^J NEW ^^CAR\\ OBJECTS ARE GENERATED AND AUTOMATICALLY
ENTER THE QUEUE.  ^IN BETWEEN THE GENERATION OF SUCCESSIVE
OBJECTS, THE PROGRAM HOLDS ITSELF, "REAPPEARING"
AFTER A TIME DELAY TAKEN FROM A ^^POISSON\\ DISTRIBUTION.
^THE STANDARD RANDOM DRAWING PROCEDURES AVAILABLE IN
^^SIMULA\\ ARE FULLY DISCUSSED IN ^APPENDIX ^B.
.B 1;.I -10
#35	^HAVING GENERATED THE LAST CAR, THE PROGRAM SUSPENDS
ITSELF FOR A SUFFICIENTLY LONG TIME TO MAKE SURE THAT
THEY HAVE ALL BEEN SERVICED.
.ST ^^CHAPTER 2\\
.IF FOA;.NUMBER 73;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J;.SP 1;.C
^^CHAPTER#2##THE#SYNTAX#AND#SEMANTICS#OF#SIMULA\\
.BR;.C
---------------------------------------------
.SUBTITLE ^^CHAPTER\\ 2.1
.B 3
.index ^^Language used in this manual\\
.index ^^Metalanguage in this manual\\
.index ^^Notation used in this manual\\
.index ^^Syntactical description language in this manual\\
.index ^^Formalism of syntax description in this manual\\
.index ^^Syntax\\
2.1##^^METHOD OF SYNTAX SPECIFICATION\\
.BR
#####------------------------------
.B 1
^WHEN A ^^SIMULA\\ CONSTRUCTION AND ALL ITS VARIANTS CAN NOT BE
ECONOMICALLY DESCRIBED IN WORDS, ITS EXACT RANGE WILL BE
SHOWN USING A SYSTEM OF NOTATION WHICH IS STANDARD THROUGHOUT
^PART 2.
.B 1
^THE NOTATION IS NOT IN ITSELF A PART OF ^^SIMULA\\, NOR RESTRICTED
SOLELY TO ^^SIMULA\\.  ^IT MAY BE USED TO DESCRIBE THE SYNTAX (OR
ALLOWABLE CONSTRUCTIONS) OF ANY PROGRAMMING LANGUAGE, AND PROVIDES
A COMPACT, VISUALLY CLEAR AND PRECISE EXPLANATION OF THE
GENERAL PATTERNS THAT THE LANGUAGE PERMITS.  ^IT IS IMPORTANT
TO REALISE THAT IT DOES NOT DESCRIBE THE MEANING OF THESE CONSTRUCTIONS
.index ^^Semantics\\
(THEIR SEMANTICS), ONLY THEIR STRUCTURE.  ^IN OTHER WORDS,
IT INDICATES:
.B 1;.LM 9;.I -3
-##THE ORDER IN WHICH LANGUAGE ELEMENTS MAY OR MUST BE COMBINED
WITH EACH OTHER,
.B 1;.I -3
-##THE PUNCTUATION THAT IS REQUIRED, AND
.B 1;.I -3
-##THE FULL RANGE OF OPTIONS.
.B 1;.LM 0
^NO SUCH CONVENIENT SHORTHAND IS YET AVAILABLE FOR THE SEMANTICS,
SO THAT INTERPRETATION OF A LEGAL CONSTRUCTION HAS TO BE
DESCRIBED IN WORDS.
.B 1
.index ^^Basic symbol\\
^WE BEGIN BY NOTING THAT VARIOUS PATTERNS OF BASIC SYMBOLS
CONTINUALLY RECUR IN ^^SIMULA\\.  ^INSTEAD OF REPEATING THE LISTING OF
THE BASIC SYMBOLS EACH TIME,  THEY ARE FIRST GROUPED TOGETHER
.index ^^Syntactic variable\\
AS A NAMED SYNTACTIC VARIABLE, AND FROM THEN ON WE NEED USE ONLY
.IF FOA;.NUMBER 74;.PS 80,80;.PAGE;
.ENDIF FOA
THAT NAME.  ^THE IDEA EXTENDS ITSELF THAT FURTHER SYNTACTIC
VARIABLES MAY NOW BE DEFINED IN TERMS OF THOSE ALREADY DEFINED AND
POSSIBLY BASIC SYMBOLS.
.B 1
.index ^^Special character\\
^THE ^^SIMULA\\ BASIC SYMBOLS ARE REPRESENTED BY SPECIAL CHARACTERS,
SUCH AS
.B 1;.I 5
+#######/#######)#######;#######_^
.B 1
BY COMBINATIONS OF SPECIAL CHARACTERS, SUCH AS
.B 1;.I 5
:-######**######=/=
.B 1
.index ^^Key word\\
AND BY KEY WORDS IN CAPITAL LETTERS, SUCH AS
.B 1;.I 5
^^PROCEDURE####CLASS####REAL####BEGIN\\

.IFNOT FOA;.PG
.ENDIF FOA;
^WHEN WE DEFINE A SYNTACTIC VARIABLE, ITS NAME WILL USUALLY BE
WRITTEN IN LOWER CASE LETTERS FOR DISTINCTION:
.B 1;.I 5
E.G####BLOCK####STATEMENT####DIGIT
.B 1
^A CERTAIN AMBIGUITY CAN ARISE WHEN THE NAME OF A SYNTACTIC VARIABLE
CONSISTS OF TWO WORDS, SUCH AS
.B 1;.I 5
PREFIXED BLOCK
.B 1
.index ^^Syntactic unit\\
^TO ENSURE THAT THESE ARE INTERPRETED AS ONE SYNTACTIC UNIT AND
NOT FOR EXAMPLE, AN OCCURRENCE OF A SYNTACTIC VARIABLE NAMED
"PREFIXED" FOLLOWED BY A SYNTACTIC VARIABLE NAMED "BLOCK", A
HYPHEN IS INSERTED BETWEEN THE WORDS, AS:
.B 1;.I 5
PREFIXED-BLOCK
.B 1
.IF FOA;.NUMBER 75;.PS 80,80;.PAGE;
.ENDIF FOA
^IN CERTAIN CASES, WHEN A BASIC SYMBOL IS AN INTEGRAL PART OF
A SYNTACTIC VARIABLE, IT IS CLEARER TO USE UPPER-CASE LETTERS.
^AGAIN, WE AVOID POSSIBLE AMBIGUITIES BY FOLLOWING THE UPPER-CASE
LETTERS BY A HYPHEN:
.B 1;.I 5
E.G.####^F^O^R-STATEMENT#####^^GOTO\\-STATEMENT
.B 1
^WE NOW GIVE TWO EXAMPLES TO SHOW THE UNIQUENESS OF INTERPRETATIONS
USING THIS TECHNIQUE:
.B 1;.LM 9;.I -4
1.##^^IF BOOLEAN\\-EXPRESSION ^^THEN\\
.BR
DENOTES AN OCCURRENCE OF THE BASIC SYMBOL "^I^F" FOLLOWED
BY A "^^BOOLEAN\\-EXPRESSION" FOLLOWED BY AN OCCURRENCE OF
THE BASIC SYMBOL "^^THEN\\".
.B 1;.I -4
2.##^^REF(CLASS\\-IDENTIFIER)
.BR
DENOTES AN OCCURRENCE OF THE BASIC SYMBOL "^R^E^F" FOLLOWED
BY AN OCCURRENCE OF THE LEFT PARENTHESIS "(" FOLLOWED BY
A "^^CLASS\\-IDENTIFIER" FOLLOWED BY AN OCCURRENCE OF THE RIGHT
PARENTHESIS ")".  ^THE SEPARATION BETWEEN "^R^E^F" AND "("
OCCURS BECAUSE IF A BASIC SYMBOL IS A KEY WORD IT MAY ONLY
BE COMPOSED OF LETTERS.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0
^BEARING THESE IN MIND, THE FOLLOWING RULES EXPLAIN THE USE OF
THE NOTATION AS APPLIED TO ^^SIMULA\\.
.B 1;.LM 9;.I -4

.IF FOA;.NUMBER 76;.PS 80,80;.PAGE;
.ENDIF FOA
1.##^A SYNTACTIC VARIABLE IS A GENERAL CLASS OF ELEMENTS IN
^^SIMULA\\.  ^THE NAME OF THE SYNTACTIC VARIABLE MUST CONSIST
OF:
.B 1;.LM 13;.I -4
^A.##LOWER-CASE LETTERS
.BR
LOWER-CASE LETTERS SEPARATED BY HYPHENS
.BR
LOWER-CASE LETTERS FOLLOWED BY A DIGIT
.B 1
E.G.###IDENTIFIER
.BR
#######COMPOUND-STATEMENT
.BR
#######IDENTIFIERL
.BR
#######SIMPLE-OBJECT-EXPRESSION
.B 1;.I -4
^B.##A COMBINATION OF UPPER-CASE LETTERS AND LOWER-CASE
LETTERS.  ^THERE MUST BE ONE PORTION OF ALL UPPER-CASE
LETTERS AND AT LEAST ONE PORTION OF ALL LOWER-CASE
LETTERS SEPARATED, ONE FROM ANOTHER, BY HYPHENS:
.B 1
E.G.#####^^PROCEDURE\\-STATEMENT
.B 1;.LM 9
^ALL SUCH UNITS USED IN THIS SECTION ARE DEFINED EITHER FORMALLY
USING THIS NOTATION OR ELSE IN WORDS.
.B 1;.LM 9;.I -4

.index ^^Basic symbol\\
.IF FOA;.NUMBER 77;.PS 80,80;.PAGE;
.ENDIF FOA
2.##^A BASIC SYMBOL DENOTES AN OCCURRENCE OF THE CHARACTERS
REPRESENTED.  ^A BASIC SYMBOL IS EITHER A KEY WORD OR
ELSE ONE OR MORE SPECIAL CHARACTERS
.B 1
E.G.###^^BEGIN####END\\
.BR
#########+######=/=
.B 1
^N.^B.##^WHEN A BASIC SYMBOL CONSISTS OF MORE THAN ONE
CHARACTER NO INTERVENING SPACES MAY APPEAR.
.B 1
^THUS, FOR EXAMPLE,
.B 1;.I 5
^^BEG#IN####=/#=\\
.B 1
ARE BOTH FAULTY REPRESENTATIONS.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -4

.index ^^Syntactic unit\\
.IF FOA;.NUMBER 78;.PS 80,80;.PAGE;
.ENDIF FOA
3.##^THE TERM SYNTACTIC UNIT, WHICH IS USED IN SUBSEQUENT RULES,
IS DEFINED BY
.B 1;.LM 13;.I -4
^A.##A SINGLE SYNTACTIC VARIABLE OR BASIC SYMBOL, OR
.B 1;.I -4
^B.##ANY COLLECTION OF SYNTACTIC VARIABLES, BASIC SYMBOLS,
SYNTAX-LANGUAGE SYMBOLS (THE SYMBOLS [,#], #######,...
WHOSE USES ARE DEFINED IN SUBSEQUENT RULES) SURROUNDED
BY BRACES OR BRACKETS.
.B 1;.LM 9
^EXAMPLES:
.B 1;.LM 15
DIGIT#LETTER
.B 1
[DIGIT]
.BR
[LETTER]
.B 1
DIGIT
.B 1
DIGIT#...
.B 1;.LM 9;.I 8
**##**
.I -4
4.##^BRACES **####** ARE USED AS GROUP MARKERS.
.I 8
**##**
.index ^^Braces\\
.B 1
^EXAMPLE:##THE DEFINITION OF AN OBJECT-RELATION IS
.B 1
OBJECT-RELATION
.BR
---------------
.B 1;.LM 13;.NJ;.NF
^^                          **    **
                          *  IN  *\\
SIMPLE-OBJECT-EXPRESSION **      ** ^^CLASS\\-IDENTIFIER
                          *  ^^IS\\  *
                          **    **
.B 1;.LM 9;.F;.J
^THE VERTICAL STACKING OF SYNTACTIC UNITS INDICATES THE
RANGE OF AVAILABLE CHOICES OF WHICH EXACTLY ONE MUST BE
TAKEN.  ^THE EXAMPLE SHOWS THAT IN AN "OBJECT-RELATION",
A "SIMPLE-OBJECT-EXPRESSION" MUST BE FOLLOWED BY THE LITERAL
OCCURRENCE OF EITHER "^I^N" OF "^I^S" (BUT NOT BOTH) AND THEN
BY A "^^CLASS\\-IDENTIFIER".

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 9;.I -4
.IF FOA;.NUMBER 80;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Alternatives\\
.index ^^Vertical stroke (|)\\
5.##^THE EXCLAMATION POINT##_!##INDICATES ALTERNATIVES.
.B 1
^EXAMPLE:##THE DEFINITION OF A DIGIT IS
.B 1
DIGIT
.BR
-----
.I 10
0!1!2!3!4!5!6!7!8!9
.B 1
^THIS HAS THE SAME INTERPRETATION AS
.B 1;.LM 13;.NJ;.NF
 ** **
 * 0 *
 * 1 *
 * 2 *
 * 3 *
** 4 **
 * 5 *
 * 6 *
 * 7 *
 * 8 *
 * 9 *
 ** **
.B 1;.LM 9;.F;.J
BUT SAVES CONSIDERABLE SPACE.  ^BOTH THE METHODS, RULE 4
(**####**) AND RULE 5 (#_!#) ARE USED IN THIS MANUAL TO DISPLAY
ALTERNATIVES.  ^WE WILL USUALLY STICK TO THE USE OF BRACES
AS THIS NOTATION IS CLEARER, AND USE#_!#ONLY WHEN THE FORMER
NOTATION TAKES UP TOO MUCH SPACE.
.B 1;.LM 9;.I -4
.IF FOA;.NUMBER 81;.PS 80,80;.PAGE;
.ENDIF FOA

.index ^^Square bracket ([ and ])\\
6.##^SQUARE BRACKETS [#] DENOTE OPTIONS.  ^ANYTHING ENCLOSED
IN SQUARE BRACKETS MAY APPEAR ONCE OR NOT AT ALL.
.B 1
^EXAMPLES:##THE DEFINITION OF A ^^CLASS\\-DECLARATION IS
.B 1
^^CLASS\\-DECLARATION
.BR
-----------------
.B 1;.I 5
[^^CLASS\\-IDENTIFIER]#MAIN-PART
.B 1
^THIS DENOTES A SYNTACTIC UNIT "MAIN-PART" OPTIONALLY PRECEDED BY
A "^^CLASS\\-IDENTIFIER".
.B 1
^IF ALTERNATIVES ARE ALSO OPTIONAL, WE USE VERTICAL STACKING
WITHIN THE SQUARE BRACKETS.

.IFNOT FOA;.PG
.ENDIF FOA;
^THUS THE MUCH SIMPLIFIED VERSION OF AN ACTIVATION-STATEMENT
.B 1;.LM 13;.NF;.NJ
^^
ACTIVATE######[#BEFORE#Y##############]
##############[#AT\\#TIME#[^^PRIOR\\]#######]
.B 1;.LM 9;.F;.J
WOULD ALLOW THE FOLLOWING ALTERNATIVES:
.B 1;.LM 13
^^ACTIVATE X
.BR
ACTIVATE X BEFORE Y
.BR
ACTIVATE X AT\\ TIME
.BR
^^ACTIVATE X AT\\ TIME ^^PRIOR\\
.B 1;.LM 9;.I -4
.IF FOA;.NUMBER 82;.PS 80,80;.PAGE;
.ENDIF FOA

.index ^^Repetition\\
7.##^THREE DOTS#...#DENOTE THE OCCURRENCE OF THE IMMEDIATALY
PRECEDING GROUPING ONE OR MORE TIMES IN SUCCESSION, I.E. A REPETITION.
.B 1
^EXAMPLES:
.B 1
^THE DEFINITION OF DIGITS IS:
.B 1
DIGITS
.BR
------
.B 1;.I 5
DIGIT#...
.B 1
DENOTING THE OCCURRENCE OF AT LEAST ONE DIGIT SUCH AS
.B 1;.I 5
1
.I 5
0935
.I 5
1976
.B 1
^THE DEFINITION OF A COMPOUND-STATEMENT IS:
.B 1
COMPOUND-STATEMENT
.BR
------------------
.B 1;.I 5
^^BEGIN\\#[STATEMENT#;]...#[STATEMENT]##^^END\\
.B 1
(^THE STATEMENT PRECEDING ^^END\\ MAY BE TERMINATED BY A SEMICOLON;
^^DUMMY\\-STATEMENT)
.B 1
^EXAMPLES;
.B 1;.LM 13
^^BEGIN END
.BR
BEGIN#;#END
.B 1
BEGIN\\##STATEMENT##^^END\\
.BR
^^BEGIN\\##STATEMENT#;#^^END\\
.BR
^^BEGIN\\##STATEMENT;
.BR
#######STATEMENT;
.BR
#######STATEMENT;
.BR
^^END\\
.SUBTITLE ^^CHAPTER\\ 2.2
.IF FOA;.NUMBER 83;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.index ^^Program content\\
.index ^^Basic symbol\\
.index ^^Basic symbols and syntactic variables\\
2.2##^^BASIC SYMBOLS AND SYNTACTIC VARIABLES\\
.B 1
^A PROGRAM WRITTEN IN ^^SIMULA\\ MAY CONTAIN ONLY
.B 1;.I 5
BASIC SYMBOLS
.I 5
.index ^^Identifier\\
IDENTIFIERS
.I 5
CONSTANTS
.B 1
^APART FROM ^^CHARACTER\\-CONSTANTS,  ^^TEXT\\-CONSTANTS AND COMMENTS
WHERE EXTRA LATITUDE IS ALLOWED, A PROGRAM MUST CONTAIN ONLY
.index ^^Language character set\\
CHARACTERS BELONGING TO THE LANGUAGE CHARACTER SET.  ^THESE
ARE EITHER ALPHANUMERIC CHARACTERS, SPECIAL SYMBOLS OR KEY
WORDS.  ^EXAMPLES OF SPECIAL SYMBOLS ARE
.B 1;.I 5
+#######-#######(#######)#######[#######]
.B 1
WHICH HAVE OBVIOUS INTERPRETATIONS.  ^IN ADDITION,  ^^SIMULA\\ NEEDS
MANY OTHER SPECIAL SYMBOLS AND, INSTEAD OF USING PECULIAR COMBINATIONS
OF SPECIAL CHARACTERS FOR THEIR REPRESENTATION, ^^SIMULA\\
USES KEY WORDS SUCH AS ^^BEGIN, CLASS\\.  ^THESE KEY WORDS ARE
RESERVED WITHIN THE LANGUAGE AND MAY BE USED ONLY AS KEY
WORDS.
.SUBTITLE ^^CHAPTER\\ 2.2.1
.B 3
.IF FOA;.NUMBER 84;.PS 80,80;.PAGE;
.ENDIF FOA
2.2.1##^^LANGUAGE CHARACTER SET\\
.B 1
^THE ^^SIMULA\\ BASIC SYMBOL SET IS BUILT UP FROM A CHARACTER SET OF
.index ^^Decimal digit\\
ALPHABETIC-CHARACTERS, DECIMAL-DIGITS AND SPECIAL-CHARACTERS.
.B 1
.index ^^Case, upper and lower\\
.index ^^CHARACTER, upper and lower case of\\
.index ^^Identifier, with upper and lower case letters in\\
.index ^^Letter, upper and lower case of\\
.index ^^Lower case characters\\
.index ^^Upper case characters\\
^THERE ARE 52 INTERNATIONAL ALPHABETIC-CHARACTERS#-#THE UPPER AND LOWER CASE
.index ^^Alphabetic character\\
.index ^^National character\\
.index ^^Swedish letter\\
.index ^^Letter, Swedish\\
LETTERS ^A THROUGH ^Z, A THROUGH Z.  ^D^E^CSYSTEM-10 ^^SIMULA\\ ALSO REGARDS THE SWEDISH
LETTERS ^A^A (^A WITH A CIRCLE), ^A^E (^A WITH TWO DOTS),
^O^E (^O WITH TWO DOTS) AS ALPHABETIC (SEE BELOW).
^EXCEPT IN CERTAIN CONSTANTS, THE UPPER AND
LOWER CASE VERSION OF THE SAME LETTERS ARE INTERPRETED AS IDENTICAL.
.B 1
^THERE ARE 10 DECIMAL-DIGITS#-#THE DIGITS 0 THROUGH 9.
.B 1
^AN ALPHANUMERIC-CHARACTER IS EITHER AN ALPHABETIC CHARACTER OR
A DECIMAL DIGIT.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^THE SPECIAL-CHARACTERS MAY HAVE AN INDEPENDENT MEANING WITHIN
THE LANGUAGE (SUCH AS + OR -) OR MAY BE USED IN COMBINATIONS
(SUCH AS := OR =/=).  ^THEIR NAMES AND THE GRAPHICS BY WHICH
THEY ARE REPRESENTED ARE:
.B 2;.LM 5;.TS 28
NAME	GRAPHIC
.BR
----	-------
.B 1;.LM 5;.TS 31;.NF;.NJ
BLANK OR SPACE	#
PLUS	+
MINUS	-
.index ^^Asterisk (*)\\
ASTERISK OR MULTIPLY	*
.index ^^Divide (/)\\
DIVIDE	/
.index ^^Equal to sign (=)\\
EQUALS	=
.index ^^Greater than (>)\\
GREATER THAN	>
LESS THAN	<
NOT	_\ (ALT. REPRESENTATION "^^NOT"\\)
COMMA	,
.index ^^Dot (.)\\
.index ^^Period (.)\\
DOT OR PERIOD	.
.index ^^Exponent sign (_&)\\
EXPONENT	_&
.index ^^Colon (:)\\
COLON	:
SEMICOLON	;
UPARROW	_^
LEFT PARENTHESIS	(
RIGHT PARENTHESIS	)
CHARACTER QUOTE	'
.index ^^TEXT quote (")\\
TEXT QUOTE	"
UNDERSCORE	-
LEFT SQUARE BRACKET	[
RIGHT SQUARE BRACKET	]
EXCLAMATION SIGN	!

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 85;.PS 80,80;.PAGE;
.ENDIF FOA
^THE SWEDISH LETTERS ^A^E ^A^A ^O^E AE AA OE CORRESPOND TO THE FOLLOWING INTERNATIONAL
EQUIVALENTS:
.B 2;.LM 5;.NJ;.NF
^SWEDISH    ^INTERNATIONAL    ^OCTAL    ^DECIMAL
LETTER         SYMBOL       RANK       RANK
--------------------------------------------
                
   ^A^A             _$          044         36
   ^A^E             _#          043         35
   ^O^E             _@          100         64
   aa             _}          175        125
   ae             _{          173        123
   oe             _`          140         96
.B 2;.F;.J
.LM 15;.RM 55;.C
^^!!#IMPORTANT#!!\\
.B 1
^THE USE OF THESE CHARACTERS IN IDENTIFIERS DOES NOT AGREE WITH
THE STANDARD DEFINITION OF THE ^^SIMULA\\ PROGRAMMING LANGUAGE.  ^PROGRAMMERS
ARE THEREFORE ADVISED NOT TO USE THESE LETTERS IN IDENTIFIERS.  ^IF
YOU USE THEM, NOTE THAT ALL LOWER CASE LETTERS IN IDENTIFIERS ARE INTERPRETED
BY THE COMPILER IDENTICAL TO THE CORRESPONDING UPPER-CASE
.index ^^NOT EQUAL TO SIGN (_\=)\\
LETTER, AE IS THUS INTERPRETED AS ^A^E, AA AS ^A^A AND OE AS ^O^E.
.B 1;.LM 0;.RM 70
^A FULL DESCRIPTION OF THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ CHARACTER SET IS GIVEN
IN APPENDIX ^A TO THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ ^LANGUAGE ^HANDBOOK PART ^I.
.SUBTITLE ^^CHAPTER\\ 2.2.2
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70
.IF FOA;.NUMBER 86;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Basic symbol\\
.index ^^Basic symbol set\\
2.2.2##^^BASIC SYMBOLS\\
.B 1
.index ^^Alphanumeric character\\
^ANY PROGRAM WRITTEN IN ^^SIMULA\\ MAY CONTAIN ONLY ALPHANUMERIC
.index ^^Language character set\\
.index ^^Special character\\
.index ^^FORM FEED character\\
.index ^^TAB character\\
.index ^^Device control characters\\
CHARACTERS, THE SPECIAL CHARACTERS AND DEVICE CONTROL CHARACTERS
(LIKE TAB AND FORMFEED), EXCEPT WITHIN ^^CHARACTER\\- OR ^^TEXT\\-CONSTANTS
.index ^^Data character set\\
AND COMMENTS (SEE ^^DATA CHARACTER SET\\ SECTION 2.3).  ^CERTAIN
COMBINATIONS OF THESE ALLOWABLE CHARACTERS HAVE SPECIAL SIGNIFICANCE
AND ARE CALLED BASIC SYMBOLS.
.B 1
^THEY FALL INTO TWO CLASSES:
.B 1;.I 5
DELIMETERS
.I 5
KEY-WORDS
.B 3
.index ^^Delimiters\\
DELIMITERS
.BR
----------
.B 1
^THE DELIMITERS USED BY THE LANGUAGE ARE DIVIDED INTO 6 TYPES:
.B 1;.LM 5
.IF FOA;.NUMBER 87;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Operator word\\
.index ^^Arithmetic operators\\
.index ^^Operator\\
1.##^ARITHMETIC-OPERATORS
.BR
.index ^^Logical operator\\
2.##^LOGICAL-OPERATORS
.BR
.index ^^Brackets\\
3.##^BRACKETS
.BR
.index ^^Reference comparator\\
4.##^REFERENCE-COMPARATORS
.BR
.index ^^Relational operator\\
5.##^RELATIONAL-OPERATORS
.IF FOA;.NUMBER 89;.PS 80,80;.PAGE;
.ENDIF FOA
.BR
.index ^^Separator\\
6.##^SEPARATORS
.B 1;.LM 9;.I -4
1.##^ARITHMETIC-OPERATORS
.B 1
^THE ARITHMETIC-OPERATORS ARE:
.B 1;.LM 13;.TS 17
.index ^^Addition sign (+)\\
.index ^^Plus (+)\\
+	DENOTING ADDITION OR UNARY PLUS
.BR
.index ^^Minus (-)\\
.index ^^Subtraction, sign (-)\\
-	DENOTING SUBTRACTION OR UNARY MINUS
.BR
.index ^^Multiplication sign (*)\\
*	DENOTING MULTIPLICATION
.BR
/	DENOTING DIVISION
.BR;.I -5
.index ^^Raised to the power of sign (** or _^)\\
.index ^^Power sign (** or _^)\\
_^#OR#**	DENOTING "RAISED TO THE POWER OF"
.BR
.index ^^INTEGER division sign (//)\\
//	DENOTING INTEGER DIVISION
.B 1;.LM 9
.I -4
2.##^LOGICAL-OPERATORS
.B 1
.index ^^Logical negation (NOT, _\)\\
.index ^^NOT (_\)\\
.index ^^NOT (_\)\\
^THE FIVE LOGICAL-OPERATORS DENOTING ^^NOT, OR, AND,
EQV\\ AND ^I^M^P (THE LAST TWO REPRESENTING EQUIVALENCE
AND IMPLICATION RESPECTIVELY) ARE REPRESENTED BY
.index ^^Key word constant\\
.index ^^Key word\\
KEY WORDS.  ^IN THE CASE OF ^^NOT\\ THERE IS THE
ALTERNATIVE REPRESENTATION '_\'.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -4
.IF FOA;.NUMBER 88;.PS 80,80;.PAGE;
.ENDIF FOA
3.##^BRACKETS
.B 1
^THE BRACKETS ARE:
.B 1
^THE BRACKETS
.BR
(####)
.BR
ARE USED IN EXPRESSIONS, FOR ENCLOSING PARAMETER LISTS AND FOR
.index ^^ARRAY\\
.index ^^Parenthesis, square ([ and ])\\
.index ^^Square bracket ([ and ])\\
.index ^^Bracket, square ([ and ])\\
ARRAY AND SWITCH BOUNDS AND INDICES, THE SQUARE BRACKETS
.BR
[####]
.BR
ONLY BE USED FOR ARRAY AND SWITCH BOUNDS AND INDICES.
.B 1;.LM 13;.TS 17
.index ^^CHARACTER quote (')\\
'	ENCLOSES CHARACTER CONSTANTS
.BR
"	ENCLOSES TEXT CONSTANTS
.B 1;.LM 9;.I -4
4.##^REFERENCE-COMPARATORS
.B 1
^THE REFERENCE-COMPARATORS ARE:
.B 1;.LM 13;.TS 17
.index ^^EQ (=)\\
.index ^^Reference equal (==)\\
==	DENOTING REFERENCE EQUAL TO
.BR
.index ^^Reference not equal (=/=)\\
=/=	DENOTING REFERENCE NOT EQUAL TO
.B 1;.LM 9;.I -4
5.##^RELATIONAL-OPERATORS
.B 1
^THE RELATIONAL-OPERATORS HAVE DUAL REPRESENTATIONS AS KEY WORDS
AND SYMBOL COMBINATIONS
.B 1;.LM 13;.TS 17,26;.NF;.NJ
.index ^^Equal to sign (=)\\
=	(OR ^E^Q)	DENOTING EQUAL TO
.index ^^NE (_\=)\\
.index ^^NOT EQUAL TO SIGN (_\=)\\
_\=	(OR ^N^E)	DENOTING NOT EQUAL TO
.index ^^GT (>)\\
.index ^^Greater than (>)\\
>	(OR ^G^T)	DENOTING GREATER THAN
.index ^^Greater than or equal to sign (>=)\\
.index ^^GE (>=)\\
>=	(OR ^G^E)	DENOTING GREATER THAN OR EQUAL TO
.index ^^Less than sign (<)\\
.index ^^Less than sign (<)\\
.index ^^LT (<)\\
<	(OR ^L^T)	DENOTING LESS THAN
.index ^^LE (<=)\\
.index ^^Less than or equal to sign (<=)\\
<=	(OR ^L^E)	DENOTING LESS THAN OR EQUAL TO

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 9;.F;.J;.I -4
.IF FOA;.NUMBER 89;.PS 80,80;.PAGE;
.ENDIF FOA
.NJ
6.##^SEPARATORS
.B 2;.TS 24,40
NAME	GRAPHIC	USE
.BR
----	-------	---
.B 1;.LM 33;.TS 27,33;.I -24
.index ^^Comma (,)\\
COMMA	,	SEPARATING ELEMENTS IN LISTS
.B 1;.I -24
.index ^^REAL\\
DOT	.	DENOTING DECIMAL POINT IN ^^REAL\\ NUMBERS; REMOTE ACCESSING
.B 1;.I -24
.index ^^Label\\
COLON	:	FOLLOWS#LABELS;#FOLLOWS ^^VIRTUAL\\; SEPARATES
ARRAY BOUNDS IN ARRAY DECLARATIONS
.B 1;.I -24
.index ^^Becomes sign (:=)\\
BECOMES	:=	IN VALUE ASSIGNMENTS
.B 1;.I -24
.index ^^Denotes sign (:-)\\
DENOTES	:-	IN REFERENCE ASSIGNMENTS
.B 1;.I -24
.index ^^Semicolon (;)\\
SEMICOLON	;	SEPARATES DECLARATIONS AND STATEMENTS;#SEPARATES
.index ^^PROCEDURE\\
VARIOUS PARTS OF PROCEDURE AND CLASS HEADINGS
.B 1;.I -24
.index ^^COMMENT\\
.index ^^COMMENT\\
.index ^^Exclamation mark (!)\\
EXCLAMATION MARK	!	MAY BE USED INSTEAD OF ^^COMMENT\\
TO INDICATE THE START OF A COMMENT
.B 1;.I -24
.index ^^Blank character\\
.index ^^Space character\\
BLANK		USED AS A SEPARATOR
.B 1;.I -24
.index ^^Underscore (__)\\
UNDERSCORE	__	USED IN IDENTIFIERS (E.G. ^^RATE__OF__PAY)\\
.B 1;.I -24
.index ^^LONG REAL\\
###(  )   	_&	POWER-OF-TEN SYMBOL IN ^^REAL\\ AND
####10                 ^^LONG REAL\\ CONSTANTS.

.JUSTIFY
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 90;.PS 80,80;.PAGE;
.ENDIF FOA
KEY-WORDS
.BR
---------
.B 1
^A KEY-WORD IS AN IDENTIFIER WHICH IS A PART OF THE LANGUAGE
AND ITS USE IS RESERVED FOR THAT PURPOSE.  ^KEY-WORDS MAY
BE CLASSIFIED AS FOLLOWS:#(1)
.FN 8
.B 1
-------------
.BR
.index ^^Switches to the compiler\\
.index ^^OPTIONS statement\\
.index ^^Reserved word\\
(1)##^IN ADDITION TO THIS, THE WORD ^^OPTIONS\\ IS A RESERVED WORD
IN ^^DEC\\SYSTEM-10 ^^SIMULA\\ AND IS USED IN THE ^^OPTIONS\\
STATEMENT TO GIVE CERTAIN MACHINE-DEPENDENT INFORMATION TO THE
SYSTEM (E.G. IF YOU WANT A SOURCE PROGRAM LISTING OR NOT, IF YOU
WANT TO GENERATE SYMBOL TABLES FOR THE ^^SIMULA\\ ^DEBUGGING ^SYSTEM OR
NOT ETC.).  ^FOR FURTHER INFORMATION ABOUT THE ^^OPTIONS\\ STATEMENT
SEE THE ^D^E^CSYSTEM-10 ^^SIMULA\\ ^LANGUAGE ^HANDBOOK PART ^I^I.
!
.B 1;.LM 5
1.##^STATEMENT-BRACKETS
.IF FOA;.NUMBER 91;.PS 80,80;.PAGE;
.ENDIF FOA
.BR
.index ^^Declarator\\
2.##^DECLARATORS
.BR
.index ^^Specificator\\
3.##^SPECIFICATORS
.IF FOA;.NUMBER 92;.PS 80,80;.PAGE;
.ENDIF FOA
.BR
4.##^OPERATORS
.BR
5.##^KEY-WORD-CONSTANTS
.B 1;.LM 9;.I -4
1.##^STATEMENT-BRACKETS
.B 1
^THE STATEMENT-BRACKETS ARE:
.B 1;.I 5
.index ^^Statement bracket\\
.index ^^BEGIN\\
^^BEGIN
.I 5
END\\
.B 1
WHICH ARE USED TO DEMARK THE LIMITS OF BLOCKS AND COMPOUND STATEMENTS.
.B 1;.LM 9;.I -4
2.##^DECLARATORS
.B 1
^THE DECLARATORS ARE:
.B 1;.LM 13;.NF;.NJ
.index ^^BOOLEAN\\
^^BOOLEAN
CHARACTER
INTEGER
.index ^^SHORT INTEGER\\
SHORT INTEGER
REAL
LONG REAL
.index ^^TEXT\\
TEXT
.index ^^REF\\
REF (CLASS\\-IDENTIFIER)
.index ^^CLASS\\
^^CLASS
PROCEDURE
.index ^^SWITCH\\
SWITCH
ARRAY\\
.B 1;.LM 9;.F;.J
WHICH ARE USED IN DECLARATIONS AND SPECIFICATION LISTS.
.index ^^INTEGER\\
^THE KEY WORDS ^^SHORT\\ AND ^^INTEGER, LONG\\ AND ^^REAL\\
MUST BE SEPARATED BY AT LEAST ONE SPACE, AS
.B 1;.I 4
^^SHORT###.[...]##INTEGER
.I 4
LONG####.[...]##REAL\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 9;.I -4
3.##^SPECIFICATORS
.B 1
^THE SPECIFICATORS ARE:
.B 1;.I 4
^^HIDDEN
.I 4
.index ^^HIDDEN, syntax\\
LABEL
.I 4
.index ^^NAME, syntax\\
NAME
.I 4
PROTECTED
.index ^^PROTECTED, syntax\\
.I 4
.index ^^VALUE, syntax\\
VALUE
.I 4
.index ^^VIRTUAL\\
VIRTUAL\\
.B 1
WHICH ARE USED IN SPECIFICATION PARTS TO PROCEDURES
(^^LABEL, NAME, VALUE\\) OR TO CLASSES (^^VALUE, VIRTUAL, HIDDEN, PROTECTED\\).
.B 1;.I -4
4.##^OPERATORS
.B 1
^THE OPERATORS ARE DIVIDED INTO 4 CLASSES:
.B 1;.LM 13
LOGICAL-OPERATORS
.BR
RELATIONAL-OPERATORS
.BR
.index ^^Sequential operator\\
SEQUENTIAL-OPERATORS
.BR
SPECIAL-OPERATORS
.B 1;.LM 9
^THE LOGICAL-OPERATORS ARE:
.B 1;.LM 13;.TS 25
.index ^^Logical AND\\
.index ^^AND\\
^^AND\\	DENOTING THE LOGICAL AND
.BR
.index ^^Logical inclusive or (OR)\\
.index ^^OR\\
^^OR\\	DENOTING THE LOGICAL INCLUSIVE OR
.BR
^^NOT\\#(OR#_\)	DENOTING LOGICAL NEGATION
.BR
.index ^^Equivalence (EQV) Boolean (logical) operator\\
.index ^^Logical equivalence (EQV)\\
.index ^^EQV\\
^^EQV\\	DENOTING LOGICAL EQUIVALENCE
.BR
.index ^^Logical implication (IMP)\\
.index ^^Implication (IMP) Boolean operator\\
.index ^^IMP\\
^^IMP\\	DENOTING LOGICAL IMPLICATION
.B 1;.LM 9
^THE RELATIONAL-OPERATORS ARE:
.B 1;.LM 13;.TS 25
^E^Q (OR =)	DENOTING EQUAL TO
.BR
^N^E (OR _\=)	DENOTING NOT EQUAL TO
.BR
^G^T (OR >)	DENOTING GREATER THAN
.BR
^G^E (OR \=)	DENOTING GREATER THAN OR EQUAL TO
.BR
^L^T (OR <)	DENOTING LESS THAN
.BR
^L^E (OR <=)	DENOTING LESS THAN OR EQUAL TO

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 9
^THE SEQUENTIAL-OPERATORS ARE:
.NJ;.B 1;.LM 13
.FILL
^^GOTO\\
.BR
.index ^^TO\\
USED IN ^^GOTO\\-STATEMENTS.  ^^GOTO\\ MAY ALSO BE WRITTEN ^^GO\\##...##^T^O (WITH
.index ^^GO TO statement\\
.index ^^GO TO statement\\
ANY NUMBER OF BLANKS BETWEEN ^G^O AND ^T^O, WHICH MEANS THAT
^G^O AND ^T^O BOTH ARE RESERVED WORDS),
.B 1
.index ^^FOR\\
.IF FOA;.NUMBER 93;.PS 80,80;.PAGE;
.ENDIF FOA
^^FOR
.BR
.index ^^STEP\\
STEP
.BR
.index ^^UNTIL\\
UNTIL
.BR
.index ^^WHILE\\
WHILE
.BR
.index ^^DO\\
DO\\
.BR
USED IN ^^WHILE\\- AND ^F^O^R-STATEMENTS (^D^O ALSO APPEARS
IN CONNECTION-STATEMENTS),
.B 1
.index ^^IF\\
^^IF
.BR
.index ^^THEN\\
THEN
.BR
.index ^^ELSE\\
ELSE\\
.BR
USED IN CONDITIONAL-STATEMENTS AND CONDITIONAL-EXPRESSIONS,
.B 1
.index ^^INSPECT\\
^^INSPECT
.BR
.index ^^WHEN\\
WHEN
.BR
DO
.BR
.index ^^OTHERWISE\\
OTHERWISE\\
.BR
USED IN CONNECTION-STATEMENTS.  (^D^O ALSO APPEARS
IN ^^WHILE\\- AND ^F^O^R-STATEMENTS),
.B 1
^^ACTIVATE
.BR
.index ^^REACTIVATE in CLASS SIMULATION\\
REACTIVATE
.BR
.index ^^DELAY in ACTIVATE statement\\
DELAY
.BR
.index ^^AFTER in the activate statement\\
AFTER
.BR
.index ^^BEFORE\\
BEFORE
.BR
.index ^^AT in the activate statement\\
AT
.BR
.index ^^PRIOR in activate statement\\
PRIOR\\
.BR
USED IN ACTIVATION-STATEMENTS,
.B 1
.index ^^INNER\\
^^INNER\\
.BR
USED IN ^^CLASS\\-BODIES TO ALTER THE ORDER OF EXECUTION
OF STATEMENTS FROM THEIR TEXTUAL ORDER,

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -4
.IF FOA;.NUMBER 94;.PS 80,80;.PAGE;
.ENDIF FOA
^THE SPECIAL-OPERATORS ARE:
.B 1
.index ^^NEW, syntax\\
^^NEW\\
.BR
IS USED IN GENERATING OBJECTS,
.B 1
^^THIS
.BR
.index ^^THIS\\
THIS CLASS\\-IDENTIFIER
REPRESENTS A REFERENCE TO THE NEAREST TEXTUALLY ENCLOSING OBJECT
OF A CLASS EQUAL TO OR INNER TO THAT OF THE ^^CLASS\\-IDENTIFIER,
.B 1
.index ^^QUA, syntax\\
^Q^U^A
.BR
DEFINES THE SCOPE OF A REFERENCE EXPRESSION,
.B 1
^^IS
.BR
.index ^^IN\\
IN\\
.BR
.index ^^IS\\
USED TO TEST CLASS MEMBERSHIP,
.B 1
^^COMMENT\\ OR !
.BR
USED TO INSERT DESCRIPTIVE TEXT AMONG THE
BASIC SYMBOLS OF A PROGRAM.
.B 1;.I -4
^THE KEY-WORD-CONSTANTS ARE:
.B 1
.index ^^TRUE\\
^^TRUE
.BR
.index ^^FALSE\\
FALSE\\
.BR
REPRESENT LOGICAL VALUES,
.B 1
.index ^^NONE\\
^^NONE\\
.BR
REPRESENTS THE "NO OBJECT REFERENCE",
.B 1
.index ^^Empty TEXT value (NOTEXT)\\
.index ^^NOTEXT\\
^^NOTEXT\\
.BR
REPRESENTS "NO TEXT OBJECT", I.E. THE EMPTY TEXT.
.SUBTITLE ^^CHAPTER\\ 2.2.3
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 95;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^ISO 7 bit character set\\
2.2.3##^^DATA CHARACTER SET\\
.B 1
^ALTHOUGH THE LANGUAGE CHARACTER SET IS A FIXED SET DEFINED FOR
THE LANGUAGE, THE DATA CHARACTER SET HAS NOT BEEN LIMITED.
^DATA MAY BE REPRESENTED BY CHARACTERS FROM THE LANGUAGE SET
.index ^^Character set\\
.index ^^EBCDIC character set\\
.index ^^CHARACTER\\
.index ^^Character set\\
.index ^^EBCDIC character set\\
.index ^^ISO 7 bit character set\\
.index ^^ASCII 7 bit character set\\
PLUS ANY OTHER ^^ISO-7(ISO R 646)\\ CHARACTERS.
.B 3
.index ^^Greater than on characters\\
.index ^^Less than on characters\\
.index ^^Sorting order of characters\\
.index ^^Collating sequence\\
^COLLATING SEQUENCE
.BR
------------------
.B 1
^THE 128 MEMBERS OF THE DATA CHARACTER SET HAVE ASSOCIATED WITH
THEM A UNIQUE ^^INTEGER\\ VALUE IN THE RANGE 0-127.  ^THIS SEQUENCE
IS KNOWN AS THE COLLATING SEQUENCE.  ^IT IS THUS POSSIBLE TO MAKE
COMPARISONS OF ^^CHARACTER\\S MEANINGFUL BY COMPARING THE ASSOCIATED
NUMERICAL VALUES, SUCH AS
.B 1;.I 5
'^A'##<##'^B'
.I 5
^^INCHAR##=##'#'\\
.B 1
^PARTS OF THE COLLATING SEQUENCE ARE GIVEN IN ^APPENDIX ^A.
.SUBTITLE ^^CHAPTER\\ 2.2.4
.B 3
.IF FOA;.NUMBER 96;.PS 80,80;.PAGE;
.ENDIF FOA
2.2.4##^^THE USE OF BLANKS\\
.B 1
^IDENTIFIERS, COMPOSITE OPERATORS (E.G. =/=),
KEY WORDS (E.G. ^^BEGIN\\) MAY NOT CONTAIN BLANKS.  ^BLANKS ARE
PERMITTED AS ^^CHARACTER\\-CONSTANTS, IN ^^TEXT\\-CONSTANTS
AND IN ARITHMETIC CONSTANTS.
.B 1
^IDENTIFIERS, CONSTANTS AND KEY WORDS MAY NOT BE IMMEDIATELY
ADJACENT.  ^THEY MUST BE SEPARATED BY AN ARITHMETIC OPERATOR,
.index ^^Left parenthesis (()\\
.index ^^Right parenthesis ())\\
PARENTHESIS (##()#[#OR#]##), REFERENCE COMPARATOR, NEGATION (_\),
NON-KEY-WORD RELATIONAL OPERATOR (<,<=,=,_\=,>,>=,==,=/=), COMMA,
DOT, COLON, BECOMES SYMBOL (:=), DENOTES SYMBOL (:-), SEMICOLON,
OR BLANK.  ^MOREOVER ADDITIONAL INTERVENING BLANKS ARE ALWAYS PERMITTED.
.B 1
^EXAMPLES:
.B 1;.LM 9;.TS 20
^^X#+#Y\\	IS EQUIVALENT TO ^X+^Y
.BR
^A#[^I#]	IS EQUIVALENT TO ^A[^I]
.BR
^A##:=^X#:=^Y	IS EQUIVALENT TO ^^A:=X:=Y\\
.SUBTITLE ^^CHAPTER\\ 2.2.5
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
.IF FOA;.NUMBER 97;.PS 80,80;.PAGE;
.ENDIF FOA
2.2.5##^^COMMENT CONVENTIONS\\
.B 1
^COMMENTS ARE USED FOR DOCUMENTATION (THE INSERTION OF A TEXTUAL
DESCRIPTION OF PART OF THE PROGRAM) AND DO NOT PARTICIPATE IN
THE EXECUTION OF A PROGRAM.  ^THE FOLLOWING CONVENTIONS HOLD:
.B 2
^SEQUENCE OF BASIC SYMBOLS
.BR
-------------------------
.B 2;.LM 0;.NJ;.NF
^THE SEQUENCE:                                          ! IS EQUIV. TO:
                                                       !
                           **                     **   !
           **         **   *  ANY SEQUENCE FROM    *   !
           *  ^^COMMENT\\  *   *  THE DATA CHARACTER . *   !
^DELIMITER **     !     ** **  SET NOT INCLUDING    ** ;! ^DELIMITER
           *           *   *  A SEMICOLON          *   !
           **         **   **                     **   !
                                                       !
     **                             **                 !
     *  ANY SEQUENCE FROM THE DATA   *                 !
.index ^^END\\
^^END\\ **  CHARACTER SET NOT INCLUDING  **                ! ^^END
     *  END!ELSE!WHEN!OTHERWISE!;    *                 !\\
     **                             **
.B 1;.LM 0;.F;.J
^EXAMPLES:
.B 1;.NF;.NJ
1.  ^^BEGIN COMMENT***THE NEXT BLOCK IS USED FOR PAY-ROLL
                   CALCULATIONS***;
.B 1
            BEGIN .....
                  .....
            END OF PAY-ROLL BLOCK;
            .....
    END
.B 1;.F;.J
^WHERE THE STRINGS "^^COMMENT#....#;"\\ AND "^^OF PAY-ROLL BLOCK"\\
ARE TREATED AS COMMENTS.
.B 1;.NF;.NJ
.IF FOA;.NUMBER 98;.PS 80,80;.PAGE;
.ENDIF FOA
2.  ^^IF X > 0 THEN BEGIN .....
                  END OF TRUE PART
             ELSE BEGIN .....
                  END OF FALSE PART;
.B 1;.F;.J
^WHERE THE STRINGS "^^OF TRUE PART\\" AND "^^OF FALSE PART\\"
ARE TREATED AS COMMENTS.
.B 1;.NF;.NJ
3.  ^^X := X !THAT WAS X;**2 COMMENT**SQUARED;;\\
    IS EQUIVALENT, AS REGARDS PROGRAM EXECUTION, TO 
    ^^X := X**2;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 99;.PS 80,80;.PAGE;
.ENDIF FOA
2.2.6##^^CODING SIMULA PROGRAMS\\

.B 1
^A ^^SIMULA\\ SOURCE PROGRAM ON THE ^D^E^CSYSTEM-10 MAY CONTAIN LINES WITH
.index ^^Line length\\
.index ^^Source program line length\\
UP TO 135 CHARACTERS.  ^THE LINES MAY BE LINE-NUMBERED
IN THE STANDARD ^D^E^CSYSTEM-10 WAY.  ^SOME OF THE LINES IN A LINE-NUMBERED
SOURCE PROGRAM MAY HAVE BLANK LINE NUMBERS.
.B 1
^IF  YOU CONVERT ^^SIMULA\\ SOURCE PROGRAMS FROM A SYSTEM WHICH
.index ^^Card source program input\\
.index ^^Column 73-80\\
.index ^^Punched card source program input\\
EXPECTS THE SOURCE PROGRAM IN COLUMNS 1-72, YOU SHOULD REMOVE COLUMNS
73-80.  (^YOU CAN USE ^^PIP,\\ THE ^^IBMSIM,\\ OR THE ^^CDCSIM\\ PROGRAM TO DO THIS.)
.B 1
^THIS WILL BE DESCRIBED IN GREATER DETAIL IN ^D^E^CSYSTEM-10 ^^SIMULA\\
^LANGUAGE ^HANDBOOK ^PART ^I^I.
.SUBTITLE CHAPTER 2.3
.IF FOA;.NUMBER 100;.PS 80,80;.PAGE;
.ENDIF FOA
.B 2
2.3##^^IDENTIFIERS\\
.BR
#####-----------
.B 1
^AN IDENTIFIER IS A STRING OF ALPHANUMERIC OR UNDERSCORE CHARACTERS,
NOT CONTAINED IN A COMMENT OR CONSTANT, PRECEDED AND FOLLOWED
BY A DELIMITER#-#THE INITIAL CHARACTER MUST BE A LETTER.
.index ^^Letter in identifier\\
.B 3
IDENTIFIER
.BR
----------
.B 1
.I 9
LETTER[#LETTER#!#DIGIT#!#__#]...
.index ^^Digit in identifiers\\
.B 1
^EXAMPLES:
.B 1;.LM 9
VALID IDENTIFIERS
.BR
-----
.B 1
^^X
.BR
SIMULA__67
.BR
A15
.BR
MORGAN__PLUS__4\\
.B 1
INVALID IDENTIFIERS
.BR
-------
.B 1;.LM 9;.TS 20
^^END\\	RESERVED FOR USE AS A KEYWORD
.BR
^^SYM#BOL\\	CONTAINS A BLANK
.BR
3^C	DOES NOT BEGIN WITH A LETTER

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
.IF FOA;.NUMBER 101;.PS 80,80;.PAGE;
.ENDIF FOA
^LENGTH OF IDENTIFIERS
.index ^^Length of identifiers\\
.BR
---------------------
.B 1
^IDENTIFIERS IN A ^^SIMULA\\ PROGRAM MAY BE COMPOSED OF ANY NUMBER
OF ALPHANUMERIC OR UNDERSCORE CHARACTERS, BUT IN ^^DEC\\system-10
^^SIMULA\\ ONLY THE FIRST
TWELVE ARE SIGNIFICANT.  ^THUS IF TWO IDENTIFIERS CONTAIN THE
SAME FIRST TWELVE CHARACTERS THEY ARE CONSIDERED EQUIVALENT.
.B 1;.LM 13;.I -6
E.G.##^^BIORTHOGONAL\\###AND
.BR
^^BIORTHOGONALISATION\\
.B 1;.LM 0
WILL BOTH BE TREATED AS OCCURRENCES OF THE IDENTIFIER
.B 1;.I 13
^^BIORTHOGONAL\\
.B 1
^^NOTE _! ^THE USE OF DIFFERENT EXTERNAL IDENTIFIERS (^^PROCEDURES\\ OR ^^CLASSES\\)
WHICH ARE EQUIVALENT IN THE FIRST SIX CHARACTERS IS NOT RECOMMENDED.
.B 2;.LM 0
^IDENTIFIERS AND KEY WORDS
.index ^^Identifiers and key words\\
.BR
-------------------------
.B 1
^IT IS NOT POSSIBLE TO USE A KEY WORD AS AN IDENTIFIER.  ^EVERY
OCCURRENCE WOULD BE TREATED AS AN OCCURRENCE OF THAT KEY WORD
AND ITS USE AS AN IDENTIFIER WOULD RESULT IN ERRORS.
.B 3
^BASIC BINDING RULES
.index ^^Scope\\
.index ^^Binding rule\\
.index ^^Basic binding rules\\
.BR
-------------------
.B 1
^VARIABLES, ARRAYS, SWITCHES, PROCEDURES AND CLASSES ARE SAID
TO BE QUANTITIES.  ^IDENTIFIERS SERVE TO IDENTIFY QUANTITIES,
OR THEY STAND AS LABELS OR FORMAL PARAMETERS.  ^IDENTIFIERS HAVE
.index ^^Label as formal parameter\\
.index ^^Formal parameter\\
NO INHERENT MEANING AND MAY BE CHOSEN FREELY (EXCEPT THAT THEY
MAY NOT CLASH WITH KEY WORDS).
.B 1
.IF FOA;.NUMBER 102;.PS 80,80;.PAGE;
.ENDIF FOA
^EVERY IDENTIFIER USED IN A PROGRAM MUST BE DECLARED.  ^THIS IS
ACHIEVED BY:
.B 1;.LM 9;.I -4
1.##^A DECLARATION (SECTION 5), IF THE IDENTIFIER DEFINES A
QUANTITY.  ^IT IS THEN SAID TO BE A ^J-VARIABLE, ^^J-ARRAY, J-PROCEDURE-,
PROCEDURE-, CLASS\\-IDENTIFIER WHERE ^J STANDS
FOR THE TYPE OF THE DECLARED QUANTITY.
.B 1;.I -4
2.##^ITS OCCURRENCE AS A LABEL (SECTION 5.6) IF THE IDENTIFIER
STANDS AS A LABEL.  ^IT IS THEN SAID TO BE A ^^LABEL\\-IDENTIFIER.
.B 1;.I -4
3.##^ITS OCCURRENCE IN THE FORMAL-PARAMETER-LIST (SECTION 5.4,
5.5) OF A ^^PROCEDURE-\\ OR ^^CLASS\\-DECLARATION.  ^IT IS THEN SAID
TO BE A FORMAL-PARAMETER.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^THE IDENTIFICATION OF THE DEFINITION OF A GIVEN IDENTIFIER IS
DETERMINED BY BINDING RULES.  ^THE BASIC BINDING RULES GIVEN
BELOW ARE LATER EXTENDED IN THE CASES OF REMOTE ACCESSING
(SECTION 6.1), ^^VIRTUAL\\ QUANTITIES (SECTION 5.5), AND CONNECTION
(SECTION 7.2).
.B 1;.LM 9;.I -4
1.##^IF THE IDENTIFIER IS DEFINED WITHIN THE SMALLEST BLOCK
.index ^^Scope\\
(SECTION 7.1) TEXTUALLY ENCLOSING THE GIVEN OCCURRENCE BY 
ITS OCCURRENCE AS A QUANTITY OR LABEL, THEN IT DENOTES
THAT QUANTITY OR LABEL.
.B 1
^THE STATEMENT FOLLOWING A PROCEDURE HEADING OR A CLASS
HEADING IS ALWAYS CONSIDERED TO BE A BLOCK, WHICH MAKES THE
BINDING TO FORMAL PARAMETERS A SPECIAL CASE.
.B 1;.I -4
2.##^OTHERWISE IF THE BLOCK IS A PROCEDURE OR A CLASS BODY AND
.index ^^PROCEDURE body\\
THE GIVEN IDENTIFIER IS IDENTICAL WITH A FORMAL PARAMETER
IN THE ASSOCIATED PROCEDURE OR CLASS HEADING, THEN IT STANDS
FOR THAT FORMAL PARAMETER.
.B 1;.LM 0
.IF FOA;.NUMBER 103;.PS 80,80;.PAGE;
.ENDIF FOA
^OTHERWISE, THESE RULES ARE APPLIED BY CONSIDERING THE SMALLEST
BLOCK TEXTUALLY ENCLOSING THE BLOCK WHICH HAS BEEN PREVIOUSLY
CONSIDERED.
.B 1
^IF THESE STEPS LEAD TO MORE THAN ONE DEFINITION OR TO NO DEFINITION,
THEN THE IDENTIFICATION IS ILLEGAL.
.B 1
^EXAMPLE:
.B 1;.LM 9;.NF;.NJ
LINE 1      ^^BEGIN PROCEDURE A;
     2              X := X + 1;
     3              REAL X;
     4              BEGIN REAL X;
     5                    X := 2;
     6              LAB:  A;
     7              END;
     8      END\\
.B 1;.LM 0;.F;.J
^THE BLOCK SPANNING LINES 4-7 IS TEXTUALLY ENCLOSED IN THE BLOCK
SPANNING LINES 1-8.  ^THE PROCEDURE DECLARATION OF LINES 1-2 IS
TREATED AS THOUGH IT WERE
.B 1;.LM 9;.NF;.NJ
^^PROCEDURE A;
BEGIN  \\<DUMMY-DECLARATION>;
       ^^X := X + 1;
END;\\
.B 1;.LM 0;.RM 70;.F;.J
^THUS THE OCCURRENCE OF ^X AT LINE 5 IS BOUND TO THE DECLARATIONS
OF LINE 4, WHEREAS IN THE INVOCATION OF THE PROCEDURE AT LINE 6
THE BINDING RULE FOR THE OCCURRENCE OF ^X IN THE PROCEDURE BODY
.index ^^PROCEDURE body\\
IS TO THE VARIABLE DECLARED AT LINE 3.
.SUBTITLE CHAPTER 2.4
.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 104;.PS 80,80;.PAGE;
.ENDIF FOA
2.4##^^TYPES AND CONSTANTS\\
.index ^^Types and constants\\
.index ^^Constants\\
.index ^^Literal constants\\
.index ^^Type\\
.BR
#####-------------------
.B 1
^CONSTANTS AND VARIABLES POSSESS VALUES AND TYPES.  ^BOTH THE
VALUE AND TYPE OF A CONSTANT ARE DETERMINED BY THE WAY IT IS
.index ^^VALUE of a constant\\
WRITTEN.  ^THE VALUE OF A VARIABLE IS THE ONE MOST RECENTLY
.index ^^Variable, value of\\
ASSIGNED TO IT, OR ITS INITIAL VALUE IF NO ASSIGNMENT HAS YET
.index ^^Initial value, type dependency of\\
BEEN MADE, AND ITS TYPE IS DETERMINED BY ITS DECLARATION.
.SUBTITLE ^^CHAPTER 2.4.1\\
.B 3

2.4.1##^^TYPES\\
.B 1
^TYPE IS SUBDIVIDED INTO TWO CLASSES BY:
.B 1
TYPE
.index ^^Type\\
.BR
----
.NJ;.NF;.LM 10
 **               **
 *                 *
**  VALUE-TYPE     **
.index ^^Value type\\
 *  REFERENCE-TYPE *
 *                 *
 **               **
.B 1;.LM 0;.F;.J
WHERE VALUE-TYPE AND REFERENCE-TYPE ARE DEFINED BY:
.index ^^Reference type\\
.index ^^REF\\
.B 2
VALUE-TYPE
.BR
----------
.B 2;.LM 10;.NJ;.NF
^^ **               **
 * [SHORT ]INTEGER *
.index ^^SHORT INTEGER constant\\
.index ^^SHORT INTEGER\\
**  [LONG ]REAL    **
 *  BOOLEAN        *
 * CHARACTER       *
 **               **\\
.B 2;.LM 0;.F;.J
REFERENCE-TYPE
.BR
--------------
.B 2;.LM 10;.NJ;.NF
 **                     **
 *                       *
** ^^REF(CLASS\\-IDENTIFIER) **
 * ^^TEXT\\                  *
 *                       *
 **                     **
.SUBTITLE ^^CHAPTER 2.4.2\\
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
.index ^^Constants\\
.index ^^Literal constants\\
.IF FOA;.NUMBER 105;.PS 80,80;.PAGE;
.ENDIF FOA
2.4.2##^^CONSTANTS\\
.B 1
^A CONSTANT IS A FIXED, UNVARYING QUANTITY THAT DENOTES ITSELF,
I.E. IT CAN NOT ALTER DURING THE COURSE OF A PROGRAM.  ^EACH
CONSTANT HAS A UNIQUELY DEFINED TYPE.  ^THE DISCUSSION OF CONSTANTS
FOLLOWS THE ORDER:
.B 1;.LM 9
ARITHMETIC-CONSTANTS
.BR
^^BOOLEAN\\-CONSTANTS
.BR
^^CHARACTER\\-CONSTANTS
.BR
OBJECT-REFERENCE-CONSTANT
.BR
^^TEXT\\-CONSTANT
.B 1;.LM 0
^NULL CHARACTERS (CHARACTERS WITH ^^RANK\\#=#0 OR ^^RANK\\#=#177(8)#=#127(10))
.index ^^Null character (Octal zero)\\
.index ^^Null character (Octal 177)\\
.index ^^Delete character (Octal 177)\\
ARE IGNORED WHEREVER THEY APPEAR IN INPUT SOURCE PROGRAMS, AND THEY
CAN THUS APPEAR ANYWHERE WITHIN A CONSTANT.
.B 3
.IF FOA;.NUMBER 106;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
ARITHMETIC-CONSTANTS
.index ^^Constants, arithmetic\\
.index ^^Arithmetic constants\\
.BR
--------------------
.B 1
^ARITHMETIC-CONSTANTS MAY BE WRITTEN WITH THE BASES 2, 4, 8, 10 OR 16.
^THE BASE 10#(DECIMAL) IS ASSUMED UNLESS OTHERWISE INDICATED.
.index ^^Decimal constant\\
^NOTE THAT
.B 1;.LM 9;.I -4
1.##^THE USE OF ARITHMETIC-CONSTANTS IS OPTIMISED BY THE SYSTEM
.B 1;.I -4
2.##^ANY '+' OR '-' SIGN PRECEDING AN ARITHMETIC-CONSTANT
IS TREATED SEPARATELY.
.B 3;.LM 0
.IF FOA;.NUMBER 107;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
DECIMAL-CONSTANT
.index ^^Constants, decimal\\
.index ^^Number, decimal\\
.index ^^Decimal constant\\
.BR
----------------
.B 1
^DECIMAL-CONSTANTS ARE INTERPRETED ACCORDING TO CONVENTIONAL
.index ^^Decimal constant\\
NOTATION WITH '_&' OR '_&_&' REPRESENTING THE EXPONENT SIGN.  ^IF
.index ^^Ampersand character (_&)\\
.index ^^Exponent sign in decimal constant\\
.index ^^Exponent sign (_&)\\
.index ^^Exponent, in [LONG] REAL constant\\
.index ^^Number, [LONG] REAL\\
.index ^^LONG REAL constant\\
A DECIMAL CONSTANT CONTAINS EITHER A DECIMAL POINT, OR AN EXPONENT
.index ^^Dot (.) as decimal point\\
.index ^^Decimal constant\\
SIGN, OR BOTH, IT IS INTERPRETED AS A (^^LONG\\) ^^REAL\\ NUMBER,
.index ^^REAL constant\\
.index ^^Floating point constant\\
.index ^^LONG REAL constant\\
IF IT CONTAINS NEITHER A DECIMAL POINT NOR AN EXPONENT SIGN, IT IS
.index ^^Decimal constant\\
TAKEN TO REPRESENT AN ^^INTEGER\\ NUMBER.
.B 2
DECIMAL-DIGIT
.index ^^Decimal digit\\
.index ^^Decimal constant\\
.BR
-------------
.B 2;.LM 10;.NJ;.NF
 **                   **
 *                     *
** 0!1!2!3!4!5!6!7!8!9 **
 *                     *
 **                   **

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
.index ^^Constants\\
.index ^^Literal constants\\
DECIMAL-DIGITS
.index ^^Decimal constant\\
.BR
--------------
.B 1;.I 9
DECIMAL-DIGIT#...
.B 1
REPRESENTING A RUN OF AT LEAST ONE DECIMAL DIGIT.
.index ^^Decimal constant\\
.B 1;.NF;.NJ
^EXAMPLES:
--------        000
                  1
             315730
.B 2;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 108;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
^^INTEGER\\-CONSTANT
.index ^^Whole number\\
.index ^^Constants, integer\\
.index ^^Number, integer\\
.index ^^INTEGER constant\\
.index ^^Digital constant in source program\\
.index ^^Number constant in source program\\
.index ^^INTEGER constant\\
.index ^^INTEGER\\
.BR
----------------
.B 1
DECIMAL DIGITS
.B 1
^THE RANGE OF VALUES IS THE SET OF WHOLE NUMBERS FROM 0
THROUGH 2_^35-1 (=34#359#738#367).  ^IF THE MAGNITUDE IS EQUAL
.index ^^Range of values, SHORT INTEGER constant\\
.index ^^Range of values, INTEGER constant\\
TO OR EXCEEDS 2_^35, THE NUMBER IS INTERPRETED AS A ^^REAL\\
CONSTANT.
.B 1;.NF;.NJ
^EXAMPLES:
--------          0
                 91
              81472
.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 109;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
[^^LONG]REAL\\-CONSTANT
.index ^^Constants, [long] real\\
.index ^^LONG REAL constant\\
.index ^^Floating point constant\\
.index ^^Digital constant in source program\\
.index ^^Number constant in source program\\
.index ^^REAL constant\\
.BR
-------------------
.B 2;.LM 5;.NJ;.NF
 **                                                  **
 *  **                                  **            *
 *  *  .DECIMAL-DIGITS                   *            *
.index ^^Decimal constant\\
 * **  DECIMAL-DIGITS.DECIMAL-DIGITS     **  EXPONENT *
 *  *  DECIMAL-DIGITS                    *            *
 *  **                                  **            *
**                                                    **
 *     .DECIMAL-DIGITS                                *
 *     DECIMAL-DIGITS.DECIMAL-DIGITS                  *
 *     EXPONENT                                       *
 **                                                  **
.B 1;.LM 0;.J;.F
WHERE EXPONENT TAKES THE FORM

.IFNOT FOA;.PG
.ENDIF FOA;
.index ^^Constants\\
.index ^^Literal constants\\
EXPONENT
.BR
--------
.B 1;.LM 10;.NJ;.NF
     [+]
_& [_&][-]DECIMAL-DIGITS
.index ^^Decimal constant\\
.B 1;.LM 0;.RM 70;.F;.J
I.E. THE SYMBOL '_&' OR '_&_&', OPTIONALLY FOLLOWED BY A '+' OR
'-' SIGN, FOLLOWED BY AN ^^INTEGER\\-CONSTANT.  ^THE EXPONENT REPRESENTS
A SCALE FACTOR EXPRESSED AS AN INTEGRAL POWER OF 10.
.B 1
^THE RANGE OF VALUES OF (^^LONG) REAL\\-CONSTANTS IS 0.147_&-38 THROUGH 0.170_&+39
.index ^^Range of values, REAL constant\\
(APPROXIMATELY). ^A TRUE ZERO IS ALSO REPRESENTABLE.  ^THE SYMBOL '_&' INDICATES ^^REAL\\ CONSTANTS,
.index ^^Range of values, LONG REAL constant\\
THE SYMBOL '_&_&' INDICATES ^^LONG REAL\\ CONSTANTS.  ^THE PRECISION
IS APPROXIMATELY 9 DECIMAL DIGITS FOR ^^REAL\\ CONSTANTS AND 18 DECIMAL
DIGITS FOR ^^LONG REAL\\ CONSTANTS.
.B 1
.IF FOA;.NUMBER 110;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
^EXAMPLES
.BR
--------
.B 1
^VALID
.BR
-----
.BR;.NF;.NJ
                      0.0
                  999.999
                 57.6_&+21     ^^REAL\\
                     .3_&1
                      3_&1
                      _&-1
.B 1
           314.1592653_&_&0
          21.2274568_&_&+03    ^^LONG REAL\\
.B 2
^INVALID
-------
                       3.      ^NO DIGIT AFTER THE DECIMAL-POINT
                  3,149.2      ^EMBEDDED COMMA
                    33.4_&      ^NO SCALE FACTOR
                  23.4_&87      ^OUT OF RANGE
   
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.index ^^Constants\\
.index ^^Literal constants\\
.IF FOA;.NUMBER 111;.PS 80,80;.PAGE;
.ENDIF FOA
^OTHER NUMBER SYSTEMS THAN DECIMAL
.BR
---------------------------------
.B 1
^CONSTANTS MAY HAVE A RADIX OF 2, 4, 8 OR 16 BY PUTTING THE
.index ^^Radix\\
.index ^^Constants, octal\\
.index ^^Constants, hexadecimal\\
.index ^^Whole number\\
.index ^^Number, binary, octal or hexadecimal\\
.index ^^Constants, binary\\
SEQUENCE "N^R" WHERE N IS THE RADIX, IMMEDIATELY IN FRONT
OF THE CONSTANT.  ^FOR RADIX 16, THE LETTERS ^A THROUGH ^F ARE USED
TO REPRESENT THE HEXADECIMAL EQUIVALENTS OF 10 TO 15.
.index ^^Octal constant\\
.index ^^Number systems\\
.index ^^Hexadecimal constant\\
.index ^^Binary constant\\
.index ^^Hexadecimal constant\\
.B 1
^EXAMPLES:
.B 1;.NF;.NJ
     16^R56789     HEXADECIMAL
     16^R^B1^F^F      HEXADECIMAL
     2^R10110011   BINARY
.index ^^Binary constant\\
     8^R7777777    OCTAL
.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 112;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
^^BOOLEAN\\-CONSTANTS
.index ^^Constants, Boolean\\
.index ^^Constants, logical\\
.BR
-----------------
.B 1
^THESE ARE THE KEY WORDS ^^FALSE\\ AND ^^TRUE\\ WHOSE INTERPRETATION
.index ^^TRUE\\
.index ^^FALSE\\
IS OBVIOUS.
.B 2
^^CHARACTER\\-CONSTANTS ARE REPRESENTED BY
.index ^^Constants, character\\
.BR
-------------------
.B 1
'[ANY ONE PRINTABLE MEMBER OF THE DATA CHARACTER SET]'##(1)
.index ^^Printable character\\
.index ^^CHARACTER, printable\\
.index ^^CHARACTER quote (')\\
.FN 3
.B 1
-------------
.BR
(1)##^BY A PRINTABLE CHARACTER IS MEANT A CHARACTER WITH ^^RANK\\
.break
BETWEEN 40 AND 176 (OCTAL), I.E. 32 and 126 (DECIMAL).
!
.B 1
^EXAMPLES:
.B 1
^VALID ^^CHARACTER\\-CONSTANTS:
.BR
-----
.B 1;.LM 5
'^X'
.BR
'_&'
.BR
'#'
.BR
'''####THE CHARACTER QUOTE ITSELF
.B 1;.I -5
^INVALID ^^CHARACTER\\-CONSTANTS:
.I -5
-------
.B 1
':-'####TWO DATA CHARACTER SET MEMBERS
.BR
'^A#'####BLANKS ARE SIGNIFICANT IN CHARACTER CONSTANTS
.index ^^Blank, in CHARACTER constant\\
.BR
^X#######NO EMBEDDING CHARACTER QUOTES
.BR
'4######NO TERMINATING CHARACTER QUOTE.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
.index ^^Constants\\
.index ^^Literal constants\\
.B 3;.LM 0
.IF FOA;.NUMBER 113;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Constants\\
.index ^^Literal constants\\
^^TEXT\\-CONSTANTS HAVE THE FORM
.index ^^Constants, text (=character string)\\
.BR
--------------
.B 1
"[ANY SEQUENCE OF PRINTABLE MEMBERS OF THE DATA CHARACTER SET]"(2)
.index ^^TEXT quote (")\\
.FN 4
.B 1
-------------
.BR
(2)##^BY A PRINTABLE CHARACTER IS MEANT A CHARACTER WITH ^^RANK\\
.break
BETWEEN 40 AND 176 (OCTAL), I.E. BETWEEN 32 AND 126 (DECIMAL).
!
.B 1
^A ^^TEXT\\ CONSTANT CAN CONTAIN THE DEVICE CONTROL CHARACTERS ^V^T, ^C^R,
^L^F AND ^F^F, BUT THESE ARE NOT TREATED AS PART OF THE TEXT
CONSTANT.  ^TO INCLUDE THE CHARACTER " IN A TEXT CONSTANT,
REPEAT IT TWICE.  ^THE LENGTH OF A ^^TEXT\\ CONSTANT IS THE NUMBER
OF PRINTABLE CHARACTERS IT CONTAINS.  ^THE LENGTH MAY BE A NATURAL
NUMBER IN THE RANGE 0 THROUGH 2_^15.  (^NOTE THAT TEXT VARIABLES CAN BE LONGER THAN THIS!)
^BLANKS ARE SIGNIFICANT IN TEXT CONSTANTS.
.index ^^Blank, in TEXT constant\\
.B 1
(^HOWEVER, A TEXT VARIABLE CAN CONTAIN DEVICE CONTROL
CHARACTERS, AND IT IS EASY TO COPY A TEXT CONSTANT TO A
VARIABLE AND THEN USE ^^"T.PUTCHAR(CHAR\\(N))" TO INSERT
THE CHARACTER WITH ^^RANK\\ N (DECIMAL) INTO IT.)
.B 1
^EXAMPLES
.B 2
^VALID ^^TEXT \\CONSTANTS
.BR
-----
.B 1;.LM 5
"^^THISTEXTCONSTANTHASNOBLANKS"
.BR
"THIS ONE HAS"
.BR
"""THIS ONE BEGINS AND ENDS WITH A DOUBLE-QUOTE\\"""
.index ^^TEXT constant containing double quote (")\\
.index ^^Quote, double, inside TEXT constants\\
.index ^^Double quote inside TEXT constants\\
.NOFILL;.UC;.B
"MULTI-"  _\   Equivalent to:
"LINE "    -  "MULTI-LINE TEXT"
"TEXT"    /
.FILL;.LC;.B 2;.LM 0
^INVALID ^^TEXT\\ CONSTANTS:
.BR
-------
.B 1;.LM 5
^^"ONE " TOO MANY"\\#######IMBEDDED DOUBLE-QUOTE IS NOT DOUBLED
.BR
"^^NEVER ENDING\\##########CONTAINS NO TERMINATING DOUBLE-QUOTE
.B 2;.LM 0
^OBJECT-REFERENCE-CONSTANT
.index ^^Constants, reference\\
.BR
-------------------------
.B 1
^THERE IS ONLY ONE OBJECT-REFERENCE-CONSTANT, NAMELY
.B 1;.I 5
^^NONE\\
.index ^^NONE\\
.B 1
^ANY OBJECT REFERENCE VARIABLE MAY TAKE THE VALUE ^^NONE\\.
.SUBTITLE ^^CHAPTER\\ 2.5
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 114;.PS 80,80;.PAGE;
.ENDIF FOA
2.5##^^DECLARATIONS\\
.BR
#####------------
.B 1
^DECLARATIONS INTRODUCE A MEASURE OF SECURITY INTO THE LANGUAGE
BY ASSOCIATING IDENTIFIERS WITH VARIABLES, ARRAYS, SWITCHES,
.index ^^Identifier\\
PROCEDURES AND CLASSES USED IN THE PROGRAMS.
.B 1
^A DECLARATION DETERMINES THE TYPE AND STRUCTURE OF A QUANTITY.
.index ^^Declaration\\
.B 1
^DECLARATIONS MUST APPEAR IN A BLOCK HEAD, AND UPON EXIT FROM
.index ^^Exit from a block\\
.index ^^Block head\\
THAT BLOCK (UNLESS IT IS THE OUTERMOST BLOCK OF A CLASS BODY),
.index ^^CLASS body\\
THEY LOSE THEIR SIGNIFICANCE.
.B 2
DECLARATION
.BR
-----------
.B 2;.LM 10;.NJ;.NF
 **                      **
 *  ^^TYPE\\-DECLARATION      *
.index ^^Type declaration\\
 *  ^^ARRAY\\-DECLARATION     *
 *  ^^SWITCH\\-DECLARATION    *
**  ^^PROCEDURE\\-DECLARATION **
 *  ^^CLASS\\-DECLARATION     *
 *  ^^EXTERNAL\\-DECLARATION  *
 **                      **
.B 1;.LM 0;.RM 70;.F;.J
^COMMON TO EACH OF THE SUCCEEDING SECTIONS, WHICH DISCUSS THESE
DECLARATIONS, IS THE DEFINITION OF AN IDENTIFIER-LIST.

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 115;.PS 80,80;.PAGE;
.ENDIF FOA
IDENTIFIER-LIST
.BR
---------------
.B 1;.I 5
IDENTIFIER#[,#IDENTIFIER]...
.B 1
IN WHICH THE IDENTIFIERS MUST ALL BE DIFFERENT.
.B 2
^EXAMPLES:
.BR
--------
.B 2
^VALID
.BR
-----
.B 1;.I 5
^^AXOLOTL\\
.I 5
^^A,#B,#MARY,#B__14\\
.B 2
^INVALID
.BR
-------
.B 1;.LM 20;.TS 20;.I -15
^^A##B\\	NO SEPARATING COMMA
.B 1;.I -15
^^A,#END,#Q\\	^^END\\ IS A KEY WORD AND IS NOT ALLOWED
AS AN IDENTIFIER.
.B 1;.I -15
^^B1,B2,#B1\\	THE SAME IDENTIFIER APPEARS TWICE
.B 1;.I -20
^^BIORTHOGONAL,#BIORTHOGONALISATION\\
.BR
THE IDENTIFIERS ARE NOT DISTINCT (ONLY THE FIRST TWELVE
CHARACTERS ARE SIGNIFICANT).
.SUBTITLE ^^CHAPTER\\ 2.5.1
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70
.IF FOA;.NUMBER 116;.PS 80,80;.PAGE;
.ENDIF FOA
2.5.1##^^TYPE DECLARATIONS\\
.index ^^Type declaration\\
.B 1
^TYPE DECLARATIONS ASSOCIATE EACH IDENTIFIER IN THE ASSOCIATED
IDENTIFIER LIST WITH A VARIABLE OF A GIVEN TYPE.  ^THIS RESTRICTS
.index ^^Identifier list\\
THE RANGE OF VALUES THAT MAY BE ASSIGNED TO THAT VARIABLE.
.B 2
TYPE-DECLARATION
.index ^^Variable type declarations\\
.index ^^Variable name declarations\\
.BR
----------------
.B 2;.LM 10;.NJ;.NF
 **                       **
^^ *  [LONG]REAL             *
.index ^^REAL\\
.index ^^LONG REAL, syntax\\
 *  [SHORT]INTEGER (3)     *
.index ^^SHORT INTEGER\\
.index ^^INTEGER\\
 *  CHARACTER              *
.index ^^CHARACTER\\
**  BOOLEAN                **  \\IDENTIFIER-LIST^^
.index ^^BOOLEAN\\
 *  REF(CLASS\\-IDENTIFIER)  *
.index ^^REF\\
^^ *  TEXT                   *\\
.index ^^TEXT\\
 **                       **
.FN 4
.B 1
-------------
.BR
(3)##^^SHORT\\ IS INCLUDED FOR COMPATIBILITY WITH 360/370 ^^SIMULA\\,
.index ^^SHORT INTEGER\\
.index ^^IBM 360/370 type compatibility with\\
BUT ON THE ^^DEC\\#10 BOTH ^^SHORT INTEGERS\\ AND ^^INTEGERS\\ ARE IN FACT
STORED IN FULL 36 BIT WORDS.
!
.B 2;.LM 0;.F;.J
^EXAMPLES:
.BR
--------
.B 2
VALID:
.BR
-----
.B 1;.LM 20;.TS 20;.I -15
VALUE-TYPE	^^REAL R1, R2
.index ^^Value type\\
.BR
LONG REAL P1
.BR
INTEGER I, J, K
.BR
SHORT INTEGER SH1
.BR
CHARACTER A, B, C, D
.BR
BOOLEAN B1, B2, B3\\
.B 1;.I -15
REFERENCE-TYPE	^^REF(POINT) P, Q
.BR
TEXT MY__STRING, YOUR__STRING\\
.B 2;.LM 0
INVALID:
.BR
-------
.B 1;.LM 5;.NF;.NJ
^^SHORT REAL ONE\\##########^NO SUCH TYPE
^^REF LINE__1, LINE__2\\######^NO SUCH TYPE - THE QUALIFICATION
                                 IS OMITTED.
.B 1;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 117;.PS 80,80;.PAGE;
.ENDIF FOA
^^INTEGER\\ AND ^^SHORT INTEGER\\ VARIABLES MAY ONLY ASSUME WHOLE
.index ^^Whole number\\
.index ^^INTEGER declaration\\
.index ^^Assignable range, SHORT INTEGER\\
.index ^^Range of values, SHORT INTEGER variable\\
.index ^^Assignable range, INTEGER\\
.index ^^Range of values, INTEGER variable\\
NUMBERS.
.B 1
^^REAL\\ AND ^^LONG REAL\\ VARIABLES MAY ONLY ASSUME NUMBERS.
.index ^^REAL declaration\\
.index ^^LONG REAL declaration\\
.index ^^REAL, assignable range\\
.index ^^LONG REAL, assignable range\\
.index ^^Assignable range, REAL\\
.index ^^Range of values, REAL variable\\
.index ^^Assignable range, LONG REAL\\
.index ^^Range of values, LONG REAL variable\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^N.^B.  ^AN ARITHMETIC EXPRESSION OF ANY ARITHMETIC TYPE (^^SHORT
INTEGER, INTEGER, REAL, LONG REAL\\) MAY BE ASSIGNED TO AN ARITHMETIC
VARIABLE.  ^IF THE TYPES DO NOT CORRESPOND,  THE EXPRESSION
.index ^^Type conversion (arithmetic)\\
.index ^^Arithmetic type conversion\\
IS FIRST CONVERTED TO THE TYPE OF THE VARIABLE AND THEN TRANSFERRED,
SUBJECT TO ITS BEING IN RANGE.  ^IF IT IS NOT IN RANGE,
THEN A RUN TIME ERROR WILL RESULT.
.B 1
^^BOOLEAN\\ VARIABLES MAY ONLY ASSUME THE VALUES ^^TRUE\\ AND ^^FALSE\\.
.index ^^Assignable range, BOOLEAN\\
.index ^^Range of values, BOOLEAN variable\\
.B 1
^^CHARACTER\\ VARIABLES MAY ONLY ASSUME VALUES FROM THE DATA
.index ^^Assignable range, CHARACTER\\
.index ^^Range of values, CHARACTER variable\\
CHARACTER SET.
.B 1
^^TEXT\\ VARIABLES MAY ONLY ASSUME STRINGS OF CHARACTERS FROM THE
.index ^^Assignable range, TEXT\\
.index ^^Range of values, TEXT variable\\
DATA CHARACTER SET OR ^^NOTEXT\\.
.B 1
^^REF\\ VARIABLES MAY ONLY ASSUME THE VALUE ^^NONE\\ OR REFERENCES TO
.index ^^Assignable range, REF\\
.index ^^Range of values, REF variable\\
OBJECTS BELONGING TO THEIR QUALIFYING CLASS OR ITS SUBCLASSES.
.index ^^Subclass\\
.index ^^Qualifying CLASS\\
.B 1
^^SIMULA has no built-in COMPLEX arithmetic, but it is easy to
.index ^^COMPLEX arithmetic\\
define COMPLEX yourself as
.B 1;.NOFILL;.LM 10
CLASS complex(re,im);
REAL re, im;
BEGIN
   REF (complex) PROCEDURE plus(arg2);
   REF (complex) arg2;
   BEGIN ...
   END;
   ...
END;\\
.FILL;.LM 0;
.B 1
.IF FOA;.NUMBER 118;.PS 80,80;.PAGE;
.ENDIF FOA
^EACH VARIABLE DECLARED IN A TYPE DECLARATION HAS AN INITIAL
VALUE (GIVEN IN THE TABLE BELOW).  ^THEREAFTER THE VALUE OF A
.index ^^Initial value for each variable type (table)\\
.index ^^Default initial variable value (table)\\
VARIABLE IS THE ONE LAST ASSIGNED TO IT,  OR IF NO ASSIGNMENT
HAS YET BEEN MADE, THE INITIAL VALUE.
.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.TS 5,15,35
.index ^^Initial value for each variable type (table)\\
.index ^^Assignable range of variables, table\\
.index ^^Precision of variables, table\\
.index ^^Maximum value of variables, table\\
.index ^^Minimum value of variables, table\\
.index ^^Variable values, table of allowed values\\
.index ^^Values of variables, table of range\\
.index ^^Range of variables, table of\\
	^TYPE	^INITIAL VALUE	^ASSIGNABLE RANGE
.index ^^Quantity\\
.BR
	----	-------------	----------------
.B 1;.LM 29;.RM 70;.TS 19,29;.I -29
.index ^^INTEGER, assignable range\\
.index ^^SHORT INTEGER, assignable range\\
.B 1;.I -29
^^[SHORT] INTEGER\\	#0	^WHOLE NUMBER IN THE RANGE
-2_^35 THROUGH 2_^35-1.
.B 1;.I -29
.index ^^Floating point value range\\
.index ^^REAL, assignable range\\
.index ^^LONG REAL, assignable range\\
.B 1;.I -29
^^[LONG] REAL\\	#0.0	^EXACT 0 OR +- A NUMBER IN THE RANGE 0.146#936#793#852#785#939_&_&-38 TO
0.170#141#183#460#469#231_&_&+39 TO 9 DECIMAL PLACES FOR ^^REAL\\ VARIABLES
AND TO 18 DECIMAL PLACES FOR ^^LONG#REAL\\ VARIABLES.
.B 1;.I -29
^^BOOLEAN	FALSE	TRUE, FALSE.\\
.index ^^BOOLEAN, assignable range\\
.B 1;.I -29
^^CHARACTER	CHAR(0)	CHAR(0), CHAR(1),#... CHAR(127)\\.
.index ^^CHARACTER, assignable range\\
.B 1;.I -29
.NO JUSTIFY
^^REF(CLASS-\\	^^NONE\\	^^NONE\\#OR#ANY#OBJECT#OF#THE#QUALIFYING#CLASS
.JUSTIFY
.index ^^REF variable, assignable range\\
.I -25
IDENTIFIER)		OR INCLUDED IN THE QUALIFYING CLASS.
.B 1;.I -29
^^TEXT	NOTEXT	NOTEXT\\ OR ANY STRING OF CHARACTERS
.index ^^Initial value for each variable type (table)\\
.index ^^TEXT variable, assignable range\\
FROM THE DATA CHARACTER SET OF LENGTH 0 THROUGH 2_^18-1 CHARACTERS.
^THE TEXT CONSTANT "" IS IDENTICAL TO ^^NOTEXT\\.
.SD 70;.PS 58,70
\\
.SUBTITLE ^^CHAPTER\\ 2.5.2
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 119;.PS 80,80;.PAGE;
.ENDIF FOA
2.5.2##^^ARRAY DECLARATIONS\\
.index ^^ARRAY declaration\\
.index ^^ARRAY\\
.index ^^ARRAY declaration\\
.B 1
^AN ARRAY IS A STRUCTURE OF MANY COMPONENTS (SUBSCRIPTED
VARIABLES) ALL OF THE SAME TYPE. ^EACH COMPONENT HAS THE SAME IDENTIFIER
.index ^^ARRAY component\\
(THE ARRAY IDENTIFIER), AND THEY ARE DISTINGUISHED ONE FROM
ANOTHER BY SUBSCRIPTS. ^ARRAYS INVITE THE USER TO GROUP LIKE
.index ^^Subscripted variable\\
DATA UNDER ONE IDENTIFIER.
.B 1
^ARRAYS ARE DECLARED WITH A CERTAIN SHAPE. ^THEY CAN HAVE 1
THROUGH 10 DIMENSIONS (WHICH IS THE NUMBER OF SUBSCRIPTS NECESSARY
.index ^^ARRAY dimension\\
TO SPECIFY A CERTAIN COMPONENT), AND EACH DIMENSION HAS A FIXED
RANGE SPECIFIED BY GIVING AN UPPER AND LOWER BOUND.
.index ^^Upper subscript bound\\
.index ^^Upper bound\\
.index ^^Subscript bound\\
.index ^^Lower subscript bound\\
.index ^^Lower bound\\
.B 1
^PICTORIAL REPRESENTATIONS OF ONE, TWO AND THREE DIMENSIONAL
ARRAYS ARE NOW GIVEN.
.B 1
.IF FOA;.NUMBER 120;.PS 80,80;.PAGE;
.ENDIF FOA
^ONE DIMENSIONAL ARRAY
.index ^^Vector\\
.index ^^One dimensional array\\
.B 1
^^INTEGER ARRAY NUMBER [4:9];\\
.index ^^Bracket, square ([ and ])\\
.index ^^Parenthesises, square ([ and ])\\
.index ^^Parenthesises (( and ))\\
.index ^^Left parenthesis (()\\
.index ^^Right parenthesis ())\\
.index ^^Left square bracket\\
.index ^^Right square bracket\\
.index ^^Square bracket ([ and ])\\
.B 2;.NF;.NJ
^^         -------------
         ! NUMBER[4] !
         -------------
         ! NUMBER[5] !
         -------------
         ! NUMBER[6] !
         -------------
         ! NUMBER[7] !
         -------------
         ! NUMBER[8] !
         -------------
         ! NUMBER[9] !
         -------------\\
.B 2;.LM 0;.F;.J
^DIMENSIONS 1:
.BR
^LOWER SUBSCRIPT BOUND#=#4
.BR
^UPPER SUBSCRIPT BOUND = 9
.BR
^DECLARES 6 SUBSCRIPTED VARIABLES EACH OF TYPE ^^INTEGER\\ AND INITIALIZED TO 0.
.index ^^ARRAY initialization of\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^EXAMPLE:
.B 1
^FIND THE SUM OF THE COMPONENTS OF THE ARRAY ^^NUMBER.\\
.B 1;.I 5
^^SUM#:=#0;
.I 5
FOR I#:=#4 STEP 1 UNTIL 9 DO
.I 9
SUM#:=#SUM + NUMBER[I];\\
.B 2
.IF FOA;.NUMBER 121;.PS 80,80;.PAGE;
.ENDIF FOA
^TWO DIMENSIONAL ARRAY
.index ^^ARRAY, two-dimensional\\
.index ^^Matrix handling\\
.B 1
^^REF(POINT) ARRAY A[0:3, 2:4];
.B 2;.NF;.NJ;.LM 9
-------------------------------------
_! A[0, 2]   !  A[0, 3]   !  A[0, 4] !
-------------------------------------
_! A[1, 2]   !  A[1, 3]   !  A[1, 4] !
-------------------------------------
_! A[2, 2]   !  A[2, 3]   !  A[2, 4] !
-------------------------------------
_! A[3, 2]   !  A[3, 3]   !  A[3, 4] !
-------------------------------------\\
.B 2;.LM 0;.F;.J
^DIMENSIONS 2:
.BR
^LOWER SUBSCRIPT BOUND 1 = 0
.BR
^UPPER SUBSCRIPT BOUND 1 = 3
.BR
^LOWER SUBSCRIPT BOUND 2 = 2
.BR
^UPPER SUBSCRIPT BOUND 2 = 4
.B 1
^DECLARES 12 SUBSCRIPTED VARIABLES EACH OF TYPE ^^REF(POINT)\\
AND EACH INITIALIZED TO ^^NONE.\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^EXAMPLE:
.B 1
^SCAN THE ARRAY AND COUNT HOW MANY SUBSCRIPTED VARIABLES ARE
CURRENTLY REFERENCING ^^NONE.\\
.B 1;.I 5
^^COUNT := 0;
.I 5
FOR I := 0 STEP 1 UNTIL 3 DO
.I 5
FOR J := 2 STEP 1 UNTIL 4 DO
.I 13
IF A[I, J] == NONE
.I 16
THEN COUNT := COUNT + 1;\\
.B 2
.IF FOA;.NUMBER 122;.PS 80,80;.PAGE;
.ENDIF FOA
^THREE DIMENSIONAL ARRAY
.index ^^ARRAY, three-dimensional\\
.B 1
^^BOOLEAN ARRAY B[0:2, 0:3, -1:0];\\
.B 2;.LM 5;.NJ;.NF
^^
    /-----------------------------------------------/
   / B[0,0,0]  / B[0,1,0]  / B[0,2,0]  / B[0,3,0]  /!
  /-----------/-----------/-----------/-----------/ !
 /           /           /           /           /  !
/-----------------------------------------------/   !
_! B[0,0,-1] ! B[0,1,-1] ! B[0,2,-1] ! B[0,3,-1] !   !
_!-----------------------------------------------!   !
_! B[1,0,-1] ! B[1,1,-1] ! B[1,2,-1] ! B[1,3,-1] !   /
_!-----------------------------------------------!  /
_! B[2,0,-1] ! B[2,1,-1] ! B[2,2,-1] ! B[2,3,-1] ! /
_!-----------------------------------------------!/
.B 2;.LM 0;.F.J
(\\^EACH COMPONENT IS  REPRESENTED BY A CUBE).
.B 1
^DIMENSIONS 3:
.BR
^LOWER SUBSCRIPT BOUND 1 = 0
.BR
^UPPER SUBSCRIPT BOUND 1 = 2
.BR
^LOWER SUBSCRIPT BOUND 2 = 0
.BR
^UPPER SUBSCRIPT BOUND 2 = 3
.BR
^LOWER SUBSCRIPT BOUND 3 = -1
.BR
^UPPER SUBSCRIPT BOUND 3 = 0
.B 1
^SCAN THROUGH THE ARRAY AND SET THE VALUES OF EACH SUBSCRIPTED
VARIABLE TO ^^TRUE.\\
.B 1;.I 5
^^FOR I := 0 STEP 1 UNTIL 2 DO
.I 9
FOR J := 0 STEP 1 UNTIL 3 DO
.I 13
FOR K := -1 STEP 1 UNTIL 0 DO
.I 17
B[I,J,K] := TRUE;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
.IF FOA;.NUMBER 123;.PS 80,80;.PAGE;
.ENDIF FOA
^^ARRAY-\\DECLARATION
.B 1;.I 5
[TYPE] ^^ARRAY  ARRAY\\-SEGMENT [,^^ARRAY\\-SEGMENT]...
.index ^^ARRAY segment\\
.B 1
^^ARRAY-\\SEGMENT
.B 1;.I 5
IDENTIFIER-LIST (LOWER-BOUND:UPPER-BOUND
.I 26
[,LOWER-BOUND:UPPER-BOUND]...)
.B 2
^EXAMPLES:
.B 1;.TS 23
^^ARRAY\\-SEGMENT	^^A[1:10]
.BR
	B,C[1:15, 0:N**2]
.B 1
ARRAY\\-DECLARATION	^^ARRAY ALFA [0:N]
.BR
	REF(LINE) ARRAY L,M[0:P.X]
.BR
	TEXT ARRAY R,S[1:5], T[1:4,ININT:IF X=0
.TS 49;.BR
	THEN 10 ELSE 100]\\
.B 2;.LM 0;.F;.J
^EACH IDENTIFIER IN AN ARRAY DECLARATION IS ASSOCIATED WITH AN
.index ^^ARRAY declaration\\
ARRAY OF A GIVEN TYPE (IF NO TYPE IS GIVEN, THE TYPE IS TAKEN
TO BE ^^REAL\\). ^TO ENABLE ARRAYS OF THE SAME TYPE, BUT WITH
DIFFERENT SHAPES (NUMBER OF DIMENSIONS AND SUBSCRIPT RANGES)
TO BE DECLARED IN THE SAME PLACE, AN ARRAY DECLARATION CONTAINS
ONE OR MORE ^^ARRAY\\-SEGMENTS WHICH ARE IDENTIFIER-LISTS FOLLOWED
BY THEIR COMMON SHAPE. ^THE NUMBER OF DIMENSIONS IS THE NUMBER
OF UPPER-BOUND LOWER-BOUND PAIRS AND THE RANGE OF EACH SUBSCRIPT
IS SPECIFIED DIRECTLY BY THE UPPER-BOUND/LOWER-BOUND PAIRS TAKEN IN ORDER.
.B 1
^NOTE THAT ALTHOUGH THE LOWER- AND UPPER-BOUNDS MAY BE ARITHMETIC
EXPRESSIONS THEIR VALUE IS THE ROUNDED INTEGER AS EVALUATED
ON ENTRY TO THE BLOCK. ^TO BE VALID, THE VALUE OF EACH LOWER
BOUND MUST BE LESS THAN OR EQUAL TO THE VALUE OF ITS ASSOCIATED
UPPER BOUND. ^NEITHER BOUND MAY REFER TO A QUANTITY DECLARED
IN THE SAME BLOCK HEAD. ^THE VALUE OF EACH SUBSCRIPTED VARIABLE
IS INITIALIZED ACCORDING TO THE TYPE OF THE ARRAY.
.index ^^ARRAY initialization of\\
.SUBTITLE ^^CHAPTER\\ 2.5.3
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 124;.PS 80,80;.PAGE;
.ENDIF FOA
2.5.3##^^SWITCH DECLARATIONS\\
.index ^^Statement number, variable\\
.index ^^Label, variable\\
.index ^^Jump statement, variable, computed, assigned\\
.index ^^GO TO, computed\\
.index ^^GO TO, assigned\\
.index ^^CASE statement, see SWITCH\\
.index ^^SWITCH declaration\\
.B 1
^A SWITCH IS DECLARED WITH A LIST OF DESIGNATIONAL-EXPRESSIONS
WHICH ARE ACCESSED BY AN INDEX. ^THE LENGTH OF THE LIST, ^N,
.index ^^SWITCH list\\
GIVES THE NUMBER OF SWITCH ELEMENTS. ^THE VALUE OF EACH ELEMENT
IS THE CURRENT VALUE OF THE DESIGNATIONAL-EXPRESSION (A LABEL
.index ^^SWITCH designator\\
.index ^^Designational expression\\
TO A STATEMENT, OR ANOTHER SWITCH VALUE).
.B 1
^^SWITCH\\-DECLARATION
.B 1
^^SWITCH SWITCH\\-IDENTIFIER := DESIGNATIONAL-EXPRESSION
.index ^^SWITCH identifier\\
.I 32
[,DESIGNATIONAL-EXPRESSION]...
.B 2
^EXAMPLES:
.B 1
^^SWITCH SW := L1, L2, T[N], M1
.BR
SWITCH T := M1, IF N<0 THEN L1 ELSE L3, M1\\
.B 2
^A ^^SWITCH\\ DECLARATION CONTAINS A LIST OF DESIGNATIONAL EXPRESSIONS
EACH OF WHICH IS GIVEN A POSITIVE INDEX (STARTING FROM 1)
BY COUNTING THE ITEMS IN THE LIST FROM LEFT TO RIGHT. ^THE VALUE
OF THE SWITCH-DESIGNATOR (SEE SECTION 6.6) CORRESPONDING TO A GIVEN
INDEX IS THE CURRENT VALUE OF THE DESIGNATIONAL EXPRESSION HAVING
THE INDEX IN THE CORRESPONDING LIST. (^AN EXPRESSION IN A SWITCH
LIST IS RE-EVALUATED EVERY TIME IT IS REFERRED TO).
.SUBTITLE ^^CHAPTER\\ 2.5.4
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 125;.PS 80,80;.PAGE;
.ENDIF FOA
2.5.4##^^PROCEDURE DECLARATION\\
.index ^^Proper PROCEDURE declaration\\
.index ^^PROCEDURE declaration\\
.B 1
^A PROCEDURE DECLARATION DEFINES AN ACTION CLUSTER AND GIVES
IT A FORMAL NAME. ^THE ACTION CLUSTER IS THE BODY OF THE ^^PROCEDURE.\\
.index ^^Subroutine\\
.index ^^PROCEDURE body\\
.index ^^PROCEDURE\\
^TO INCREASE THE GENERALITY OF THE CONCEPT, THERE ARE FACILITIES
FOR TRANSMITTING PARAMETERS AND RETURNING A FUNCTION VALUE AT
.index ^^Parameter to a PROCEDURE\\
.index ^^Function\\
RUN TIME. ^THUS A PROCEDURE IS ABLE TO INTERACT WITH ITS CALLING
ENVIRONMENT BY BINDINGS ESTABLISHED BY THE CALLING MECHANISM.
.B 1
^BY MEANS OF THE PROCEDURE CONCEPT, SPECIAL INSTANCES OF DECLARED
ACTION CLUSTERS BECOME MEANINGFUL UNITS WITHIN THE ^^SIMULA\\ PROGRAM.
.B 1
^^PROCEDURE\\-DECLARATION
.BR
---------------------
.B 2;.LM 10;.NJ;.NF
 **                              **
 *  PROPER-PROCEDURE-DECLARATION  *
**                                **
 *  FUNCTION-DECLARATION          *
.index ^^Function declaration\\
 **                              **
.B 2;.LM 0;.F;.J
PROPER-PROCEDURE-DECLARATION
.BR
----------------------------
.B 1
.I 10
^^PROCEDURE##PROCEDURE\\-HEADING##^^PROCEDURE\\-BODY
.index ^^PROCEDURE heading\\
.B 1
FUNCTION-DECLARATION
.BR
--------------------
.index ^^Function declaration\\
.B 1
.I 10
TYPE ^^PROCEDURE##PROCEDURE\\-HEADING##^^PROCEDURE\\-BODY
.B 1
^^PROCEDURE\\-HEADING
.BR
-----------------
.B 2;.LM 0;.NJ;.NF;.RM 75
                      **                                          **
                      *                     ;                      *
.index ^^Semicolon (;)\\
^^PROCEDURE-IDENTIFIER\\ **  FORMAL-PARAMETER-PART MODE-PART SPEC-PART **
.index ^^PROCEDURE identifier\\
.index ^^Mode part\\
                      *                                            *
                      **                                          **

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.PS 58,70;.F;.J
.IF FOA;.NUMBER 126;.PS 80,80;.PAGE;
.ENDIF FOA
FORMAL-PARAMETER-PART
.BR
---------------------
.B 1
(IDENTIFIER-LIST);##(4)
.FN 2
(4)##^THE MAXIMUM NUMBER OF PARAMETERS IS 255.
.END FOOTNOTE
.index ^^Identifier list\\
.B 1
MODE-PART
.B 2;.LM 10;.NJ;.NF
^^ **                              **
 *  VALUE\\  IDENTIFIER-LIST;       *
.index ^^CALL by VALUE\\
.index ^^PROCEDURE, call by value\\
**                                **
 *  ^^NAME\\   IDENTIFIER-LIST;  ...  *
.index ^^Call by NAME, syntax of\\
.index ^^NAME, syntax of\\
 **                              **
.B 1;.LM 0;.F;.J
SPEC-PART
.index ^^SPEC part\\
.B 2;.LM 5;.NJ;.NF
 **                                                **
 *    **                **                          *
 *    *  TYPE            *                          *
 *    *  [TYPE] ^^ARRAY    *                          *
.index ^^ARRAY as a parameter\\
 *    *  PROCEDURE\\       *                          *
**   **  TYPE ^^PROCEDURE\\  **  IDENTIFIER-LIST;  ...  **
 *    *  ^^LABEL           *                          *
.index ^^Label\\
 *    *  SWITCH          *                          *
.index ^^SWITCH, as PROCEDURE parameter\\
 *    **                **                          *\\
 **                                                **
.B 2;.LM 0;.F;.J
PROCEDURE\\-BODY
.BR
--------------
.I 10
.B 1
STATEMENT
.B 2
^NOTE FOR IDENTIFIER-LIST IN MODE-PART AND SPEC-PART:
.B 1;.LM 3;.I -3
A)#^ONLY IDENTIFIERS FROM THE FORMAL-PARAMETER-PART MAY APPEAR,
.I -3
B)#EACH OF THOSE IDENTIFIERS MUST APPEAR ONLY ONCE IN THE MODE-PART AND
ONCE IN THE SPEC-PART.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0
.IF FOA;.NUMBER 127;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLES:
.B 1
PROPER-PROCEDURE-DECLARATION
.BR
----------------------------
.B 1;.LM 5;.TS 26;.NF;.NJ
^^PROCEDURE SWAP(A,B);	NAME A, B;
.index ^^Call by NAME, example of use\\
.index ^^NAME, example of use\\
	REAL A, B;
.TS 12
BEGIN	REAL X;
	X := A;
	A := B; B := X;
END ***SWAP***
.B 1
PROCEDURE OUTCOLUMN(A,N); REAL ARRAY A; INTEGER N;
.index ^^PROCEDURE OUTCOLUMN\\
.TS 12
BEGIN	INTEGER J;
	FOR J := 1 STEP 1 UNTIL N DO
.TS 16
	BEGIN  OUTFIX (A[J], 5, 12);
.TS 23
	OUTIMAGE;
.TS 16
	END;
END ***OUTCOLUMN***
.B 1
PROCEDURE TREETRAVERSE(N); REF(NODE)N;
.index ^^PROCEDURE TREETRAVERSE\\
INSPECT N DO
.TS 12
BEGIN	TREETRAVERSE(LEFTBRANCH);
	DUMP;
	TREETRAVERSE(RIGHTBRANCH);
END ***RECURSIVE TRAVERSE***\\
.B 1;.LM 0;.F;.J
^A PROPER-PROCEDURE IS USED AS A STATEMENT IN ITS OWN RIGHT.
.B 1;.I 5
^^INIMAGE
.B 1;.I 5
OUTTEXT("PROPER-PROCEDURE")
.index ^^OUTTEXT, example of use\\
.B 1;.I 5
IF B THEN SWAP(TEMP1,TEMP2)\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2
.IF FOA;.NUMBER 128;.PS 80,80;.PAGE;
.ENDIF FOA
FUNCTION-DECLARATION
.BR
--------------------
.B 1
^^REF(POINT) PROCEDURE ADD(Q); REF(POINT)Q;
.BR
###IF Q =/= NONE THEN ADD :- NEW POINT(X+Q.X,Y+Q.Y)
.B 1
REAL PROCEDURE NORM(A,N); REAL ARRAY A; INTEGER N;
.index ^^PROCEDURE NORM (REAL)\\
.BR
BEGIN  REAL T; INTEGER I;
.BR;.TS 7
	FOR I := 1 STEP 1 UNTIL N DO
.TS 11;.BR
	T := T + A[I]**2;
.TS 7;.BR
	NORM := SQRT(T)
.BR
END ***NORM***
.B 1
INTEGER PROCEDURE FACTORIAL(N); INTEGER N;
.index ^^PROCEDURE FACTORIAL (INTEGER)\\
.BR
IF N < 0 THEN ERROR ELSE
.BR
###IF N < 2 THEN FACTORIAL := 1
.BR;.TS 12
	ELSE FACTORIAL := N*FACTORIAL(N-1)\\
.B 2;.LM 0;.F;.J
^A FUNCTION RETURNS A VALUE OF THE TYPE INDICATED IN ITS DECLARATION,
AND MAY BE USED WHEREVER A VALUE OF THAT TYPE IS LEGAL. (^IT
MAY ALSO BE USED AS A STATEMENT IN WHICH CASE THE FUNCTION VALUE
IS IGNORED);
.B 1;.LM 5
^^P :- R.ADD(S)
.B 1
X := NORM(MATRIX, 10)
.B 1
IF NORM (MATRIX, 10) < _&-6 THEN
.BR
###OUTTEXT ("ELEMENTS ALL (ALMOST) ZERO")\\
.B 1;.LM 0
.IF FOA;.NUMBER 129;.PS 80,80;.PAGE;
.ENDIF FOA
^A ^^PROCEDURE\\-DECLARATION DEFINES A PROCEDURE ASSOCIATED 
WITH A ^^PROCEDURE\\-IDENTIFIER. ^THE CHIEF COMPONENT OF A ^^PROCEDURE\\
DECLARATION IS THE ^^PROCEDURE\\-BODY WHICH MAY BE ACTIVATED
THROUGH A ^^PROCEDURE\\-STATEMENT OR A FUNCTION-DESIGNATOR.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^IF THE PROCEDURE HAS FORMAL-PARAMETERS, THEN THEIR IDENTIFIERS
ARE LISTED IN THE FORMAL-PARAMETER PART. ^NO FORMAL-PARAMETER
IDENTIFIER MAY APPEAR MORE THAN ONCE, AND SPECIFICATIONS OF ALL FORMAL-PARAMETERS
MUST BE SUPPLIED. ^WHENEVER THE PROCEDURE IS ACTIVATED BY A
^^PROCEDURE\\-STATEMENT OR FUNCTION-DESIGNATOR, THE FORMAL-PARAMETERS
ARE EITHER ASSIGNED THE VALUES OF THE ACTUAL-PARAMETERS (CALL
.index ^^Actual parameter, transfer of\\
BY VALUE, CALL BY REFERENCE) OR ELSE REPLACED BY THE ACTUAL-PARAMETERS
(CALL BY NAME).
.index ^^PROCEDURE parameter transmission\\
.index ^^Parameter transmission to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
.B 1
^IDENTIFIERS IN THE ^^PROCEDURE\\-BODY WHICH ARE NOT FORMAL-PARAMETERS
ARE LOCAL IF DECLARED WITHIN THAT BODY, OTHERWISE THEY ARE
NON-LOCAL. ^A ^^PROCEDURE\\-BODY ACTS LIKE A BLOCK REGARDLESS
OF ITS FORMAT. ^CONSEQUENTLY, THE SCOPE OF ANY LABEL TO A STATEMENT
.index ^^Label inside a procedure\\
WITHIN THE BODY OR TO THE BODY ITSELF CAN NEVER BE EXTENDED
BEYOND THE ^^PROCEDURE\\-BODY. ^IN ADDITION, IF THE IDENTIFIER OF A FORMAL-PARAMETER
IS REDECLARED WITHIN THE ^^PROCEDURE-\\BODY (OR USED AS A LABEL),
.index ^^Label inside a procedure\\
IT IS GIVEN LOCAL SIGNIFICANCE AND THE CORRESPONDING ACTUAL-PARAMETER
.index ^^Actual parameter, redeclaration of\\
BECOMES INACCESSIBLE.
.B 1
^WHEN A ^^PROCEDURE-\\DECLARATION IS GIVEN A TYPE, IT DESIGNATES
A FUNCTION. ^THE TYPE OF THIS FUNCTION IS THE TYPE OF THE ^^PROCEDURE\\
AND FOR ANY ACTIVATION ITS VALUE IS THE LAST VALUE ASSIGNED TO
AN OCCURRENCE OF THE ^^PROCEDURE-\\IDENTIFIER WITHIN THE ^^PROCEDURE\\-BODY.
^IF NO SUCH ASSIGNMENT IS MADE, THEN THE RESULT OF THE FUNCTION-DESIGNATOR
TAKES A DEFAULT VALUE WHICH IS IDENTICAL TO THE INITIAL VALUE
.index ^^Default value of a function designator\\
OF A DECLARED VARIABLE OF THAT TYPE.
.B 1
.IF FOA;.NUMBER 130;.PS 80,80;.PAGE;
.ENDIF FOA
^WITHIN THE ^^PROCEDURE\\-BODY OF A FUNCTION-PROCEDURE, AN ASSIGNMENT
MAY BE MADE TO AN OCCURRENCE OF THE ^^PROCEDURE-\\IDENTIFIER.
^EVERY OTHER USE OF THE ^^PROCEDURE\\-IDENTIFIER DENOTES
ANOTHER ACTIVATION OF THE PROCEDURE (RECURSION).
.index ^^Recursion\\
^NOTE THAT IS PERFECTLY LEGAL TO USE A FUNCTION PROCEDURE CALL
AS A SINGLE STATEMENT (EXPLOATING IT'S SIDE EFFECTS PROBABLY).
^FOR EXAMPLE:##^^"SQRT(1);"\\ IS A LEGAL STATEMENT AS WELL AS
^^"LASTITEM;"\\ (SKIPS BLANKS AND TABS AND RETURNS
^^TRUE\\ IF END-OF-FILE IS ENCOUNTERED - SEE SECTION 3.5.)
.B 1
.index ^^RETURN from a subroutine\\
.index ^^PROCEDURE, return from\\
^^Execution of the procedure stops when control is passed to the
final END of the procedure body. Control is thereafter returned to
the place where the procedure was called.\\
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 131;.PS 80,80;.PAGE;
.ENDIF FOA
^^PARAMETER TRANSMISSION\\
.index ^^Parameters to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
.index ^^Parameter transmission\\
.index ^^PROCEDURE parameters\\
.B 1
^N.^B.##^THERE ARE THREE POSSIBLE MODES FOR PARAMETER TRANSMISSION
.index ^^Parameters to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
.B 1;.I 11
CALL BY VALUE
.I 11
CALL BY REFERENCE
.I 11
CALL BY NAME
.B 1
^ALL THREE ARE ALLOWABLE FOR PARAMETERS TO PROCEDURES, BUT ONLY
CALL BY VALUE AND CALL BY REFERENCE ARE VALID FOR PARAMETERS
TO CLASSES. ^SINCE CALL BY VALUE AND CALL BY REFERENCE ARE COMMON
.index ^^NAME parameters to classes disallowed\\
.index ^^Call by NAME, disallowed to classes\\
.index ^^Parameter transmission modes to classes\\
TO PROCEDURE AND CLASS DECLARATIONS, THESE SECTIONS APPLY TO CLASS
DECLARATIONS AS WELL.
.B 1
^IF NO MODE IS SPECIFIED IN THE MODE PART, THEN THE PARAMETER IS TRANSMITTED
.index ^^Parameters to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
BY THE APPROPRIATE DEFAULT MODE WHICH IS CALL BY VALUE FOR VALUE TYPE
.index ^^VALUE (Parameter transmission mode), default\\
.index ^^CALL by VALUE, default\\
PARAMETERS, AND CALL BY REFERENCE FOR OTHER KINDS OF PARAMETERS.
.index ^^Call by reference, default\\
.B 1
^THE AVAILABLE TRANSMISSION MODES FOR LEGAL PARAMETERS TO PROCEDURES
.index ^^Parameters to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
ARE SHOWN IN THE FOLLOWING TABLE:
.IF FOA;.NUMBER 132;.PS 80,80;.PAGE;
.ENDIF FOA
.B 2;.C
^^PROCEDURE PARAMETERS\\
.index ^^PROCEDURE parameters (table)\\
.index ^^Parameters to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
.index ^^PROCEDURE parameters\\
.B 1;.LM 0;.NF;.NJ;.TS 35
^PARAMETER	^TRANSMISSION
.index ^^Parameters to a procedure\\
.index ^^Argument to a procedure, see Parameter\\
.index ^^Type of PROCEDURE parameters\\
.index ^^Default mode of parameter transmission\\
.index ^^PROCEDURE parameters\\
.B 1;.TS 25,37,53
	BY VALUE	BY REFERENCE	BY NAME
.index ^^CALL by VALUE for procedures, table\\
.index ^^VALUE Parameter for procedure, table\\
.index ^^Call by reference for procedures, table\\
.index ^^Call by NAME for procedures, table\\
.index ^^NAME parameters for procedures, table\\
.B 1;.TS 29,43,56
VALUE-TYPE	^D	^X	^O
OBJECT-REFERENCE	^X	^D	^O
^^TEXT	^O	D	^O\\
VALUE-TYPE ^^ARRAY	^O	D	^O\\
REFERENCE-TYPE ^^ARRAY	X	D	^O\\
^^PROCEDURE	X	D	^O\\
TYPE ^^PROCEDURE	X	D	^O\\
^^LABEL	X	D	^O
.index ^^Label, as procedure parameter, table\\
SWITCH	X	D	^O\\
.B 1
^D : DEFAULT MODE
^O : OPTIONAL
^X : ILLEGAL

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 133;.PS 80,80;.PAGE;
.ENDIF FOA
^CALL BY VALUE
.index ^^VALUE (Parameter transmission mode)\\
.index ^^PROCEDURE parameters\\
.BR
-------------
.B 1
^A FORMAL-PARAMETER CALLED BY VALUE DESIGNATES A LOCAL COPY
OF THE VALUE OBTAINED BY EVALUATING THE ACTUAL PARAMETER. ^THE
.index ^^Actual parameter, transfer by value\\
EVALUATION TAKES PLACE AT THE TIME OF PROCEDURE ENTRY. ^THROUGHOUT
THE LIFESPAN OF THE PROCEDURE OR CLASS BODY, THE FORMAL-PARAMETER ACTS LIKE
.index ^^CLASS body\\
A LOCAL VARIABLE (OR VALUE TYPE ARRAY#(5)) AND ITS CONTENTS MAY BE
.FN 4
-----------------------------------------------------------
.break
(5)##^THE TYPE OF AN ARITHMETIC ^^ARRAY\\ PASSED BY ^^VALUE\\ MUST
BE IDENTICAL TO THE FORMAL TYPE.
.END FOOTNOTE
ACCESSED AND CHANGED BY LOCAL ASSIGNMENTS. ^IN THE CASE OF AN
OBJECT, THE CONTENTS MAY BE ACCESSED AND CHANGED FROM WITHOUT
BY REMOTE ACCESSING.
.B 1
^VALUE SPECIFICATION IS REDUNDANT FOR A PARAMETER OF VALUE TYPE.
^THERE IS NO CALL BY VALUE OPTION FOR OBJECT REFERENCES, REFERENCE-TYPE
^^ARRAYS, PROCEDURES,\\ TYPE-^^PROCEDURES, LABELS\\ AND ^^SWITCHES.\\
.index ^^Label, as procedure parameter\\
.B 1
^EXAMPLE:
.B 1
^GIVEN THE PROGRAM:
.B 1;.LM 12;.TS 12;.NF;.NJ;.I -7
^^BEGIN	PROCEDURE CALL__BY__VALUE__(X,Y,T1,T2,B);
VALUE T1, T2, B;
REAL X, Y; TEXT T1, T2; BOOLEAN ARRAY B;
BEGIN .................... END;
.B 1
BOOLEAN ARRAY TRUTH[0:3];
TEXT S;
REAL NUM;
NUM := 3.5; S :- COPY("+++");
TRUTH[2] := TRUE;
CALL__BY__VALUE(4,NUM,S,"O.K",TRUTH);
_...
.I -7
END\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
THEN A SNAPSHOT ON PROCEDURE ENTRY SHOWS THE INITIALIZED VALUES
FOR THE FORMAL-PARAMETERS.
.B 1
.IF FOA;.NUMBER 134;.PS 80,80;.PAGE;
.ENDIF FOA
.LM 15;.NJ;.NF
^^
   ---------------------------
   !            !            !
   !   BLOCK    !            !<---
   !            !            !   !
   !-------------------------!   !
   !                         !   !      ---------
   ! PROCEDURE CALL__BY__VALUE !   !      ! FALSE !
   ! BOOLEAN ARRAY TRUTH  .--!---!----->! FALSE !
   ! TEXT   S             .--!---!---   ! FALSE !
   ! REAL   NUM      3.5     !   !  !   ! TRUE  !
   !     .....               !   !  !   ! FALSE !
-->! CALL__BY__VALUE           !   !  !   ---------
_!  !                         !   !  !
_!  ---------------------------   !  !   ---------
_!                                !  --->! "+++" !
_!  ---------------------------   !      ---------
_!  !            !            !   !
---!----.       !     .------!----      ---------
   !            !            !    ----->! "+++" !
   !-------------------------!    !     ---------
   !                         !    !
   ! REAL      X       4.0   !    !     ---------
   ! REAL      Y       3.5   !    !  -->! "O.K."!
   ! TEXT      T1       .----!-----  !  ---------
   ! TEXT      T2       .----!--------
.TS 15;.I -15
       \\CURRENT	^^   ! BOOLEAN ARRAY B    .----!---       ---------
-->!         .....           !  !       ! FALSE !
.I -15
       \\STATEMENT^^  !                         !  ------->! FALSE !
   ---------------------------          ! TRUE  !
                                        ! FALSE !
                                        ---------\\
.F;.J;.LM 0

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 135;.PS 80,80;.PAGE;
.ENDIF FOA
^CALL BY REFERENCE
.BR
-----------------
.B 1
^A FORMAL-PARAMETER CALLED BY REFERENCE DESIGNATES A LOCAL COPY
OF THE REFERENCE OBTAINED BY EVALUATING THE CORRESPONDING ACTUAL-PARAMETER.
.index ^^Actual parameter, transfer by reference\\
^THE EVALUATION TAKES PLACE AT THE TIME OF THE PROCEDURE ENTRY
OR OBJECT GENERATION. ^THROUGHOUT THE LIFESPAN OF THE ^^PROCEDURE-\\ OR ^^CLASS\\-BODY,
.index ^^CLASS body\\
THE FORMAL-PARAMETER ACTS LIKE A LOCAL QUANTITY.
.B 1
^IF THE FORMAL-PARAMETER IS A REFERENCE-TYPE VARIABLE, ITS CONTENTS
MAY BE CHANGED BY ASSIGNMENTS WITHIN THE BODY (OR EXTERNALLY BY
.index ^^CLASS body\\
REMOTE ACCESSING IN THE CASE OF OBJECTS).
.B 1
^AN ^^ARRAY, PROCEDURE, LABEL\\ OR ^^SWITCH\\ PARAMETER CALLED
.index ^^Label, as procedure parameter by reference\\
BY REFERENCE REMAINS FIXED AND REFERENCES THE SAME ENTITY THROUGHOUT
ITS SCOPE. ^OF COURSE, THE CONTENTS OF AN ^^ARRAY\\ CALLED BY
REFERENCE MAY WELL BE CHANGED THROUGH ASSIGNMENTS TO ITS COMPONENTS.
.B 1
^FOR AN OBJECT-REFERENCE TYPE PARAMETER (WHICH MAY BE A VARIABLE, ^^PROCEDURE\\
OR AN ^^ARRAY),\\ THE QUALIFICATION OF THE MATCHING ACTUAL-PARAMETER
.index ^^Qualification of actual parameter\\
.index ^^Matching qualification\\
.index ^^Actual parameter, transfer by reference\\
MAY COINCIDE WITH, OR BE INNER TO, THE QUALIFICATION OF THE FORMAL-PARAMETER.
.index ^^INNER\\
.B 1
^^SIMSET BEGIN##INTEGER PROCEDURE NULLREF(L,N); REF(LINK) ARRAY L;
.index ^^PROCEDURE NULLREF (INTEGER)\\
.I 46
INTEGER N;
.LM 14;.TS 21;.NF;.NJ
BEGIN	INTEGER J, COUNT;
	FOR J := 1 STEP 1 UNTIL N DO
	####IF L[J] == NONE THEN COUNT := COUNT + 1;
	NULLREF := COUNT;
END;
INTEGER C;
REF(LINK) ARRAY Q[1:50];
_......
C := NULLREF(Q,50);
_......
.LM 5
END\\
.LM 0;.F;.J
.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 136;.PS 80,80;.PAGE;
.ENDIF FOA
^ON THE PROCEDURE CALL, A SNAPSHOT IS
.B 2;.LM 0;.NJ;.NF
^^           -----------------------
           !          !          !<-----
           -----------------------     !
           ! SIMSET              !     !
           -----------------------     !
           ! PROCEDURE NULLREF   !     !
           ! INTEGER  C          !     !     --------
           ! REF(LINK) ARRAY Q .-!-----!---->!   .--!---->
           !    ..........       !     !  -->--------
      ---->! C := NULLREF(1,50)  !     !  !  !   .--!---->
      !    !    ..........       !     !  !  --------
      !    -----------------------     !  !  ! NONE !
      !                                !  !  --------
      !                                !  !  ! NONE !
      !    -----------------------     !  !  --------
      -----!----.     !     .----!------  !  !      !
           -----------------------        !  !------!
           ! INTEGER NULLREF 0   !        !  !      !
           ! INTEGER N      50   !        !  --------
           ! REF(LINK) ARRAY L .-!---------  !  .---!---->
           !                     !           --------
\\CURRENT    !     ..........      !
       --->!                     !
STATEMENT  -----------------------

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 137;.PS 80,80;.PAGE;
.ENDIF FOA
.J
.FILL
^CALL BY NAME
.index ^^NAME parameter transmission, semantics\\
.index ^^Call by NAME, semantics\\
.index ^^NAME parameter transmission, semantics\\
\\
.BR
------------
.B 1
^CALL BY NAME IS AN OPTIONAL TRANSMISSION MODE AVAILABLE FOR PARAMETERS
.index ^^NAME parameter transmission, semantics\\
.index ^^Call by NAME, semantics\\
TO PROCEDURES, BUT NOT TO CLASSES. ^IT REPRESENTS A TEXTUAL
REPLACEMENT IN THAT THE FORMAL-PARAMETER MAY BE CONSIDERED REPLACED
THROUGHOUT THE ^^PROCEDURE-\\BODY BY THE CORRESPONDING ACTUAL-PARAMETER.
.index ^^Actual parameter, transfer by name\\
.B 1
^WHEREAS CALL BY VALUE AND CALL BY REFERENCE OPERATE ON VARIABLES
LOCAL TO THE ^^PROCEDURE-\\BODY ITSELF, CALL BY NAME OPERATES
.index ^^NAME parameter transmission, semantics\\
ON NON-LOCAL QUANTITIES AND CAN ALTER GLOBAL QUANTITIES. ^IT IS
THEREFORE ESPECIALLY USEFUL FOR THE CONTROLLED ALTERATION OF SEVERAL
VARIABLES EXTERNAL TO THE ^^PROCEDURE-\\BODY.
.B 1
^THE FOLLOWING RULES APPLY:
.B 1;.LM 4;.I -4
1)##^THE TYPE OF A NAME PARAMETER IS THAT PRESCRIBED BY THE
.index ^^Call by NAME, semantics\\
.index ^^NAME parameter transmission, semantics\\
CORRESPONDING FORMAL SPECIFICATION.
.B 1;.I -4
2)##^IF THE TYPE OF THE ACTUAL-PARAMETER DOES NOT COINCIDE WITH THAT
.index ^^Actual parameter, transfer by name\\
OF THE FORMAL SPECIFICATION, THEN AN EVALUATION OF THE EXPRESSION
IS FOLLOWED BY AN ASSIGNMENT OF THE VALUE OR REFERENCE OBTAINED
TO A FICTITIOUS VARIABLE OF THE LATTER TYPE. ^THIS ASSIGNMENT
IS SUBJECT TO THE RULES OF SECTION 2.7.2. ^THE VALUE
OR REFERENCE OBTAINED BY THE EVALUATION IS THE CONTENTS OF THE FICTITIOUS VARIABLE.
.B 1;.LM 0
^SECTION 2.7.2 DEFINES THE MEANING OF AN ASSIGNMENT TO A VARIABLE
WHICH IS A FORMAL-PARAMETER CALLED BY NAME, OR IS A SUBSCRIPTED
VARIABLE WHOSE ARRAY IDENTIFIER IS A FORMAL-PARAMETER CALLED BY
NAME, IF THE TYPE OF THE ACTUAL PARAMETER DOES NOT COINCIDE WITH
.index ^^NAME parameter transmission, semantics\\
.index ^^Call by NAME, semantics\\
.index ^^Actual parameter, transfer by name\\
THAT OF THE FORMAL SPECIFICATION.
.B 1
.IF FOA;.NUMBER 138;.PS 80,80;.PAGE;
.ENDIF FOA
^ASSIGNMENT TO A ^^PROCEDURE-\\IDENTIFIER WHICH IS A FORMAL PARAMETER
.index ^^Formal parameter part\\
IS ILLEGAL, REGARDLESS OF ITS TRANSMISSION MODE.
.B 1
^NOTICE THAT EACH DYNAMIC OCCURRENCE OF A FORMAL-PARAMETER CALLED
BY NAME, REGARDLESS OF ITS KIND, MAY INVOKE THE EXECUTION OF A
.index ^^NAME parameter transmission, semantics\\
.index ^^Call by NAME, semantics\\
NON-TRIVIAL EXPRESSION, E.G. IF ITS ACTUAL-PARAMETER IS A REMOTE-IDENTIFIER.
.index ^^Actual parameter, transfer by name\\

.IFNOT FOA;.PG
.ENDIF FOA;
^EXAMPLE:
.B 1;.LM 12;.TS 12;.I -7
^^BEGIN	PROCEDURE SWAP(A,B); NAME A, B; REAL A, B;
.index ^^NAME parameter transmission, semantics\\
.index ^^Call by NAME, semantics\\
.B 1;.NF;.NJ;.TS 19
BEGIN	REAL X;
	X := A;
	A := B; B := X;
END ***SWAP***;
REAL P, Q;
P := 4.0; Q := 5.7;
SWAP(P,Q);
_..........
.I -7
END\\
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 139;.PS 80,80;.PAGE;
.ENDIF FOA
^A SNAPSHOT AT THE PROCEDURE CALL IS:
.B 2;.LM 5;.NJ;.NF
^^
         -------------------
         !        !        !<----
         -------------------    !
         ! PROCEDURE SWAP  !    !
         ! REAL   P   4.0  !    !
         ! REAL   Q   5.7  !    !
         !   ..........    !    !
     --->! SWAP    (P,Q)   !    !
     !   -------------------    !
     !              _^ _^         !
     !              ! !         !
     !              ! !         !
     !   -----------!-!-----    !
     ----!---.    ! ! ! .--!-----
         -----------!-!-----
         !          ! !    !
         ! REAL  A  . !    !
         ! REAL  B    .    !
         ! REAL  X    0.0  !
         !                 !        \\^PROGRAM ^SEQUENCE ^CONTROL^^
 PSC --->!    ..........   !        (\\^^PSC)\\ REFERENCES THE CURRENT
         -------------------        STATEMENT
.B 2;.LM 0;.F;.J
^NO LOCAL COPIES ARE MADE. ^EVERY OCCURRENCE OF ^A OR ^B IN THE
^^PROCEDURE-\\BODY MEANS A RE-EVALUATION OF THE ACTUAL-PARAMETER.
.index ^^Actual parameter, transfer by name\\
^NOTICE THAT THE ACTUAL-PARAMETERS ARE EVALUATED IN THE CONTEXT OF THE PROCEDURE CALL.
.index ^^Actual parameter, transfer by name\\
.SUBTITLE ^^CHAPTER\\ 2.5.5
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 140;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Call by NAME of CLASS parameters (disallowed)\\
.index ^^NAME parameter to a CLASS (disallowed)\\
2.5.5##^^CLASS DECLARATIONS\\
.index ^^Declaration of a CLASS\\
.index ^^CLASS declaration\\
.B 1
.index ^^Left parenthesis (()\\
.index ^^Right parenthesis ())\\
^^CLASS\\ DECLARATIONS DEFINE CONCEPTS. ^^CLASS\\ INSTANCES ARE
.index ^^CLASS instance\\
CALLED OBJECTS AND MANY OBJECTS OF A GIVEN CLASS MAY EXIST
.index ^^Structure declaration\\
.index ^^Object of a CLASS\\
SIMULTANEOUSLY TO BE EXAMINED AND MANIPULATED BY THE PROGRAM.
^OBJECTS ARE GENERALIZATIONS OF BLOCKS AND PROCEDURES, AS THE
ENVIRONMENT OF EITHER A BLOCK INSTANCE OR A PROCEDURE INSTANCE
CAN ONLY OBSERVE THE RESULT OF ITS ACTIONS.
.B 2
^^CLASS-\\DECLARATION
.B 1
.I 10
[^^CLASS\\-IDENTIFIER]MAIN-PART
.index ^^Main part of CLASS declaration\\
.index ^^Record declaration\\
.index ^^CLASS identifier\\
.B 2
MAIN-PART
.B 2;.LM 0;.NJ;.NF;.RM 75
                        **                **
                        *         ;        *
^^CLASS CLASS\\-IDENTIFIER **                  **
                        *  PARAMETER-PART  *
.index ^^Parameter part of CLASS declaration\\
                        **                **
.B 1
               [PROTECTION-PART] [VIRTUAL-PART] ^^CLASS\\-BODY
.index ^^CLASS body\\
.index ^^CLASS body\\
.B 2;.LM 0;.F;.J;.RM 70;.PS 58,70
PARAMETER-PART
.B 1
(IDENTIFIER-LIST); [^^VALUE\\ IDENTIFIER-LIST;]... ^^CLASS\\-SPEC-PART
.index ^^VALUE declaration of CLASS parameter\\
.index ^^Left parenthesis ((), use in CLASS declaration\\
.index ^^Right parenthesis ()), use in CLASS declaration\\
.index ^^Identifier list\\
.B 2
^^CLASS\\-SPEC-PART
.B 2;.LM 5;.NJ;.NF
 **                                                     **
 *   **                       **                         *
 *   * [^^LONG]REAL              *                         *
.index ^^REAL, as CLASS attribute\\
.index ^^LONG REAL as CLASS attribute\\
 *   * [SHORT]INTEGER          *                         *
.index ^^SHORT INTEGER, as CLASS attribute\\
.index ^^INTEGER as CLASS attributes\\
 *   * CHARACTER               *                         *
.index ^^CHARACTER as CLASS parameter\\
**  ** BOOLEAN\\                 **  IDENTIFIER-LIST;  ... **
.index ^^BOOLEAN CLASS attribute\\
^^ *   * REF(CLASS\\-IDENTIFIER)   *                         *
.index ^^REF, as CLASS attribute\\
 *   * ^^TEXT                    *                         *
.index ^^TEXT, as CLASS attribute\\
 *   * [\\TYPE]^^ARRAY             *                         *\\
.index ^^Type ARRAY, as CLASS attribute\\
 *   **                       **                         *
 **                                                     **

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
.IF FOA;.NUMBER 141;.PS 80,80;.PAGE;
.ENDIF FOA
PROTECTION-PART
.UC;.B 2;.LM 5;.NJ;.NF
 **                                 **
 *         **                  **    *
 *         *  HIDDEN            *    *
 *         *  PROTECTED         *    *
**  [NOT] **  HIDDEN PROTECTED  **   **  ...
 *         *  PROTECTED HIDDEN  *    *
 *         **                  **    *
 **                                 **
.LC;.B 2;.LM 0;.F;.J
VIRTUAL-PART
.index ^^VIRTUAL, syntax\\
.B 2;.LM 5;.NJ;.NF
^^          **                                               **
          *    **                **                         *
          *    *  PROCEDURE\\       *                         *
.index ^^PROCEDURE as CLASS attribute\\
.index ^^PROCEDURE declaration in outermost CLASS body\\
          *    *  TYPE ^^PROCEDURE\\  *                         *
VIRTUAL: **   **  LABEL           ** \\IDENTIFIER-LIST;  ...  **^^
.index ^^Colon (:)\\
.index ^^Label, virtual\\
          *    *  SWITCH          *                         *\\
.index ^^SWITCH, as CLASS attribute\\
          *    **                **                         *
          **                                               **
.B 3;.LM 0;.F;.J
^^CLASS\\-BODY
.index ^^CLASS body\\
.index ^^CLASS body\\
.B 2;.LM 5;.NJ;.NF
 **           **
 * STATEMENT   *
**             **
 * SPLIT-BODY  *
.index ^^Split body\\
.index ^^CLASS body\\
 **           **
.B 2;.LM 0;.F;.J
SPLIT-BODY
.index ^^Split body\\
.index ^^CLASS body\\
.B 1
^^BEGIN\\ [DECLARATION;] ... [STATEMENT;] ... ^^INNER\\
.index ^^INNER\\
.index ^^BEGIN (In CLASS declaration)\\
.I 27
[; STATEMENT] ... ^^END\\
.index ^^END in CLASS declaration\\
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 142;.PS 80,80;.PAGE;
.ENDIF FOA
^THE AVAILABLE TRANSMISSION MODES FOR LEGAL PARAMETERS TO CLASSES
ARE SHOWN IN THE FOLLOWING TABLE:

.IFNOT FOA;.PG;
.ENDIF FOA;.C
^^CLASS PARAMETERS\\
.index ^^NEW operator, table of parameter transmission\\
.index ^^Arguments to a CLASS\\
.index ^^Parameter to a CLASS\\
.B 1;.TS 29;.NF;.NJ
^PARAMETER	^TRANSMISSION
.index ^^CLASS parameters (table)\\
.B 1;.TS 20,37
	CALL BY VALUE	CALL BY REFERENCE
.BR
	---------------------------------
.index ^^CALL by VALUE of CLASS parameters\\
.index ^^Call by reference of CLASS parameters\\
.B 1;.TS 26,45;.LM 0
VALUE-TYPE	^D	^X
REFERENCE-TYPE	^X	^D
^^TEXT\\	^O	^D
VALUE-TYPE ^^ARRAY	O	D\\
.index ^^ARRAY, as CLASS parameter\\
REFERENCE-TYPE ^^ARRAY\\	^X	^D
.B 1
^D : DEFAULT MODE
^O : OPTIONAL
^X : ILLEGAL
.B 2;.F;.J;.LM 0
^THE TRANSMISSION MODES "CALL BY VALUE" AND "CALL BY REFERENCE"
.index ^^CALL by VALUE of CLASS parameters\\
.index ^^Call by reference of CLASS parameters\\
ARE EXPLAINED IN SECTION 2.5.4.
.B 1
^^The bounds of an array declared after the initial BEGIN of
.index ^^ARRAY as CLASS attribute\\
.index ^^Bounds of ARRAY as CLASS attribute\\
.index ^^Depending bounds of an ARRAY\\
.index ^^Subscript bounds of CLASS attribute\\
a CLASS-declaration may be taken or computed from the
parameters of the CLASS.\\
.B 1
^THE DISCUSSION OF ^^CLASS\\-DECLARATIONS BEGINS BY CONSIDERING
TWO SELECTED EXAMPLES OF INCREASING SCOPE.
.B 2
.IF FOA;.NUMBER 143;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE 1:##^EMPTY PREFIX AND VIRTUAL PART
.index ^^Empty part and VIRTUAL part\\
.B 1
^THE DECLARATION OF A CLASS ^A CAN HAVE THE FORM:
.B 2;.LM 5;.NJ;.NF
^^
CLASS A(\\FP^^A); \\SP^^A;          ------------
                            !  \\FP^^A     !
BEGIN  \\D^^A;                  ------------
                            !   \\D^^A     !
\\       ACTIONS^A;            ------------
                            ! ACTIONS^A !
^^END                         ------------\\
.B 2;.LM 0
#####^^CLASS A\\ DECLARATION       ^A OBJECT
.B 2
.LM 12;.TS 12;.I -12
^A:	^^CLASS-\\IDENTIFIER
.BR;.I -12
FP^A:	^LIST OF THE FORMAT PARAMETERS OF ^A
.BR;.I -12
SP^A:	^LIST OF SPECIFICATIONS OF EACH OF THE FORMAL
.index ^^CLASS specification part\\
PARAMETERS OF ^A.
.I -12
D^A:	^DECLARATIONS OF THE ^^CLASS-\\BODY OF ^A.
.index ^^CLASS body\\
.index ^^CLASS body\\
.I -12
ACTIONS^A:	ACTIONS OF THE ^^CLASS\\-BODY OF ^A
.index ^^CLASS body\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
^THE ^^CLASS\\-BODY OF ^A IS A BLOCK (ONE FORM OF STATEMENT).
.index ^^CLASS body\\
.B 1
^THE QUANTITIES PASSED AS PARAMETERS OR DECLARED IN THE OUTERMOST
BLOCK OF THE CLASS BODY ARE CALLED THE ATTRIBUTES OF CLASS ^A
.index ^^Attributes of CLASSes\\
.index ^^CLASS body\\
AND ARE ATTRIBUTES OF EVERY OBJECT OF THE CLASS. ^ATTRIBUTES SPECIFIED
AS FORMAL-PARAMETERS MAY ONLY BE SIMPLE VARIABLES OR ARRAYS.
^DECLARED ATTRIBUTES MAY BE SIMPLE VARIABLES, ARRAYS, PROPER-PROCEDURES,
.index ^^PROCEDURE as CLASS attribute\\
FUNCTION-PROCEDURES AND CLASSES.
.B 1
.IF FOA;.NUMBER 144;.PS 80,80;.PAGE;
.ENDIF FOA
^THE EXPRESSION
.B 1;.I 5
^^NEW A(...)\\
.index ^^NEW operator, parameter correspondence to\\
.B 1
CREATES AN OBJECT OF THE CLASS ^A (THE ORDER AND NUMBER OF THE
ACTUAL-PARAMETERS MUST CORRESPOND WITH THE ORDER AND NUMBER OF THE FORMAL-PARAMETERS)
.index ^^Actual parameter, correspondence with formal\\
AND COMMENCES EXECUTION OF ITS ACTIONS. ^THE EXECUTION CONTINUES UNTIL
THE FINAL ^^END\\ OF THE CLASS BODY IS ENCOUNTERED, WHEN THE EXECUTION
.index ^^CLASS body\\
IS TERMINATED. ^HOWEVER THIS MAY BE INTERRUPTED IN FOUR WAYS#-#BY A
^^GOTO\\-STATEMENT (WHICH LEADS OUT OF THE OBJECT), OR BY CALLS
ON THE SYSTEM PROCEDURES "DETACH", "RESUME" OR "CALL". ^A ^^GOTO\\
.index ^^RESUME procedure operating on class instances\\
.index ^^GO TO exit\\
.index ^^DETACH (outside CLASS SIMULATION)\\
EXIT WILL LEAVE THE OBJECT IN THE TERMINATED STATE. "^DETACH" SUSPENDS
.index ^^DETACH (outside CLASS SIMULATION)\\
THE ACTIONS OF THE CLASS BODY AND NAMES IT AN INDEPENDENT COMPONENT
.index ^^CLASS body\\
OF THE PROGRAM. ^ITS ACTIONS MAY BE CONTINUED LATER BY A CALL ON "RESUME".
.B 1
^AN OBJECT IS "ATTACHED" EITHER UNDER GENERATION AS A RESULT OF
^^NEW\\ OR WHEN IT IS "CALL"-ED.
.index ^^CALL of a CLASS object\\
.B 1
.index ^^CALL of a CLASS object\\
.index ^^RESUME procedure operating on class instances\\
.index ^^PROCEDURE call, efficiency of\\
.index ^^CPU efficiency, procedure call versus class call\\
.index ^^Efficiency, procedure call versus class call\\
.index ^^Efficiency of quasi-parallel processing\\
.index ^^Quasi-parallel processing, efficiency of\\
^^In many cases, it may be better to use CALL or RESUME on class objects
instead of using ordinary procedure calls.
CALL or RESUME on CLASS objects have the following advantages compared to
procedure calls:
.B 1
.left margin 2
.indent -2
- No memory is allocated, which means that CALL or RESUME uses
much less CPU time than a procedure call.
.p -2,1,2
- Data can be kept within the class object between CALLs or
RESUMEs.
.left margin 0
.B 1
On the other hand, procedure calls can have parameters, but no
parameters can be transferred to the class when you make a
CALL or RESUME on a class object.\\
.IF FOA;.NUMBER 154;.PS 80,80;.PAGE;
.ENDIF FOA
.P 0,2,15
^^Initialization of CLASS attributes.
.index ^^Initial value of CLASS attributes.\\
.index ^^Initialization of CLASS attributes.\\
.index ^^Undefined values are impossible in SIMULA\\
.index ^^Start value of CLASS attributes\\
.index ^^CLASS attribute initialization\\
.index ^^First value of CLASS attributes\\
.B 1
There are three ways to initialize CLASS attributes in SIMULA:
.B 1
1) Attributes which are parameters to the CLASS are initialized
by the actual parameters in the NEW command.
.B 1
2) Attributes can be initialized by executable statements
before the first "detach" in the CLASS. This can for example
be used to include each new CLASS object into a set immediately at
creation, or to give each new CLASS object a unique number.
.B 1
3) If none of the above is done, the attribute is given
a default initial value, see chapter 2.5.1.\\
.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 145;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE 2:##^NON-EMPTY PREFIX AND EMPTY VIRTUAL PART
.index ^^Non-empty prefix and empty virtual part\\
.index ^^Attribute redefinition (VIRTUAL)\\
.index ^^VIRTUAL, attribute redefinition\\
.B 1
^A ^^CLASS-\\DECLARATION MAY CONTAIN A PREFIX WHICH IS THE IDENTIFIER
OF ANOTHER CLASS DECLARED EITHER IN THE SAME BLOCK, OR IN THE
PREFIX TO THE SAME BLOCK. ^THE PREFIXED CLASS IS A SUBCLASS
.index ^^Subclass\\
OF THE PREFIX.
.B 1
E.G.,
.B 2;.LM 5;.NJ;.NF

^^
                              ------------
                              !   FPA    !
A CLASS B(\F\PB); \S\PB;          ------------
                              !   DA     !
  BEGIN \DB;                   ------------
                              ! \\ACTIONS^A !
        ACTIONS^B;             ------------
                              !   FP^B    !
  ^^END                         ------------
                              !   DB     !
                              ------------
                              ! \\ACTIONS^^B !
                              ------------
.B 1
^^CLASS B\\ DECLARATION       ^B OBJECT
.B 2;.LM 0;.F;.J
^A ^B-OBJECT IS A COMPOUND OBJECT WHICH HAS ALL THE ATTRIBUTES
AND ACTIONS OF THE PREFIX ^A AND THE MAIN-PART OF CLASS ^B. ^A
^B-OBJECT IS GENERATED BY
.B 1;.I 5
^^NEW####B(\A\PA, \A\PB)\\
.B 1
WITH A LIST OF ACTUAL-PARAMETERS CORRESPONDING IN NUMBER AND
.index ^^Actual parameter when making NEW class objects\\
ORDER TO THOSE OF AN ^A-OBJECT AND THOSE OF THE MAIN-PART OF
^B. ^ON GENERATION, THE ACTIONS OF THE ^A-PART ARE EXECUTED FIRST
AND THEN THOSE OF THE ^B-PART. ^THE ACTIONS OF THE ^A-PART
HAVE ACCESS TO THE ATTRIBUTES OF ^A ONLY, THE ACTIONS OF THE
^B-PART TO THOSE OF ^B AND OF ^A.

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 146;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS HIERARCHIES\\
.BR
.index ^^CLASS hierarchies\\
-----------------
.B 1
^IN GENERAL, A HIERARCHY OF CLASSES MAY BE INTRODUCED.
.BR
E.G.
.B 1;.TS 20
	DECLARATIONS
.B 1
	^^CLASS C1......;
.BR;.TS 17
	C1#CLASS C2......;
.BR
	C1 CLASS C3......;
.BR
	C2 CLASS C4......;
.BR
	C2 CLASS C5......;\\
.B 2;.LM 0;.NJ;.NF
    HIERARCHY                         OBJECTS
    ---------                         -------
                    
^^                   
                        C1       C2       C3       C4       C5
      ----C1----      ------   ------   ------   ------   ------
      !        !      ! C1 !   ! C1 !   ! C1 !   ! C1 !   ! C1 !
 ----C2----    C3     ------   ------   ------   ------   ------
 !        !                    ! C2 !   ! C3 !   ! C2 !   ! C2 !
C4        C5                   ------   ------   ------   ------
                                                 ! C4 !   ! C5 !
                                                 ------   ------\\
.B 2;.LM 0;.F;.J
.LM 0
.IF FOA;.NUMBER 147;.PS 80,80;.PAGE;
.ENDIF FOA
^THE PREFIX SEQUENCE OF A CLASS IS THE SEQUENCE OF CLASSES
IN ITS PREFIX CHAIN
.index ^^Prefix chain of CLASS declarations\\
.B 1
E.G.##IN THE ABOVE FIGURE, THE PREFIX SEQUENCE OF
.B 1;.I 10
^C1 IS EMPTY
.I 10
^C2 IS ^C1
.I 10
^C5 IS ^C1 ^C2

.IFNOT FOA;.PG
.ENDIF FOA;
^IF THE PREFIX SEQUENCE OF A CLASS ^^CN\\ IS ^C1, ^C2,.....,#^^CN-1,\\
THEN A ^^CN\\ OBJECT MAY BE DEPICTED BY:
.B 2;.LM 5;.NJ;.NF
                      ---------  **
                      !  ^C1   !   *
                      ---------   *
                      !  ^C2   !   **   CLASSES OUTER TO ^^CK\\
.index ^^OUTER CLASS declarations\\
                      ---------   *
                      ! ..... !   *
                  **  ---------  **
                  *   !  ^^CK\\   !     CLASS EQUAL TO ^^CK\\
SUBCLASSES OF ^^CK\\  *   ---------  **
.index ^^Subclass\\
OR CLASSES       **   ! ..... !   *
INCLUDED IN ^^CK\\    *   ---------   **    CLASSES INNER TO ^^CK\\
.index ^^INNER\\
                  *   !  ^^CN\\   !   *
.index ^^INCLUDED CLASSes of prefixing CLASSes\\
                  **  ---------  **
.B 2;.LM 0;.F;.J
^AN OBJECT OF A PREFIXED CLASS IS A COMPOUND OBJECT WHICH IS
THE UNION OF THE FORMAL-PARAMETERS, DECLARATIONS AND ACTIONS
OF THE CLASSES IN ITS PREFIX SEQUENCE TOGETHER WITH THE STRUCTURE
DEFINED IN ITS OWN MAIN-PART.
.B 1
^THE MECHANISM OF CONCATENATION MAY BE EXTENDED TO THE CASE OF
PREFIXED-BLOCKS, E.G.
.B 1;.TS 5,17,23
	^^SIMULATION	BEGIN
.BR
				_...
.BR
		END\\
.B 1;.LM 0
^THE EXECUTION OF A PREFIXED BLOCK BEGINS BY EXECUTING THE ACTIONS
OF THE INITIAL OPERATIONS OF THE CLASS AND THEN THOSE OF THE BLOCK BODY.
.index ^^CLASS body\\
^THE ATTRIBUTES OF THE CLASS ARE ACCESSIBLE INSIDE THE BLOCK
BODY AND THIS BLOCK IS THUS GIVEN A BUILT-IN ENVIRONMENT IN WHICH TO OPERATE.

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 148;.PS 80,80;.PAGE;
.ENDIF FOA
^^INNER\\
.index ^^INNER\\
.BR
-----
.B 1
^THE ORDER OF THE EXECUTION OF ACTIONS IN AN OBJECT MAY BE
ALTERED FROM THEIR TEXTUAL ORDER BY USE OF ^^INNER.\\
.index ^^INNER\\
.B 1
^CONSIDER
.B 1;.I 5
^^CLASS A ...;
.I 5
BEGIN  ....; S1; INNER; S2  END;
.index ^^INNER\\
.B 1;.I 3
A CLASS B ...;
.I 5
BEGIN .....; S3  END\\
.B 1
^IN AN ^A OBJECT ^^INNER\\ ACTS AS A DUMMY STATEMENT, AND THE
.index ^^INNER\\
.index ^^Dummy statement behaviour of INNER\\
ACTIONS EXECUTED ARE
.B 1;.I 5
^S1; ^S2
.B 1
^IN A ^B OBJECT, ^^INNER\\ FORCES EXECUTION OF ^S3 BEFORE THOSE OF ^S2, THUS
.index ^^INNER\\
.B 1;.I 5
^S1; ^S3; ^S2
.B 2
.IF FOA;.NUMBER 149;.PS 80,80;.PAGE;
.ENDIF FOA
^^VIRTUAL QUANTITIES#(6)\\
.FOOTNOTE 6
---------------------------------------------------------------------
.break
(6)##^THIS SECTION MAY BE BYPASSED BY READERS STARTING TO LEARN
^^SIMULA\\. ^THOUGH IT CONCERNS A VERY USEFUL MECHANISM, IT IS
NOT NECESSARY TO LEARN INITIALLY. ^MOST ^^SIMULA\\ PROGRAMS
DO NOT USE VIRTUAL QUANTITIES.
.END FOOTNOTE
.index ^^CASE statement, see VIRTUAL procedures\\
.index ^^VIRTUAL quantities\\
.index ^^VIRTUAL, semantics\\
.index ^^Attribute redefinition (VIRTUAL)\\
.BR
------------------
.B 1
^THE VIRTUAL MECHANISM IS A METHOD OF EXTENDING THE RULES OF
.index ^^Attribute redefinition (VIRTUAL)\\
ACCESSIBILITY, WHILST STILL RETAINING SECURITY. ^THE VIRTUAL
.index ^^INNER accesibility (VIRTUAL)\\
.index ^^Attribute redefinition (VIRTUAL)\\
.index ^^Security\\
MECHANISM IS USEFUL IN TWO CIRCUMSTANCES.
.B 1;.LM 4;.I -4
1)##TO REDEFINE ATTRIBUTES
.I -4
2)##TO GIVE ACCESSIBILITY TO ATTRIBUTES DECLARED AT INNER LEVELS
.B 1;.I -4
1)##ATTRIBUTE REDEFINITION
.BR
----------------------
.B 1
^USUALLY WHEN A CLASS HIERARCHY IS CONSTRUCTED, AN ATTRIBUTE
HAS A FIXED MEANING NO MATTER HOW MANY PREFIX LEVELS ARE ADDED
TO THE CLASS CONTAINING ITS DECLARATION.
.B 1
^SOMETIMES, HOWEVER, WE MAY WISH TO REDEFINE THE ATTRIBUTE THROUGHOUT ITS SCOPE.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 14;.I -14
.IF FOA;.NUMBER 150;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE:##^CONSIDER THE DESCRIPTION OF A ^^CLASS ROW\\ FOR MANIPULATING VECTORS.
.B 1;.LM 4;.NF;.NJ
^^CLASS ROW(A,N); REAL ARRAY A; INTEGER N;
BEGIN  REAL PROCEDURE NORM;
.TS 11
	BEGIN  REAL T; INTEGER I;
.TS 18
	FOR I := 1 STEP 1 UNTIL N DO
.TS 22
	T := T + A[I]*A[I];
	NORM := SQRT(T);
.TS 11
	END ***NORM***;
	PROCEDURE NORMALISE;
	BEGIN  REAL T; INTEGER I;
.TS 18
	T := NORM;
	IF T  NE 0 THEN
.TS 21
	BEGIN  T := 1/T;
.TS 28
	FOR I := 1 STEP 1 UNTIL N DO
.TS 32
	A[I] := A[I]*T;
.TS 21
	END;
.TS 11
	END ***NORMALISE***;
	IF N < 1 THEN ERROR;
.LM 4
END ***ROW***
.B 1;.LM 0;.F;.J
^^Note: Procedure attributes to classes can be used to
.index ^^Entry points into a subroutine\\
.index ^^Subroutine entry points\\
.index ^^CLASS entry points\\
get a function equivalent to several entry points into
subroutines as available in other programming languages.\\
.B 2;.LM 4;.F;.J
.IF FOA;.NUMBER 151;.PS 80,80;.PAGE;
.ENDIF FOA
^A NEW ^^ROW\\ OBJECT HAS FOUR ATTRIBUTES:
.B 1;.LM 8;.I -4
1)##A ^^REAL ARRAY A\\ RUNNING FROM 1 THROUGH ^N
.I -4
2)##A SPECIFIED UPPER BOUND ^N
.I -4
3)##A ^^REAL PROCEDURE NORM\\ WHICH COMPUTES THE SQUARE ROOT
OF THE SUM OF THE SQUARE OF ITS COMPONENTS. (^^NORM\\ GIVES THE
"MAGNITUDE" OF THE ^^ARRAY A).\\
.I -4
4)##A ^^PROCEDURE NORMALISE\\ WHICH DIVIDES THROUGH EACH ARRAY
ELEMENT BY THE CURRENT VALUE OF ^^NORM.\\
.B 1;.LM 4
^IF THE USER WISHES TO USE A DIFFERENT ^^NORM\\ THEN THE CLASS
HAS TO BE REWRITTEN.
.B 1
^HOWEVER BY ALTERING THE CLASS OUTLINE TO
.B 1;.I 5
^^CLASS ROW(A,N); REAL ARRAY A; INTEGER N;
.I 21
VIRTUAL : REAL PROCEDURE NORM;
.index ^^Attribute redefinition (VIRTUAL)\\
.I 5
BEGIN##REAL PROCEDURE NORM...;
.I 12
PROCEDURE NORMALISE...;
.I 12
IF N < 1 THEN ERROR;
.I 5
END ***ROW***\\
.B 1;.LM 4
IT BECOMES POSSIBLE TO ALTER THE DEFINITION OF ^^NORM\\ IN A
.index ^^Binding rules, virtual quantities\\
SUBCLASS OF ^^ROW,\\ AND YET HAVE THE NEW MEANING AVAILABLE
.index ^^Subclass\\
AT THE ^^ROW\\ LEVEL WHERE IT IS NEEDED IN ANY CALL ON ^^NORMALISE\\ E.G.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.NF;.NJ;.I 5
^^ROW CLASS ROW1;
.I 9
BEGIN  REAL PROCEDURE NORM;
.I 16
BEGIN  REAL S,T; INTEGER I;
.I 25
FOR J := 1 STEP 1 UNTIL N DO
.I 27
BEGIN  T := ABS(A(I));
.I 34
IF T > S THEN S := T;
.I 27
END;
.I 27
NORM := S;
.I 16
END ***NORM*** ;
.I 9
END ***ROW1***\\
.B 2;.NF;.NJ;.LM 4;.TS 11,43
.IF FOA;.NUMBER 152;.PS 80,80;.PAGE;
.ENDIF FOA
	^^ROW OBJECT	ROW1 OBJECT
.B 1
-----------------------          -----------------------
! REAL ARRAY A        !          ! REAL ARRAY A        !
! INTEGER N           !          ! INTEGER N           !
! VIRTUAL : NORM .----!---       ! VIRTUAL : NORM .----!---
! REAL PROCEDURE NORM !<-!       ! PROCEDURE NORMALISE !  !
! PROCEDURE NORMALISE !          -----------------------  !
-----------------------          ! REAL PROCEDURE NORM !<--
                                 -----------------------
.B 2;.LM 4;.F;.J
^IN A ^^ROW1\\ OBJECT, THE ^^NORM\\ ATTRIBUTE DECLARED AT THE
^^ROW\\ LEVEL IS DELETED AND IS NEVER AVAILABLE. ^THOUGH THE
^^VIRTUAL\\ MECHANISM, THE ONLY VALID ^^NORM\\ ATTRIBUTE IS THAT
DECLARED AT THE ^^ROW1\\ LEVEL.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 4;.I -4
2)##^INNER ACCESSIBILITY
.index ^^INNER\\
.B 1
^THIS IS ILLUSTRATED BY AN EXAMPLE.
.B 1
^IN PROCESSING A LINKED STRUCTURE WHICH CONTAINS OBJECTS OF
VARIOUS CLASSES, (SAY ^A, ^B) THE LINKS ARE PROVIDED BY THEIR
COMMON PART ^^CLASS NODE.\\
.B 1;.I 5
^^CLASS NODE;BEGIN  REF(NODE)NEXT;  END;
.I 5
NODE CLASS A;  BEGIN  PROCEDURE DUMP ....;  END;
.I 5
NODE CLASS B;  BEGIN  PROCEDURE DUMP ....;  END;
.B 1
.IF FOA;.NUMBER 153;.PS 80,80;.PAGE;
.ENDIF FOA
I\\F THE STRUCTURE IS LINKED BY FOLLOWING ^^REF(NODE) NEXT\\
REFERENCES, THEN, IN THE NORMAL WAY, THE INFORMATION IN THE STRUCTURE
WOULD BE DUMPED BY
.B 1;.I 5
^^X :- FIRST;
.I 5
WHILE X =/= NONE DO
.I 5
BEGIN  IF X IS A THEN X QUA A.DUMP
.I 22
ELSE X QUA B.DUMP;
.I 12
X :- X.NEXT;
.I 5
END;\\
.B 1
WHICH IS TEDIOUS TO WRITE. ^BY WRITING THE CLASSES BY
.B 1;.I 5
^^CLASS NODE; VIRTUAL : PROCEDURE DUMP;
.I 5
BEGIN  REF(NODE) NEXT;
.I 12
_...
.I 5
END ***NODE*** ;
.I 5
NODE CLASS A;
.I 10
BEGIN  PROCEDURE DUMP ...;
.I 10
END;
.I 5
NODE CLASS B;
.I 10
BEGIN  PROCEDURE DUMP ...;
.I 5
END;\\

.B 1
WE CAN WRITE INSTEAD
.B 1;.I 5
^^X :- FIRST;
.I 5
WHILE X =/= NONE DO
.I 5
BEGIN  X.DUMP;
.I 12
X :- X.NEXT;
.I 5
END;\\
.IFNOT FOA;.PG
.ENDIF FOA;
.B 2;.LM 4
.IF FOA;.NUMBER 154;.PS 80,80;.PAGE;
.ENDIF FOA
^A VIRTUAL QUANTITY IS EITHER UNMATCHED OR ELSE MATCHED WITH
AN ATTRIBUTE (WITH THE SAME IDENTIFIER) DECLARED AT THE SAME OR
AN INNER PREFIX LEVEL. ^THE MATCHING ATTRIBUTE MUST BE OF THE SAME
.index ^^Matching attribute (VIRTUAL)\\
TYPE AS THAT SPECIFIED IN THE VIRTUAL PART, EXCEPT IN THE CASE
OF OBJECT-REFERENCE-FUNCTION-PROCEDURES. ^THE TYPE ^^REF(C)\\
MAY BE MATCHED WITH THE TYPE ^^REF(C)\\ OR TYPE ^^REF(D)\\, WHERE ^D
IS A SUBCLASS OF ^C. ^A ^^VIRTUAL\\ PROPER-^^PROCEDURE\\ MAY
.index ^^Subclass\\
BE MATCHED WITH ANY TYPE OF PROCEDURE. ^IN BOTH THESE CASES, THE
TYPE OF THE MATCH IS THE TYPE OF THE MATCHING DECLARATION.
.B 1
^A VIRTUAL QUANTITY OF A GIVEN OBJECT CAN HAVE AT MOST ONE MATCHING
ATTRIBUTE. ^IF MATCHING DECLARATIONS ARE GIVEN AT MORE THAN ONE
PREFIX LEVEL, THEN THE ONE AT THE INNERMOST PREFIX LEVEL IS
TAKEN. ^THE MATCH IS VALID AT ALL PREFIX LEVELS OF THE OBJECT
EQUAL OR INNER TO THAT OF THE SPECIFICATION.
.SUBTITLE ^^CHAPTER\\ 2.5.6
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 155;.PS 80,80;.PAGE;
.ENDIF FOA
2.5.6##^^EXTERNAL DECLARATIONS\\
.index ^^EXTERNAL declaration\\
.B 2;.LM 0;.NJ;.NF;.RM 80
EXTERNAL-IDENTIFIER
.index ^^Separate compilation, External declaration\\
-------------------
                    
           **                                                           **
           *               **                                        **  *
IDENTIFIER *  = IDENTIFIER *  [  PROJECT NUMBER, PROGRAMMER NUMBER ]  *  *
           *               **                                        **  *
           **                                                           **
.B 2
EXTERNAL-DECLARATION
--------------------
                                
          **                      **              **              **
          *  **      **            *              *                *
          *  *  TYPE  * ^^PROCEDURE\\  *              *                *
          *  **      **            *  EXTERNAL-   * EXTERNAL-      *
^^EXTERNAL\\ **                        **             * ,              * ...
          *           ^^CLASS\\        *  IDENTIFIER  * IDENTIFIER     *
          *                        *              *                *
          **                      **              **              **
.B 2;.LM 0;.RM 70;.PS 58,70;.F;.J
^THE ^^EXTERNAL\\ DECLARATION IS USED WHEN A SEPARATELY COMPILED
PROCEDURE OR ^^CLASS\\ WRITTEN IN ^^SIMULA, MACRO 10\\ OR ^^FORTRAN\\
.index ^^FORTRAN subroutine called from SIMULA\\
.index ^^Assembly language procedure\\
.index ^^MACRO 10 procedure called from SIMULA program\\
IS TO BE USED. ^IN THE MAIN PROGRAM, THE ^^EXTERNAL\\ DECLARATION
IS PUT AT THE PLACE WHERE THE SEPARATELY COMPILED SEGMENT WOULD
HAVE BEEN PUT IF IT HAD NOT BEEN SEPARATELY COMPILED. ^IN A SEPARATELY
COMPILED PROCEDURE OR CLASS, THE ^^EXTERNAL\\ DECLARATION IS
PUT IN FRONT OF THE SOURCE CODE.
.B 1
^THE EXTERNAL IDENTIFIER GIVES THE FILE NAME OF THE DISK FILE
ON WHICH THE SEPARATELY COMPILED SEGMENT IS STORED. ^FOR ^^FORTRAN\\
AND ^^MACRO\\ PROCEDURES, THE EXTERNAL IDENTIFIER GIVES THE FILENAME
OF THE DUMMY ^^SIMULA\\ BODY FOR THE PROCEDURE, OFTEN BUT NOT NECESSARILY
IDENTICAL TO THE FILENAME
.index ^^Dummy statement instead of CLASS body\\

OF THE ^^FORTRAN\\ OR ^^MACRO\\ PROCEDURE ITSELF.
.B 1
^MORE INFORMATION ABOUT SEPARATE COMPILATION IS GIVEN IN ^^DEC\\SYSTEM-10
^^SIMULA\\ ^LANGUAGE ^HANDBOOK ^PART ^I CHAPTER 4 AND IN ^^DEC\\SYSTEM-10
^^SIMULA\\ ^LANGUAGE ^HANDBOOK PART ^^II.\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.SUBTITLE ^^CHAPTER\\ 2.5.7
.LM 0;.RM 70;.F;.SP 1;.PS 58,70
.UC
.IF FOA;.NUMBER 156;.PS 80,80;.PAGE;
.ENDIF FOA
2.5.7##^^HIDDEN PROTECTED SPECIFICATIONS
.index ^^HIDDEN PROTECTED protection feature\\
.index ^^PROTECTED protection feature\\
.index ^^Security\\
.index ^^Protection\\
.index ^^Segmentation of programs\\
.B
[The HIDDEN PROTECTED specification is not available in release 1 and 2
of DECsystem-10 SIMULA, but available from release 3.]
.index ^^HIDDEN specification\\
.B 1
The HIDDEN PROTECTED feature is a feature to increase the reliability and
security of large software packages by dividing
.index ^^Security by module protection\\
the package into smaller submodules and controlling the interface
between the submodules.
.B 1
Many programming errors occur because a programmer, when writing code
in one submodule, is not aware of the effect of that code on other
submodules. If the interface between the modules is controlled,
the compiler and program can automatically guard against many such
programming errors.
.B 1
This is especially important when several programmers are working
on the same project, or when one programmer is writing a
program using one or several packages developed previously 
by someone else.
.B 1
The natural submodule in SIMULA is a CLASS. This CLASS is sometimes
separately compiled
(See Chapter 4).
However, programs using a separately compiled CLASS do not
ordinarily use directly all the attributes
of the separately compiled CLASS. Some attributes are internal
to the CLASS and only used by code inside the CLASS.
Other attributes are "ports of entry" to the CLASS. Often,
these "ports of entry" are PROCEDURE attributes to the CLASS,
since PROCEDUREs can include code to check the correctness
of the input parameters before performing the requested
actions.
.B 1
The simplest use of the HIDDEN PROTECTED specification is to declare as
HIDDEN PROTECTED those attributes which are not to be accessible outside
the body of the CLASS. Suppose for example
.index ^^CLASS body, protection of access to\\
that we have a CLASS "data#base" where the user of the CLASS
need only access the features of the CLASS through the attribute
PROCEDUREs "put" and "get". All other attributes of the CLASS
are then declared HIDDEN PROTECTED as in the following simplified excerpt:
.B 1
.nofill;.nojustify
.test page 16
.IF FOA;.NUMBER 157;.PS 80,80;.PAGE;
.ENDIF FOA
    CLASS data__base;
    HIDDEN PROTECTED diskdata, has__been__read, filesize,
    filepos, internal;
    BEGIN
        REF (directfile) diskdata;
        BOOLEAN has__been__read;
        INTEGER filesize, filepos;
        PROCEDURE internal; COMMENT this PROCEDURE is only
        used internally inside the class data__base;;
        PROCEDURE PUT; COMMENT port accessible from
        outside the CLASS ...;;
        PROCEDURE GET; COMMENT port accessible from
        outside the CLASS ...;;
        COMMENT etc. ;
    END of data__base;
.fill;.justify

.p 0,1,5
If most of the attributes of a CLASS are to be HIDDEN PROTECTED,
and only a few attributes are to be non-protected ports, then it is
easier to list the non-protected attributes. This can be done using
the NOT HIDDEN PROTECTED specification. The CLASS in the example
above could then instead begin:
.p 0,1,4
.nofill
    CLASS data_base;
    NOT HIDDEN PROTECTED put, get;
    BEGIN ...
.fill
.p 0,1,5
The NOT HIDDEN PROTECTED specification indicates that all attributes
which can be specified HIDDEN PROTECTED at that place in the program,
and which are not listed in the specification, are specified to be
HIDDEN PROTECTED.
.p 0,1,2
The syntax of the HIDDEN PROTECTED specification is defined in section
2.5.5 above.
.SUBTITLE ^^CHAPTER\\ 2.5.7.1
.p 0,2,10
2.5.7.1##^^SEMANTICS OF THE HIDDEN PROTECTED SPECIFICATION
.B 1
Attributes declared PROTECTED are only visible
inside the body of the
class where they have been specified PROTECTED, and inside the body
of subclasses to this class and inside the body of blocks prefixed
.index ^^Subclass, protection against\\
with this class or a subclass to it.
.B 1
Note that inside this body, the attributes are visible not only
by direct access but also by remote access (dot notation or
INSPECT statements) to other objects of the same CLASS.
[NOTE! Accessing local PROTECTED attributes remotely has not yet been confirmed by 
SIMULA DEVELOPMENT GROUP.]
.B 1
If an identifier in the source program, outside this scope,
would without PROTECTED refer to the PROTECTED variable,
that identifier will instead act as if the PROTECTED variable
cannot be seen, it will thus either refer to a statically enclosing
identifier with the same name, or it will give the compile time
error message "UNDECLARED IDENTIFIER".
.IF FOA;.NUMBER 158;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1
Attributes declared HIDDEN are invisible in subclasses
to the class where the HIDDEN specification occurs and in blocks prefixed
with this class or subclasses to it.
.B 1
The combined specification HIDDEN PROTECTED will thus make 
the variables invisible everywhere except in the body of the
class with the HIDDEN PROTECTED specification.
.B
A VIRTUAL
attribute may only be specified PROTECTED in the same CLASS heading
where the VIRTUAL specification is placed.
If a VIRTUAL attribute is declared HIDDEN, the effect is that
procedures with the same name in subclasses will not
take part in the virtual match. They will instead act as ordinary
(non-virtual) procedures.
.B 1
Attributes of a class may only be specified PROTECTED
in the heading of the class where the attribute is declared.
Attributes of a class may, however, be declared HIDDEN in a
subclass to it.
Such a HIDDEN specification will only be valid for subclasses
to the class where the HIDDEN specification is placed.
.B
An attribute may not be specified HIDDEN except when it is specified
PROTECTED in the same class or in a
superclass.
.B
If a HIDDEN specification contains an identifier
which is ambiguous, because the same identifier has been
used for different attributes within the prefix chain,
then the HIDDEN specification will take effect for all
these attributes with the same name. [NOTE! This mechanism
may be changed in the future, depending on SIMULA DEVELOPMENT GROUP
decisions. The definition might be changed so that each HIDDEN just
nullifies one PROTECTED level at a time.]

.B
All HIDDEN
specifications at the start of a certain CLASS must either be
of the NOT kind or of
the positive kind. Mixed specifications are illegal. The same is true for the
PROTECTED specifications. However, HIDDEN and PROTECTED may be of different
kind.
.SUBTITLE ^^CHAPTER\\ 2.5.7.2
.p 0,2,10
.IF FOA;.NUMBER 159;.PS 80,80;.PAGE;
.ENDIF FOA
^^2.5.7.2##EXAMPLES OF USE OF THE HIDDEN PROTECTED SPECIFICATION
.B 1
.nofill
Example i: WRITE-PROTECTED ATTRIBUTES
.fill
.B
The attributes "length", "width" and "height" of the following
CLASS can be given values when a new CLASS object is generated,
but can never be changed in an existing CLASS object.
.B
The attribute "density" can only be changed through the procedure
"set_density" which checks that the new value is within a legal range.
.B
The attribute values can all be used outside the CLASS body, but
not redefined, since the externally accessible ports are all PROCEDUREs.
.nofill
.p 0,1,19
    CLASS box (internal__length, internal__width,
        internal__height, internal density);
    REAL internal__length, internal__width,
        internal__height, internal density;
    NOT HIDDEN PROTECTED length, width, height, density, set__density;
    BEGIN
.left margin 8
REAL PROCEDURE length; length:= internal__length;
REAL PROCEDURE width; width:= internal__width;
REAL PROCEDURE height; height:= internal__height;
REAL PROCEDURE density; density:= internal__density;
PROCEDURE set__density(new__density);
IF new__density < 0 OR new__density > 10 THEN abort
ELSE internal__density:= new__density;
.B
set__density(internal__density); COMMENT to check initial value;
_...
.left margin 0
    END;
.fill
.p 0,2,21
.IF FOA;.NUMBER 160;.PS 80,80;.PAGE;
.ENDIF FOA
Example ii: SIMSET AS IN SIMULA COMMON BASE
.nofill
.p 0,1,19
CLASS simset;
BEGIN
    CLASS linkage;
    PROTECTED i__suc, i__pred;
    BEGIN
        REF (linkage) i__suc, i__pred;
    END;
    linkage CLASS link;
    HIDDEN i__suc, i__pred;
    BEGIN
        PROCEDURE out;
        BEGIN
            IF i__suc =/= NONE THEN
            BEGIN ....
            END;
        END;
    END;
END;
.fill
.B
As is seen above, the internal, HIDDEN attributes i__suc and i__pred
are invisible outside LINKAGE, except within the subclasses LINK
(and HEAD, analoguous to LINK) since they are declared PROTECTED
in LINKAGE, but declared HIDDEN in LINK (and HEAD).
.p 0,2,27
Example iii: INVISIBLE, NOT FORBIDDEN
.B
This example shows that PROTECTED attributes are invisible rather
than forbidden:
.nofill
.B
BEGIN
.left margin 4
INTEGER b;
.b
CLASS a; HIDDEN PROTECTED b;
BEGIN INTEGER b;
END;
.b
a CLASS asub;
BEGIN
    b:= 3; COMMENT legal, but refers to the b outside a;
END;
.b
INSPECT NEW a DO
BEGIN
    b:= 1; COMMENT legal, but refers to the b outside a;
END;
.b
a BEGIN
    b:= 2; COMMENT legal, but refers to the b outside a;
END;
.left margin 0
END;
.fill
.p 0,2,17
.IF FOA;.NUMBER 161;.PS 80,80;.PAGE;
.ENDIF FOA
Example iv: LABELS CAN ALSO BE HIDDEN
.index ^^Label, hiding of\\
.nofill
.B
BEGIN
.left margin 4
CLASS a;
HIDDEN PROTECTED la;
BEGIN
    INNER;
.index ^^INNER, example with protection\\
    la: lb:
END;
.b
a CLASS b;
BEGIN
    GOTO la; COMMENT illegal;
    GOTO lb; COMMENT legal;
END;
.left margin 0
END;
.p 0,2,15
.fill
Example v: PROTECTING THE NAME OF A CLASS.
.B
.nofill
BEGIN
    CLASS a;
    HIDDEN PROTECTED b;
    BEGIN
        REF (b) bl;
        CLASS b;
        BEGIN INTEGER i; END;
       bl:- NEW b;
    END of a;
    INSPECT NEW a DO outint(bl.i); COMMENT legal;
END;
.B
.fill
Class a has a local class B which is HIDDEN and PROTECTED.
This protects against all statements where the name of
the local class appears. Thus, the following is impossible
outside the body of a:
.B
> Creation of new objects of the class b using the NEW statement.
.B
> Declaration of references to b.
.B
> Use of the WHEN clause in the INSPECT statement.
.B
Nevertheless, it is possible to access the attributes of the
instance of the class b referred to by the reference variable
b1 in the class a, since b1 is not HIDDEN PROTECTED.
.p 0,2,15
.fill
.IF FOA;.NUMBER 162;.PS 80,80;.PAGE;
.ENDIF FOA
Example vi: PROTECTING THE "NEW" COMMAND OF SIMULA.
.B
.nofill
BEGIN
    CLASS c; HIDDEN PROTECTED b;
    BEGIN BOOLEAN b;
        CLASS d;
        BEGIN IF b THEN abort; END;
        COMMENT here, "NEW d" will not cause any error!!;
        b:= TRUE;
    END;
    INSPECT NEW c DO NEW d; COMMENT causes error!!!;
END;
.B
.fill
If you want to protect just the "NEW" command and nothing
else, this construct can be used. Note however that the construct
in example v causes compile time error, the construct in example
vi causes run time error.
.B
Class c has a boolean attribute B which is used to indicate
if the statement part is executed. Such an attribute may
be used to inhibit instance generation of a local class
through a programmed runtime check like that on line 6.
The "NEW d" phrase on line 12 will result in a call on the
"abort" procedure.
.SUBTITLE ^^CHAPTER\\ 2.6
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 163;.PS 80,80;.PAGE;
.ENDIF FOA
2.6##^^EXPRESSIONS\\
.BR
#####-----------
.B 1
^EXPRESSIONS ARE RULES FOR COMPUTING VALUES. ^EXPRESSIONS MAY
OCCUR ON THE RIGHT HAND SIDES OF ASSIGNMENT STATEMENTS, AS
ACTUAL PARAMETERS, IN ^^FOR\\-STATEMENTS, AS ARRAY INDICES, ETC.
.B 2
EXPRESSION
.index ^^Expression\\
.B 2;.LM 5;.NF;.NJ
 **                          **
 *  ARITHMETIC-EXPRESSION     *
.index ^^Arithmetic expressions\\
 *  CONDITION                 *
.index ^^Condition\\
.index ^^Condition\\
 *  ^^CHARACTER\\-EXPRESSION      *
**  DESIGNATIONAL-EXPRESSION  **
.index ^^Designational expression\\
 *  OBJECT-EXPRESSION         *
.index ^^Object expression\\
 *  ^^TEXT\\-EXPRESSION           *
.index ^^TEXT expression\\
 *  ^^TEXT\\-VALUE                *
.index ^^TEXT value\\
 **                          **
.B 2;.LM 0;.J;.F
^I^F-CLAUSE
.B 1;.I 5
^^IF\\ CONDITION ^^THEN\\
.index ^^THEN\\
.index ^^IF clause\\
.index ^^Condition\\
.B 1;.LM 0;.F;.J
^THE CONSTITUENTS OF EXPRESSIONS ARE OPERATORS AND OPERANDS.
.index ^^Operator\\
.index ^^Operand\\
^THE OPERANDS ARE CONSTANTS, VARIABLES OR FUNCTION DESIGNATORS.
.index ^^Variable, use in expression\\
.index ^^Function designator\\
^NO TWO OPERANDS MAY OCCUR SIDE BY SIDE#-#THEY MUST BE SEPARATED
.index ^^Operand\\
BY AT LEAST ONE OPERATOR. ^A DISCUSSION OF VARIABLES AND FUNCTION
DESIGNATORS PRECEDES THE DISCUSSION OF EXPRESSIONS.
.B 2
VALUE-EXPRESSION
.B 2;.LM 5;.NJ;.NF
 **                       **
 *  ARITHMETIC-EXPRESSION  *
.index ^^Arithmetic expressions\\
**  CONDITION              **
 *  ^^CHARACTER\\-EXPRESSION   *
.index ^^CHARACTER expression\\
 **                       **
.B 2;.LM 0
REFERENCE-EXPRESSION
.B 2;.LM 5;.NJ;.NF
 **                   **
 *  OBJECT-EXPRESSION  *
.index ^^Object expression\\
**                     **
 *  ^^TEXT\\-EXPRESSION    *
.index ^^TEXT expression\\
 **                   **
.F;.J
.SUBTITLE ^^CHAPTER\\ 2.6.1
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 164;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.1##^^VARIABLES\\
.B 1
^THE VALUE OF A VARIABLE MAY BE USED IN EXPRESSIONS FOR FORMING
VALUES AND MAY BE CHANGED BY ASSIGNMENTS TO THAT VARIABLE. ^THE
.index ^^Variable, assignment to\\
.index ^^Assignment\\
VALUE OF A VARIABLE IS THE VALUE OF THE LAST ASSIGNMENT TO IT,
.index ^^Variable, value of\\
OR ITS INITIAL VALUE IF NO ASSIGNMENT HAS YET BEEN MADE.
.B 1
VARIABLE
.index ^^Variable\\
.B 2;.LM 5;.NJ;.NF
 **                      **
 *  SIMPLE-VARIABLE       *
.index ^^Simple variable\\
**  SUBSCRIPTED-VARIABLE  **
.index ^^Subscript\\
 *  REMOTE-VARIABLE       *
.index ^^Remote-variable\\
 **                      **
.B 1;.F;.J;.LM 0
SIMPLE-VARIABLE
.B 1;.I 5
IDENTIFIER
.B 2;.LM 0
SIMPLE-VARIABLE
.B 2;.LM 5;.NJ;.NF
 **                 **
 *  IDENTIFIER       *
**                   **  (SUBSCRIPT-LIST)
.index ^^Subscript list\\
 *  REMOTE-VARIABLE  *
 **                 **
.B 1;.LM 0
SUBSCRIPT-LIST
.index ^^Subscript\\
.B 1;.I 10
ARITHMETIC-EXPRESSION [, ARITHMETIC-EXPRESSION]...
.index ^^Comma (,) in array subscript list\\
.index ^^Arithmetic expressions, as array subscript\\
.index ^^Arithmetic expressions\\
.B 2
REMOTE-VARIABLE
.B 2;.LM 5;.NJ;.NF
 **                            **
 *  SIMPLE-TEXT-EXPRESSION .    *
.index ^^Simple TEXT expression\\
.index ^^TEXT expression\\
**                              **  IDENTIFIER
 *  SIMPLE-OBJECT-EXPRESSION .  *
.index ^^Object expression\\
 **                            **

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
.IF FOA;.NUMBER 165;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLES:
.B 1;.TS 30;.NF;.NJ
SIMPLE-VARIABLE:	^^EPS
	A15
	A16__C\\
.B 1
SUBSCRIPTED-VARIABLE:	^^SON[2]
.index ^^Subscript\\
	ELEMENT[I,J]
	THIS SQUARE.LONG__SIDE[2]\\
.B 1
REMOTE-VARIABLE:	^^ANNA.FATHER
	APOSTLE(6).LEADER
	C.P.X
	LINE(2).SIDE(3)\\
.B 1;.LM 0;.F;.J
^A VARIABLE IS A DESIGNATION FOR A SINGLE VALUE.
.B 2
SIMPLE-VARIABLE
.B 1
^THE TYPE OF THE VALUE OF A PARTICULAR SIMPLE VARIABLE IS GIVEN
IN THE DECLARATION FOR THAT VARIABLE.
.B 2
REMOTE-VARIABLE
.B 1
^AN ATTRIBUTE OF AN OBJECT IS IDENTIFIED BY THE FOLLOWING INFORMATION:
.index ^^Pointer variable, use of\\
.index ^^Remote accessing\\
.index ^^REF variables, use of to access into CLASS objects\\
.index ^^Binding rules, remote accessing\\
.index ^^Attribute\\
.B 1;.LM 4;.I -4
1)##A REFERENCE TO THE OBJECT
.index ^^Object expression\\
.I -4
2)##A CLASS WHICH INCLUDES THAT OF THE OBJECT
.I -4
3)##AN ATTRIBUTE IDENTIFIER DEFINED IN THAT CLASS OR ANY CLASS
BELONGING TO ITS PREFIX SEQUENCE.
.B 1;.LM 0
.IF FOA;.NUMBER 166;.PS 80,80;.PAGE;
.ENDIF FOA
^LET ^X BE A SIMPLE OBJECT EXPRESSION QUALIFIED BY CLASS ^C,
.index ^^Simple object expression\\
.index ^^Object expression\\
AND ^A AN ATTRIBUTE IDENTIFIER.
.B 1
^THEN ^X.^A IS VALID IF ^X =/= ^^NONE\\ AND CLASS ^C HAS AT LEAST
.index ^^Dot (.), for remote accessing into class objects\\
ONE ATTRIBUTE IDENTIFIED BY ^A. ^IF THERE IS ONLY ONE ATTRIBUTE
WITH IDENTIFIER ^A CONTAINED IN CLASS ^C OR IN ITS PREFIX CHAIN,
THEN IT IS DESIGNATED BY ^X.^A. ^IF CLASS ^C CONTAINS MORE THAN
ONE ATTRIBUTE WITH IDENTIFIER ^A, THEN ^X.^A DESIGNATES THE 
ATTRIBUTE WITH IDENTIFIER ^A AT THE INNERMOST PREFIX LEVEL.
.B 1
^N.^B.##^THE MAIN PART OF ANY CLASS DECLARATION CAN CONTAIN
AT MOST ONE ATTRIBUTE WITH THAT IDENTIFIER.

.IFNOT FOA;.PG
.ENDIF FOA;
^EXAMPLE:
.B 1;.I 5
^^REF(C1)#X1; REF(C2)#X2; REF(C3)#X3; REF(C4)#X4;
.B 1;.I 5
CLASS C1(A); REAL A;
.I 5
BEGIN .................... END;
.B 1;.I 2
C1 CLASS C2;
.I 5
BEGIN  TEXT A; ... END;
.B 1;.I 2
C2 CLASS C3;
.I 5
BEGIN .................... END;
.B 1;.I 2
C3 CLASS C4;
.I 5
BEGIN  BOOLEAN A; ........ END;
.B 1;.I 2
X1 :- X2 :- X3 :- X4 :- NEW C4(6.0);\\

.B 2;.LM 0;.NF;.NJ;.TS 35
.IF FOA;.NUMBER 167;.PS 80,80;.PAGE;
.ENDIF FOA
##REMOTE-VARIABLE	TYPE
##---------------       ----
.B 1
^^X1.A, X2 QUA C1.A,
.index ^^QUA, example of use\\
X3 QUA C1.A, X4 QUA C1.A	REAL
.B 1
X1 QUA C2.A, X2.A,
X3 QUA C2.A, X4 QUA C2.A	TEXT
.B 1
X1 QUA C3.A, X2 QUA C3.A,
X3.A, X4 QUA C3.A	TEXT
.B 1
X1 QUA C4.A, X2 QUA C4.A,
X3 QUA C4.A, X4.A	BOOLEAN\\
.B 1;.F;.J;.LM 0
^IT IS NOT POSSIBLE TO ACCESS EITHER LABEL OR SWITCH IDENTIFIERS REMOTELY.
.index ^^Access into a CLASS object\\
.B 1
^IF CLASS ^C OR A CLASS IN ITS PREFIX CHAIN CONTAINS A CLASS
ATTRIBUTE, THEN ACCESSING OF ANY ATTRIBUTE IN CLASS ^C IS ONLY
.index ^^Access into a CLASS object\\
POSSIBLE THROUGH A CONNECTION STATEMENT.

.IFNOT FOA;.PG
.ENDIF FOA;
^EXAMPLE:
.B 1;.I 5
^^CLASS C1; BEGIN  REAL D;  END;
.I 2
C1 CLASS C2;
.I 5
BEGIN  CLASS F.....;
.I 12
BOOLEAN Q;
.I 5
END;
.I 5
REF(C2)X;\\
.B 1
^THEN ^X.^F, ^X.^Q, ^X.^D
.BR
ARE ALL ILLEGAL ATTEMPTS AT REMOTE ACCESSING.
.index ^^Access into a CLASS object\\
.B 1
.IF FOA;.NUMBER 168;.PS 80,80;.PAGE;
.ENDIF FOA
^BUT IT IS LEGAL TO WRITE
.B 1;.I 5
^^INSPECT X DO
.I 5
BEGIN  ...F...
.I 12
_...Q...
.I 12
_...^D...
.I 5
END\\
.B 1
OR, FOR THE ^^REAL\\ ATTRIBUTE OF ^C1, ^X ^^QUA C1.D.\\
.B 1
^A SIMPLE-TEXT-EXPRESSION IS ITSELF A COMPOUND STRUCTURE IN THE
.index ^^TEXT expression\\
SENSE THAT IT HAS ATTRIBUTES ACCESSIBLE THROUGH THE DOT NOTATION.
.index ^^Access into a CLASS object\\
^^TEXT\\-VALUE ASSIGNMENTS MAY BE MADE THROUGH THE USE OF THE SYSTEM-DEFINED
PROCEDURE ^^SUB, STRIP\\ AND ^^MAIN\\ TO SUB-FIELDS (^^T.SUB, T.STRIP\\)
AND SUPER-FIELDS (^^T.MAIN\\) OF THE TEXT OBJECT REFERENCED BY ^T.
.B 1;.LM 6;.I -6
E.G.##^^T.SUB(1,24) := "CHANGE IN FIRST 24 CHARS"
.BR
T.MAIN.STRIP := NOTEXT\\
.B 2;.LM 0
^SUBSCRIPTED VARIABLES
.B 1
.index ^^Index to an array^^
.index ^^Argument to an array^^
^A SUBSCRIPTED VARIABLE IS AN ARRAY COMPONENT. ^THE TYPE OF A
.index ^^Subscript\\
.index ^^ARRAY component\\
SUBSCRIPTED VARIABLE IS THE TYPE OF THE ARRAY. ^EACH ARITHMETIC
.index ^^Arithmetic expressions, as array subscript\\
EXPRESSION IN THE SUBSCRIPT LIST IS CALLED A SUBSCRIPT AND THE
COMPLETE LIST OF SUBSCRIPTS IS ENCLOSED IN PARENTHESES (##), OR SQUARE BRACKETS [##].
(^NOTE: ^SQUARE BRACKETS ARE PREFERRED FOR BETTER READABILITY.)  ^EACH
SUBSCRIPT ACTS AS A VARIABLE OF TYPE ^^INTEGER\\ AND THE EVALUATION
OF THE SUBSCRIPT IS UNDERSTOOD TO BE EQUIVALENT TO AN ASSIGNMENT
TO THIS FICTITIOUS VARIABLE.
.B 1
.index ^^ARRAY bounds, exceeding of\\
.index ^^Bounds of an array, exceeding of\\
^A RUN TIME ERROR WILL OCCUR WHEN ANY OF THE SUBSCRIPTS IS OUTSIDE
THE DECLARED BOUNDS ON THAT SUBSCRIPT OF THE ARRAY. ^THIS
.index ^^Subscript bound\\
CAN, AT THE PROGRAMMERS OWN RISK, BE REMOVED WITH THE COMPILER SWITCH -^A.
.SUBTITLE ^^CHAPTER\\ 2.6.2
.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 169;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.2##^^FUNCTION DESIGNATORS\\
.B 1
^A FUNCTION DESIGNATOR DENOTES THE VALUE OBTAINED BY EVALUATING
THE ASSOCIATED PROCEDURE BODY WHEN SUPPLIED WITH THE ASSOCIATED ACTUAL
.index ^^Expression\\
.index ^^Actual parameter list\\
PARAMETER LIST (IF ANY).
.index ^^Actual parameter\\
.B 2
FUNCTION-DESIGNATOR
.index ^^Function designator\\
.B 2;.LM 5;.NJ;.NF
 **                   **
 *  IDENTIFIER         *
**                     **    [ACTUAL-PARAMETER-LIST]
 *  REMOTE-IDENTIFIER  *
.index ^^Remote identifier\\
 **                   **
.B 2;.LM 0;.F;.J
ACTUAL-PARAMETER-LIST
.B 1;.I 5
(ACTUAL-PARAMETER[, ACTUAL-PARAMETER]...)
.index ^^Comma (,), use between subscripts\\
.B 2
ACTUAL-PARAMETER
.B 2;.LM 5;.NJ;.NF
 **                      **
 *  EXPRESSION            *
 *  ^^ARRAY\\-IDENTIFIER      *
.index ^^ARRAY identifier\\
**  ^^SWITCH\\-IDENTIFIER     **
.index ^^SWITCH identifier\\
 *  ^^PROCEDURE\\-IDENTIFIER  *
.index ^^PROCEDURE identifier\\
 *  ^^LABEL\\-IDENTIFIER      *
.index ^^Label identifier\\
 **                      **

.IFNOT FOA;.PG;
.ENDIF FOA;.I -5
^EXAMPLES:
.B 1
^^ININT
INTEXT(20)
SIN(A+B)
H.FIRST
CURRENT.NEXTEV.SUC
POINT(5).MODULUS\\
.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 170;.PS 80,80;.PAGE;
.ENDIF FOA
^FUNCTION-DESIGNATORS DENOTE SINGLE ARITHMETIC, ^^BOOLEAN, TEXT\\
OR ^^CHARACTER\\ VALUES OR OBJECT- OR ^^TEXT\\-REFERENCES. ^THESE
VALUES ARE OBTAINED BY APPLYING A SET OF RULES DEFINED BY THE
PROCEDURE DECLARATION TO A SET OF ACTUAL PARAMETERS. ^THE ACTUAL
PARAMETER LIST MUST CORRESPOND IN NUMBER AND ORDER TO THE FORMAL
.index ^^Formal-actual parameter correspondence\\
.index ^^Actual-formal parameter correspondence\\
PARAMETER LIST IN THE CORRESPONDING PROCEDURE DECLARATION.
.B 1
^CERTAIN IDENTIFIERS, EXPRESSED AS PROCEDURES, ARE PRE-DEFINED
IN THE ^^SIMULA\\ SYSTEM. ^A LIST IS GIVEN IN ^APPENDIX ^B.
^CALLS TO STANDARD PROCEDURES CONFORM TO THE SYNTAX OF CALLS
TO DECLARED PROCEDURES AND ARE EQUIVALENT TO NORMAL PROCEDURE CALLS.
(^NOTE, HOWEVER, THAT STANDARD PROCEDURES MAY NOT BE PASSED AS PARAMETERS.)
^THE IDENTIFIER OF A SYSTEM DEFINED PROCEDURE IS NOT RESERVED,
AND MAY BE DECLARED TO HAVE ANOTHER MEANING AT ANY LEVEL. (^THIS
.index ^^Identifier clash\\
IS NOT RECOMMENDED PRACTICE AS IT WILL OBVIOUSLY MAKE THE PROGRAM
MORE DIFFICULT TO READ AND UNDERSTAND). ^THE IDENTIFIER THEN
ASSUMES THE NEW MEANING THROUGHOUT THE SCOPE OF THE BLOCK IN WHICH IT WAS DECLARED.
.SUBTITLE ^^CHAPTER\\ 2.6.3
.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 171;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.3##^^ARITHMETIC EXPRESSIONS\\
.index ^^Arithmetic expressions, syntax and semantics of\\
.B 1
^AN ARITHMETIC EXPRESSION IS A RULE FOR COMPUTING A NUMBER.
.B 2
ARITHMETIC-EXPRESSION
.index ^^Arithmetic expressions\\
.B 2;.LM 5;.NJ;.NF
 **                                        **
 *  SIMPLE-ARITHMETIC-EXPRESSION            *
.index ^^Simple arithmetic expression\\
**  ^^IF\\-CLAUSE SIMPLE-ARITHMETIC-EXPRESSION  **
.index ^^IF clause\\
.index ^^IF clause\\
 *            ^^ELSE\\ ARITHMETIC-EXPRESSION    *
.index ^^ELSE\\
 **                                        **
.B 2;.LM 0;.F;.J
SIMPLE-ARITHMETIC-EXPRESSION
.B 1;.I 5
[+!-]  ARITHMETIC-PRIMARY [ARITHMETIC-OPERATOR ARITHMETIC-
.index ^^Arithmetic primary\\
.index ^^Operator\\
.BR
.TS 44
   	PRIMARY] ...
.B 2
ARITHMETIC-PRIMARY
.B 2;.LM 5;.NF;.NJ
 **                                **
 *  ARITHMETIC-CONSTANT             *
.index ^^Arithmetic constants\\
.index ^^Constants, use in expression\\
 *  ARITHMETIC-VARIABLE             *
.index ^^Arithmetic variable\\
**  ARITHMETIC-FUNTION-DESIGNATOR   **
 *  (ARITHMETIC-EXPRESSION)         *
.index ^^Right parenthesis ()) in expression\\
.index ^^Left parenthesis (() in expression\\
 **                                **
.B 2;.LM 0
ARITHMETIC-OPERATOR
.index ^^Operator\\
.B 2;.LM 5;.NJ;.NF
+###-###*###**###_^###/###//
.index ^^Arithmetic operators\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
.IF FOA;.NUMBER 172;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLES:
.B 1
ARITHMETIC-PRIMARY
.B 1;.LM 5
15.7
16^^R1FA
X
SIN(23*P1/180)
.index ^^Sinus function\\
(IF X>0 THEN X ELSE -X)\\
.B 1;.I -5
ARITHMETIC-EXPRESSION
.B 1
^^X**2 + Y**2
X + A(J)**2
EXP(2 + (IF B THEN 3 ELSE 4))
IF X > 0 THEN 1 ELSE IF X < 0 THEN -1 ELSE 0
-3*(-5)\\
.B 1;.LM 0
^EXAMPLES OF INCORRECT ARITHMETIC EXPRESSIONS:
.B 1;.NF;.NJ;.LM 0;.TS 31
^^(A + B) C)\\	LEFT PARENTHESIS MISSING
.B 1
-3*-5	TWO OPERATORS TOGETHER
.B 1
^^(A + B) _& - 0.5\\	_& ONLY ALLOWED IN CONSTANTS
.B 1
^^X + (IF Y < 0 THEN 2)	ELSE\\ ALTERNATIVE IS MISSING
.B 1
^^X + IF Y < 0 THEN 2 ELSE 3\\	THE ^^IF\\ EXPRESSION MUST BE
.index ^^IF clause\\
.index ^^IF clause example of use in expression\\
	##ENCLOSED IN PARENTHESES
.B 2;.LM 0;.F;.J
^THE VALUE OF A SIMPLE-ARITHMETIC-EXPRESSION IS THE VALUE OBTAINED
BY EXECUTING THE ARITHMETIC OPERATIONS ON THE ACTUAL NUMERIC
VALUES OF THE PRIMARIES OF THE EXPRESSION. ^THE ACTUAL NUMERIC
VALUE OF A PRIMARY IS OBVIOUS IN THE CASE OF NUMBERS.
.B 1
.IF FOA;.NUMBER 173;.PS 80,80;.PAGE;
.ENDIF FOA
^FOR VARIABLES, IT IS THE CURRENT VALUE (ASSIGNED LAST IN THE
DYNAMIC SENSE); AND FOR FUNCTION-DESIGNATORS IT IS THE VALUE
.index ^^Arithmetic function designator\\
ARISING FROM THE COMPUTING RULES DEFINING THE FUNCTION-PROCEDURE
WHEN APPLIED TO THE CURRENT VALUES OF THE PROCEDURE PARAMETERS
IN THE EXPRESSION. ^FOR ARITHMETIC-EXPRESSIONS ENCLOSED IN PARENTHESIS,
THE VALUE MUST, THROUGH A RECURSIVE ANALYSIS, BE EXPRESSED IN
TERMS OF THE VALUES OF PRIMARIES OF THE OTHER THREE KINDS.
.B 1
^IN THE MORE GENERAL ARITHMETIC-EXPRESSIONS, WHICH INCLUDE ^^IF-\\ CLAUSES, A SIMPLE-ARITHMETIC-EXPRESSION
IS SELECTED ON THE BASIS OF THE ACTUAL VALUES OF THE ^^BOOLEAN\\ CONDITIONS.
.index ^^Condition\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^IF THE FORM OF THE ARITHMETIC EXPRESSION IS
.B 1;.I 5
^I^F CONDITION ^^THEN\\ SIMPLE-ARITHMETIC-EXPRESSION
.I 18
^^ELSE\\ ARITHMETIC-EXPRESSION
.B 1
THE SELECTION OF THE APPROPRIATE VALUE IS MADE ACCORDING TO THE RULES:
.B 1;.LM 4;.I -4
1.##^THE CONDITION IN THE ^^IF\\-CLAUSE IS EVALUATED.
.index ^^IF clause\\
.index ^^IF clause\\
.B 1;.I -4
2.##^IF THE RESULT OF 1 IS ^^TRUE\\, THEN THE VALUE OF THE EXPRESSION
IS THE VALUE OF THE SIMPLE ARITHMETIC EXPRESSION FOLLOWING THE
^^IF\\-CLAUSE. ^OTHERWISE IT IS THE VALUE OF THE ARITHMETIC
.index ^^IF clause\\
.index ^^IF clause\\
EXPRESSION FOLLOWING THE ^^ELSE.\\
.B 1
E.G.##^^IF X < 0 THEN 4 ELSE 17\\
.B 1;.I 6
IF ^X < 0 THEN THE VALUE IS 4
.I 6
IF ^X = 0 OR ^X > 0 THEN THE VALUE IS 17.
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 174;.PS 80,80;.PAGE;
.ENDIF FOA
^ARITHMETIC OPERATORS AND TYPES
.BR
------------------------------
.index ^^Floating point expressions\\
.index ^^Type of arithmetic expression\\
.index ^^Arithmetic operators and types\\
.index ^^Operator\\
.B 1
^APART FROM THE ^^CONDITIONS\\ OF ^I^F-CLAUSES, THE CONSTITUENTS
OF ARITHMETIC EXPRESSIONS ARE OF TYPES ^^SHORT INTEGER, INTEGER, REAL\\ OR ^^LONG REAL.\\
.index ^^Type of arithmetic expression\\
.index ^^SHORT INTEGER in expression\\
.index ^^REAL in expression\\
.index ^^LONG REAL in expression\\
.index ^^INTEGER in expressions\\
.index ^^Arithmetics of (LONG)REAL quantities\\
.B 1
^THE FOLLOWING HIERARCHY MAY BE ASSOCIATED WITH THESE TYPES.
.B 1;.TS 23,34
TYPE NUMBER	TYPE	SHORTENED NOTATION
.B 1;.TS 5,14,41
	1	^^[SHORT]##INTEGER	I
.TS 5,23,41
.BR
	2	REAL	R
.BR
	3	LONG REAL	LR\\
.B 1;.LM 0
^THE TYPES ARE RANKED ACCORDING TO THEIR ASSOCIATED TYPE NUMBER.
^THUS ^^LONG REAL\\ IS HIGHER THAN ^^INTEGER, INTEGER\\ IS LOWER THAN ^^REAL.\\
.B 1
^THE MEANINGS OF THE BASIC OPERATORS ARE:
.index ^^Operator\\
.B 1;.TS 5,11
	+	ADDITION
.BR
	-	SUBTRACTION
.BR
	*	MULTIPLICATION
.BR
_^ OR **	EXPONENTIATION
.BR
	/	DIVISION
.BR
	//	INTEGER DIVISION

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0
.IF FOA;.NUMBER 175;.PS 80,80;.PAGE;
.ENDIF FOA
^THE TYPES OF ARITHMETIC EXPRESSIONS ARE GIVEN BY THE FOLLOWING RULES:
.B 1;.LM 4;.I -4
1)##^THE OPERATORS + AND - MAY BE USED AS UNARY OPERATORS
.B 1;.I 5
+ OPERAND
.index ^^Operand\\
.I 5
- OPERAND
.B 1;.LM 4
^THE TYPE OF THE RESULTING EXPRESSION IS THE TYPE OF THE OPERAND.
.B 1;.I -4
2)##^THE TYPE OF THE ARITHMETIC EXPRESSION
.index ^^Floating point expressions\\
.B 1;.I 5
OPERAND1 [+!-] OPERAND2
.B 1
IS THE HIGHER OF THE TYPES OF OPERAND1 AND OPERAND2. ^THIS IS
DISPLAYED IN THE TABLE:
.B 1;.TS 20
TYPE OF OPERAND1	###TYPE OF OPERAND2
.index ^^Floating point expressions\\
.index ^^Operand\\
.B 1;.TS 18,24,29,35
		#^^I	#R	LR
.br
	####------------------
.BR
	####!
.BR
	#I##!	#I	#R	LR
.BR
	#R##!	#R	#R	LR
.BR
	LR##!	LR	LR	LR\\
.B 1;.LM 4;.I -4
3)##/ DENOTES DIVISION, AND
.B 1;.I 5
OPERAND1 / OPERAND2
.B 1
ALWAYS RESULTS IN AN ARITHMETIC EXPRESSION OF TYPE ^^REAL\\ OR
^^LONG REAL.\\ ^IF EITHER OF OPERAND1 OR OPERAND2 ARE OF TYPE
^^LONG REAL\\ THEN SO IS THE RESULTING EXPRESSION, OTHERWISE
IT IS OF TYPE ^^REAL.\\
.B 1
.IF FOA;.NUMBER 176;.PS 80,80;.PAGE;
.ENDIF FOA
^THIS IS DISPLAYED IN THE TABLE:
.B 1;.TS 12,31
	TYPE OF OPERAND1	###TYPE OF OPERAND2
.B 1;.TS 24,35,40,46
		#^^I	#R	LR
.br
	####----------------------
.BR
	####!
.BR
	#I##!	#R	#R	LR
.BR
	#R##!	#R	#R	LR
.BR
	LR##!	LR	LR	LR\\
.B 1;.LM 4
^A RUN TIME ERROR WILL ALWAYS RESULT IF THE VALUE OF OPERAND2 IS ZERO.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -4
4)##// DENOTES INTEGER DIVISION. ^THE OPERATOR IS DEFINED ONLY
.index ^^Floating point expressions\\
BETWEEN TWO OPERANDS OF TYPE ^^INTEGER\\ AND GIVES THE ^^INTEGER\\ RESULT
.B 1;.I 5
^^A // B = SIGN (A*B) * ENTIER (ABS(A/B))\\
.B 1
^IF, IN
.B 1;.I 5
OPERAND1 // OPERAND2
.index ^^Operand\\
.B 1
THE TYPES OF OPERAND1 AND OPERAND2 ARE NOT BOTH ^^INTEGER,\\ THEN
THEY ARE ROUNDED TO TYPE ^^INTEGER\\ AND THEN THE OPERATION,
AS DEFINED ABOVE, IS CARRIED OUT.
.B 1
^EXAMPLES:
.B 1;.LM 14;.TS 31;.NF;.NJ
10 // 5	=  2
 9 // 5	=  1
-9 // 5	= -1
 9 //(-5)	= -1
.B 1;.LM 4;.F;.J;.I -4
.IF FOA;.NUMBER 177;.PS 80,80;.PAGE;
.ENDIF FOA
5)##^THE OPERATION
.index ^^Floating point expressions\\
.B 1;.I 5
OPERAND1**OPERAND2#####OR##OPERAND1_^OPERAND2
.B 1
DENOTES EXPONENTIATION, WHERE OPERAND1 IS THE BASE AND OPERAND2 THE EXPONENT.
.B 1;.TS 13,27,36
E.G.	2**3	MEANS	8 (=2*2*2)
.BR
	2**(3**4)	MEANS	2 TO THE POWER
.BR
			(3 TO THE 4TH POWER)
.BR
	2**3**4	MEANS	2 CUBED TO THE 4TH POWER
.B 1;.LM 4
^THE TYPE IS ^^REAL\\ UNLESS ONE OF OPERAND1 OR OPERAND2 IS OF TYPE
^^LONG REAL\\ WHEN IT IS ^^LONG REAL.\\
(^THIS IS A DIFFERENCE FROM ^ALGOL#60 WHERE THE TYPE IS ^^INTEGER\\ IF BOTH
OPERANDS ARE POSITIVE ^^INTEGER\\S.  ^HOWEVER, IF OPERAND1 AND OPERAND2 ARE POSITIVE
INTEGERS AND THE RESULT IS LESS THAN 134258569, THE RESULT RETAINS FULL INTEGER PRECISION. ^IN THE CASE WHERE BOTH OPERANDS ARE INTEGER CONSTANTS AND
OPERAND2 IS 2, NO TYPE CONVERSION IS PERFORMED.)

.IFNOT FOA;.PG;
.ENDIF FOA;.I -4
6)##^WHEN THE TYPE OF AN ARITHMETIC EXPRESSION CAN NOT BE DETERMINED
AT COMPILE-TIME, IT IS CONSIDERED TO BE THE HIGHEST POSSIBLE
TYPE IN THE HIERARCHY OF THE ALTERNATIVES.
.B 1
^IF IN
.B 1;.I 5
^^IF X > 0 THEN P.R ELSE S\\
.B 1
THE RESULT OF AN EXPRESSION IS OF ONE ARITHMETIC TYPE AND THE
EXPRESSION IS ASSIGNED TO A VARIABLE OF ANOTHER ARITHMETIC TYPE,
THE RESULT IS CONVERTED TO THE APPROPRIATE TYPE.
.B 1;.I -4
7)##^FOR MATHEMATICAL FUNCTIONS(LIKE ^^SIN\\ OR ^^TAN\\) THE
.index ^^Square root function, type of\\
.index ^^SIN function, type of\\
.index ^^TAN function, type of\\
.index ^^Mathematical functions, type of\\
.index ^^Built-in mathematical functions, type of\\
TYPE OF THE FUNCTION IS THE SAME AS THE TYPE OF THE ARGUMENT.
^SOME OF THESE MATHEMATICAL FUNCTIONS ARE NOT PROVIDED FOR THE
^^LONG REAL\\ TYPE. ^IN THAT CASE, A WARNING MESSAGE IS GIVEN
AND THE ^^REAL\\ FUNCTION IS USED INSTEAD. (^SEE ^APPENDIX ^B.)
^NOTE THAT ABS WORKS ACCORDING TO ^ALGOL DEFINITON - I.E.
ABS IS [^^LONG] REAL\\ EVEN IF ACTUAL PARAMETER IS ^^INTEGER\\.
^THIS MIGHT BE CHANGED IN THE FUTURE FOR COMPATIBILITY
REASONS.)

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 178;.PS 80,80;.PAGE;
.ENDIF FOA
^ARITHMETIC OPERATOR PRECEDENCE
.BR
------------------------------
.index ^^Arithmetic operator precedence\\
.index ^^Operator\\
.B 1
^THE EVALUATION OF AN ARITHMETIC-EXPRESSION CAN BE CONSIDERED
AS TAKING PLACE IN A NUMBER OF SCANS THROUGH THE EXPRESSION,
EACH SCAN GOING FROM LEFT TO RIGHT:
.B 1;.LM 4;.I -4
1)##^THE VALUES OF THE CONSTANTS, VARIABLES AND FUNCTION DESIGNATORS ARE EVALUATED.
.B 1;.I -4
2)##^ANY SUBEXPRESSION BETWEEN A LEFT PARENTHESIS AND ITS MATCHING
RIGHT PARENTHESIS IS EVALUATED (ACCORDING TO RULES 2, 3, 4, 5)
AND IS USED AS A PRIMARY IN SUBSEQUENT CALCULATIONS.
.B 1;.I -4
3)##^ALL EXPONENTIATIONS ARE EVALUATED.
.B 1;.I -4
4)##^ALL MULTIPLICATIONS, DIVISIONS AND INTEGER DIVISIONS ARE EVALUATED.
.B 1;.I -4
5)##^ALL ADDITIONS AND SUBTRACTIONS ARE EVALUATED.
.B 1;.LM 0
^THE OPERATOR PRECEDENCES MAY BE SUMMARIZED BY
.B 1;.TS 7
1.	(#####)####[#####]
.BR
2.	**####_^
.BR
3.	*#####/###//
.BR
4.	+#####-
.B 2;.LM 0
^ARITHMETICS OF ^^REAL\\ AND ^^LONG REAL\\ QUANTITIES
.BR
--------------------------------------------
.B 1
^QUANTITIES OF TYPE ^^REAL\\ AND ^^LONG REAL\\ ARE DEFINED TO
A FINITE ACCURACY. ^THUS ANY OPERATION PERFORMED ON SUCH QUANTITIES
IS SUBJECT TO A POSSIBLE DEVIATION. ^THE ANALYSIS OF THE POSSIBLE
CONSEQUENCES SHOULD BE CARRIED OUT BY A NUMERICAL ANALYST.
.SUBTITLE ^^CHAPTER\\ 2.6.4
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 179;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.4##^^CONDITIONS\\
.B 1
^CONDITIONS (OR ^^BOOLEAN-\\EXPRESSIONS) RETURN THE VALUES ^^TRUE\\
OR ^^FALSE.\\ ^THEIR PRIME USE IS IN CONDITIONAL EXPRESSIONS AND
.index ^^FALSE\\
CONDITIONAL STATEMENTS.
.B 2;.LM 0;.NJ;.NF
CONDITION
---------
                    
 **                                                       **
^^ *  BOOLEAN\\-PRIMARY [^^BOOLEAN\\-OPERATOR ^^BOOLEAN\\-PRIMARY]...  *
.index ^^BOOLEAN primary\\
.index ^^BOOLEAN operator\\
.index ^^BOOLEAN expression\\
.index ^^Logical expression\\
.index ^^Logical operator\\
**                                                         **
 *  ^^IF\\-CLAUSE ^^BOOLEAN\\-PRIMARY ^^ELSE\\ CONDITION               *
.index ^^IF clause\\
 **                                                       **
.B 2;.LM 0;.NJ;.NF
^^BOOLEAN-\\PRIMARY
---------------
                    
           **                             **
           *  ^^BOOLEAN\\-VARIABLE             *
.index ^^BOOLEAN variable\\
**     **  *  ^^BOOLEAN\\-FUNCTION-DESIGNATOR  *
.index ^^BOOLEAN function designator\\
^^*  NOT  *  *  TRUE                         *
*   _\   * **  FALSE                        **\\
**     **  *  RELATION                     *
.index ^^Relation\\
           *  (CONDITION)                  *
           **                             **
.B 2;.LM 0
^^BOOLEAN\\-OPERATOR
.index ^^BOOLEAN operator\\
----------------
.B 1;.LM 5
^^
 **                      **
 *                        *
**  AND ! OR ! EQV ! IMP  **
 *                        *
 **                      **\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 80
RELATION
.index ^^Relation\\
--------
.B 1
.index ^^Comparing operators\\
 **                                                                      **
 *                                **     **                               *
 *                                *   =   *                               *
 *                                *   >   *                               *
.index ^^GT (>)\\
.index ^^Greater than (>)\\
 *                                *  >=   *                               *
.index ^^GE (>=)\\
 *  SIMPLE-VALUE-EXPRESSION      **   <   **  SIMPLE-VALUE-EXPRESSION     *
.index ^^Simple value expression in realtion\\
.index ^^LT (<)\\
 *                                *  <=   *                               *
.index ^^LE (<=)\\
 *                                *  _\=   *                               *
 *                                **     **                               *
 *                                                                        *
 *                                                                        *
 *                                **     **                               *
 *                                *  = =  *                               *
**  SIMPLE-REFERENCE-EXPRESSION  **       ** SIMPLE-REFERENCE-EXPRESSION  **
.index ^^Simple reference expression in relation\\
 *                                *  =/=  *                               *
.index ^^Reference not equal (=/=)\\
 *                                **     **                               *
 *                                                                        *
 *                                                                        *
 *                                **     **                               *
 *                                *  ^^IS\   *                               *
 *  SIMPLE-REFERENCE-EXPRESSION  **       ** CLASS-IDENTIFIER             * 
 *                                *  ^^IN\\   *                               *
 *                                **     **                               *
 **                                                                      **
.B 2;.LM 0;.RM 70;.F;.J;.PS 58,70
.IF FOA;.NUMBER 180;.PS 80,80;.PAGE;
.ENDIF FOA
^NOTE THE EQUIVALENT MODES OF WRITING:
.B 1;.TS 10,21,33;.NF;.NJ
	#_\	OR	^^NOT
.index ^^NOT (_\)\\
.TS 10,33
	#=	^^EQ
.index ^^EQ (=)\\
	_\=	NE
.index ^^NE (_\=)\\
	#<	LT
.index ^^LT (<)\\
	<=	LE
.index ^^LE (<=)\\
	#>	GT
.index ^^GT (>)\\
.index ^^Greater than (>)\\
	>=	GE\\
.index ^^GE (>=)\\
.B 1;.LM 0
^EXAMPLES:
.B 1;.LM 5
^^TRUE
.index ^^TRUE\\
FATHER AND SON
X = 0 OR _\ (Y > C)
NOT (X IN HEAD)
T == NOTEXT
.index ^^Reference equal (==)\\
FATHER =/= NONE
C = 'A'\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0
.IF FOA;.NUMBER 181;.PS 80,80;.PAGE;
.ENDIF FOA
^^BOOLEAN OPERATORS\\
.index ^^BOOLEAN operator\\
.B 1
^THE MEANINGS OF THE LOGICAL OPERATORS
.index ^^BOOLEAN operator\\
.B 1;.TS 16,29
	^^NOT\\	NOT
	^^AND\\	AND
.index ^^AND\\
	^^OR\\	OR
.index ^^OR\\
	^^IMP\\	IMPLICATION
.index ^^IMP\\
.index ^^Implication (IMP) Boolean operator\\
	^^EQV\\	EQUIVALENT
.index ^^EQV\\
.B 1;.LM 0
ARE GIVEN IN THE TABLE:
.UC;.B 1;.TS 11,15,20,27,32,36
##P	!	T	T	F	F
	!
##Q	!	T	F	T	F
	!
------------------------------------
	!
NOT P	!	F	F	T	T	IF P THEN FALSE ELSE TRUE
P AND Q	!	T	F	F	F	IF P THEN Q ELSE FALSE
P OR Q	!	T	T	T	F	IF P THEN TRUE ELSE Q
P IMP Q	!	T	F	T	T	IF P THEN Q ELSE TRUE
P EQV Q	!	T	F	F	T	IF P THEN Q ELSE NOT Q\\
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 182;.PS 80,80;.PAGE;
.ENDIF FOA
^NOTE THAT A ^BOOLEAN EXPRESSION IS ALWAYS EVALUATED COMPLETELY.
IN SOME CASES IT MAY BE MORE EFFEICIENT OR EVEN NECESSARY
TO USE THE EXPANDED FORM GIVEN BY THE TABLE ABOVE.
.B 1
^FOR EXAMPLE:
.B
.I 10
^^WHILE T.MORE AND T.GETCHAR = ' ' DO;\\
.B 1
MAY WORK MORE SAFELY CODED:
.B
.I 10
^^WHILE (IF T.MORE THEN T.GETCHAR = ' ' ELSE FALSE) DO;\\
.B 2
^PRECEDENCE OF ^^OPERATORS
.BR
-----------------------
.index ^^Precedence of operators\\
.index ^^BOOLEAN operator\\
.LC;.B 1
^THE SEQUENCE OF OPERATIONS WITHIN ONE CONDITION IS FROM LEFT
TO RIGHT WITH THE FOLLOWING ADDITIONAL RULES:
.B 1;.TS 16
FIRST:	ARITHMETIC EXPRESSIONS (+, -, **, _^, /, //)
.BR
	###ACCORDING TO SECTION 6.3
.BR
SECOND:	RELATIONS (<, <=, =, ^N^E, _\=, >, >=, ==, =/=, ^I^S, ^I^N)
.index ^^Relation\\
.index ^^Reference equal (==)\\
.BR
THIRD:	^^NOT\\
.BR
FOURTH:	^^AND\\
.BR
FIFTH:	^O^R
.BR
SIXTH:	^I^M^P
.BR
SEVENTH:	^E^Q^V
.B 1;.LM 0
^THE USE OF PARENTHESES IS INTERPRETED AS IN SECTION 6.3.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2
.IF FOA;.NUMBER 183;.PS 80,80;.PAGE;
.ENDIF FOA
^RELATIONS
.B
---------
.B 1;.LM 4;.I -4
1)##^^IS, IN\\
.index ^^IS\\
.B 1
^THE OPERATORS ^^IS\\ AND ^^IN\\ TEST THE CLASS MEMBERSHIP OF A REFERENCED OBJECT:
.index ^^IS\\
.index ^^IN\\
.index ^^CLASS identifier in expression with IN or IS\\
.index ^^Object expression\\
.B 1;.LM 15;.TS 15;.I -11
^^X IS C\\	IS ^^TRUE\\ ONLY IF ^X IS A REFERENCE TO AN OBJECT
.index ^^Object expression\\
BELONGING TO THE CLASS ^C, OTHERWISE THE VALUE IS ^^FALSE\\
.B 1;.I -11
^^X IN C\\	IS ^^TRUE\\ ONLY IF ^X IS A REFERENCE TO AN OBJECT
BELONGING TO EITHER THE CLASS ^C OR TO A SUB-CLASS OF ^C, OTHERWISE
THE VALUE IS ^^FALSE.\\
.B 1;.LM 4
^BOTH ^^X IN C\\ AND ^^X IS C\\ ARE ^^FALSE\\ IF ^X == ^^NONE.\\
.index ^^Reference equal (==)\\
.B 1;.I -4
2)##^REFERENCE COMPARATORS (==, =/=)
.index ^^Reference not equal (=/=)\\
.index ^^Reference equal (==), main treatment of\\
.index ^^Reference comparator, main treatment of\\
.B 1
^THESE OPERATORS COMPARE EITHER TWO SIMPLE TEXT REFERENCES OR
.index ^^TEXT reference, comparison of\\
.index ^^TEXT values, comparison of\\
TWO SIMPLE OBJECT EXPRESSIONS. ^TWO OBJECT (TEXT) REFERENCES
.index ^^Simple object expression\\
.index ^^Object expression\\
^X AND ^Y ARE IDENTICAL IF THEY REFER TO THE SAME OBJECT (TEXT
.index ^^Object expression\\
VALUE INSTANCE) OR IF BOTH ARE ^^NONE (NOTEXT).\\ ^IN THESE CASES,
THE RELATION ^X == ^Y IS ^^TRUE.\\ ^OTHERWISE IT IS ^^FALSE.\\
.index ^^Reference equal (==)\\
.B 1
^THE RELATION ^^X =/= Y\\ HAS THE VALUE OF ^^NOT (X == Y).\\
.index ^^Reference not equal (=/=)\\
.index ^^Reference equal (==)\\
.B 1
^IF ^X AND ^Y ARE TWO TEXT REFERENCES, THEN ^X =/= ^Y AND 
^X = ^Y MAY BOTH BE ^^TRUE\\ IF ^X AND ^Y REFER TO PHYSICALLY
DISTINCT CHARACTER SEQUENCES WHICH ARE EQUAL.
.index ^^CHARACTER values, comparison\\
.B 1;.I -4
.IF FOA;.NUMBER 184;.PS 80,80;.PAGE;
.ENDIF FOA
3)##^VALUE COMPARATORS (=, ^N^E, _\=, >, >=, <, <=)
.index ^^Value comparators\\
.B 1
^THE RELATIONS TAKE THE VALUE ^^TRUE\\ IF THE CORRESPONDING RELATION
IS SATISFIED FOR THE ACTUAL VALUES OF THE EXPRESSIONS INVOLVED, OTHERWISE ^^FALSE.\\
.B 1
^EXAMPLES:
.B 1;.TS 10,14,18,26,33
	5	=	3	IS	^^FALSE\\
.BR
	' '	=	'+'	IS	^^FALSE\\
.BR;.LM 33;.TS 14,18,26,33;.I -23
^X	<	0	IS	^^FALSE\\ IF THE CURRENT VALUE
OF ^X IS POSITIVE OR ZERO, OTHERWISE IT IS ^^TRUE\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.F;.J
^IF THE VALUES OF TWO ARITHMETIC EXPRESSIONS ARE COMPARED AND
THEY ARE OF DIFFERENT TYPES, THEN THE VALUE LOWER DOWN IN THE
HIERARCHY IS CONVERTED TO THE TYPE OF THE HIGHER BEFORE COMPARISON IS MADE.
.B 1
^CHARACTER VALUES MAY BE COMPARED WITH RESPECT TO THE COLLATING SEQUENCE. ^A RELATION
.index ^^CHARACTER values, comparison\\
.B 1;.I 5
^X##^^REL##Y\\
.B 1
WHERE ^X AND ^Y ARE CHARACTER VALUES, AND ^^REL\\ IS A RELATIONAL
OPERATOR HAS THE SAME TRUTH VALUE AS
.B 1;.I 5
^^RANK(X)##REL RANK(Y)\\
.index ^^RANK\\
.B 1
^EXAMPLE:
.B 1;.TS 5,19,35
	'+' < '='	IS ^^TRUE\\	^^RANK('+') = 43
.index ^^RANK\\
.BR
			RANK('=') = 61\\
.index ^^RANK\\
.B 1;.LM 0
.IF FOA;.NUMBER 185;.PS 80,80;.PAGE;
.ENDIF FOA
^TWO TEXT VALUES ARE EQUAL IF THEY ARE BOTH EMPTY OR IF THEY
ARE BOTH INSTANCES OF THE SAME CHARACTER SEQUENCE. ^OTHERWISE
THEY ARE UNEQUAL, AND THEN A TEXT VALUE ^T RANKS LOWER THAN A TEXT VALUE
.index ^^RANK\\
^U IF ONE OF THE FOLLOWING CONDITIONS
IS FULFILLED:
.B 1;.LM 4;.I -4
1)##^T IS EMPTY
.I -4
2)##^U IS EQUAL TO ^T FOLLOWED BY ONE OR MORE CHARACTERS
.I -4
3)##^IF THE FIRST I-1 CHARACTERS OF ^T AND ^U ARE THE SAME, AND
THE ITH CHARACTER OF ^T RANKS LOWER THAN THE ITH CHARACTER OF ^U.
.B 1;.LM 0
^EXAMPLES:
.B 1;.LM 10;.TS 31
^^NOTEXT = ""	TRUE
.BR
"0"  <  "9"	TRUE
.BR
"ABCDE"="ABCDEF"	FALSE
.BR
"+12" NE "=12"	TRUE
.BR
"ABC"  =  "ABCD"	FALSE\\
.SUBTITLE ^^CHAPTER\\ 2.6.5
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.NF;.NJ
.IF FOA;.NUMBER 186;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.5##^^CHARACTER EXPRESSIONS\\
.B 1
^^CHARACTER\\-EXPRESSION
.B 1;.LM 5
SIMPLE-CHARACTER-EXPRESSION
.index ^^CHARACTER expression\\
.index ^^Simple character expression\\
.index ^^CHARACTER expression\\
^^IF\\-CLAUSE SIMPLE-CHARACTER-EXPRESSION
.index ^^IF clause, with character expression\\
.index ^^IF clause\\
.index ^^IF clause\\
###^^ELSE\\ CHARACTER-EXPRESSION
.index ^^ELSE, with character expression\\
.B 1;.I -5
SIMPLE-CHARACTER-EXPRESSION
.index ^^CHARACTER expression\\
.B 1
^^CHARACTER\\-CONSTANT
.index ^^CHARACTER constant\\
^^CHARACTER\\-VARIABLE
.index ^^CHARACTER variable\\
^^CHARACTER-\\FUNCTION-DESIGNATOR
.index ^^CHARACTER function designator\\
(^^CHARACTER\\-EXPRESSION)
.index ^^CHARACTER expression\\
.B 1;.I -5
^^CHARACTER\\-CONSTANT
.B 1
'(ANY CHARACTER FROM THE DATA CHARACTER SET)'
.B 2;.I -5
^EXAMPLE:
.B 1
'''
'^A'
^^IF X < 0 THEN ' ' ELSE 'Y'\\
.B 1;.LM 0;.F;.J
^THE SET OF INTERNAL CHARACTERS IS ORDERED ACCORDING TO THE COLLATING
SEQUENCE (^APPENDIX ^A). ^THE COLLATING SEQUENCE DEFINES A ONE-ONE
MAPPING BETWEEN INTERNAL CHARACTERS AND INTEGERS EXPRESSED BY THE
.index ^^CHARACTER expression\\
FUNCTION PROCEDURES:
.B 1;.I 5
^^INTEGER PROCEDURE RANK (C); CHARACTER C;\\
.index ^^Type conversion(CHARACTER to INTEGER)\\
.index ^^RANK\\
.index ^^CHARACTER to INTEGER conversion\\
.index ^^PROCEDURE RANK\\
.index ^^CHARACTER expression\\
.index ^^RANK\\
.B 1
WHOSE VALUE IS IN THE RANGE 0 THROUGH 127 AND
.B 1;.I 5
^^CHARACTER PROCEDURE CHAR (N); INTEGER N;\\
.index ^^Type conversion(INTEGER to CHARACTER)\\
.index ^^INTEGER-CHARACTER conversion\\
.index ^^Conversion from INTEGER to CHARACTER\\
.index ^^PROCEDURE CHAR\\
.B 1
.IF FOA;.NUMBER 187;.PS 80,80;.PAGE;
.ENDIF FOA
^THE PARAMETER VALUE MUST BE IN THE RANGE 0 THROUGH 127 OTHERWISE
A RUN TIME ERROR RESULTS.
.B 1
^TWO CHARACTER SUBSETS ARE DEFINED BY THE STANDARD PROCEDURES
.B 1;.I 5
^^BOOLEAN PROCEDURE DIGIT (C); CHARACTER C;\\
.index ^^PROCEDURE DIGIT\\
.B 1
WHICH IS ^^TRUE\\ ONLY IF ^C IS A DIGIT, AND
.B 1;.I 5
^^BOOLEAN PROCEDURE LETTER (C); CHARACTER C;\\
.index ^^PROCEDURE LETTER\\
.B 1
WHICH IS ^^TRUE\\ ONLY IF ^C IS AN UPPER OR LOWER CASE LETTER.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^EXAMPLE:
.B 1
^THE FOLLOWING PROGRAM SCANS AN INPUT FILE ON ^^SYSIN\\ UNTIL
"END OF FILE" IS MET AND RECORDS THE NUMBER OF OCCURRENCES OF
THE DIGITS 0 - 9.
.B 1;.LM 12;.TS 12;.NF;.NJ;.I -7
^^BEGIN	INTEGER ARRAY INCIDENCES [RANK('0') : RANK('9')];
.index ^^RANK\\
CHARACTER C; INTEGER R;
WHILE NOT LASTITEM DO
BEGIN  C := INCHAR;
.I 7
IF DIGIT (C) THEN
.I 10
BEGIN  R := RANK(C);
.index ^^RANK\\
.I 17
INCIDENCES[R] := INCIDENCES[R] + 1;
.I 10
END;
END;
_...
.I -7
END\\
.SUBTITLE ^^CHAPTER\\ 2.6.6
.index ^^Designational expression\\
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 188;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.6##^^DESIGNATIONAL EXPRESSIONS\\
.B 1
^A DESIGNATIONAL EXPRESSION IS A RULE FOR OBTAINING THE LABEL OF A STATEMENT.
.B 2
DESIGNATIONAL-EXPRESSION
.index ^^Right parenthesis ())\\
.index ^^Left parenthesis (()\\
.B 1;.I 5
SIMPLE-DESIGNATIONAL-EXPRESSION
.index ^^Simple designational expression\\
.I 5
^I^F-CLAUSE SIMPLE-DESIGNATIONAL-EXPRESSION
.I 9
^^ELSE\\ DESIGNATIONAL-EXPRESSION
.B 2
SIMPLE-DESIGNATIONAL-EXPRESSION
.B 1;.I 5
^^LABEL\\-IDENTIFIER
.index ^^Label identifier\\
.I 5
^^SWITCH\\-IDENTIFIER [SUBSCRIPT]
.index ^^SWITCH identifier\\
.index ^^Subscript of SWITCH\\
.I 5
(DESIGNATIONAL-EXPRESSION)
.PG;.B 2
^EXAMPLES:
.B 1;.TS 9
VALID	^^LAB
.BR
	CHOOSE [I]
.BR
	SELECT [IF X < 0 THEN 2 ELSE 3]
.BR
	IF B < 0 THEN LAB__1 ELSE SLAB[1]\\
.B 1;.TS 9,30
INVALID	^^X.LAB\\	REMOTE ^^SWITCH-\\ OR ^^LABEL-\\
.BR
		IDENTIFIERS ARE NOT ALLOWED
.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 189;.PS 80,80;.PAGE;
.ENDIF FOA
^THE PRINCIPLE OF EVALUATION IS ANALOGOUS TO THAT OF ARITHMETIC-EXPRESSIONS.
^IN THE GENERAL CASE, THE CONDITIONS IN THE ^I^F-CLAUSES WILL
SELECT A SIMPLE-DESIGNATIONAL-EXPRESSION. ^IF THIS IS A LABEL
THE DESIRED RESULT IS FOUND. ^A SWITCH DESIGNATOR, ON THE OTHER
HAND, REFERS TO THE CORRESPONDING SWITCH DECLARATION AND BY USE
OF THE ACTUAL NUMERICAL VALUE OF ITS SUBSCRIPT (AN ARITHMETIC-EXPRESSION)
SELECTS ONE OF THE DESIGNATIONAL-EXPRESSIONS LISTED IN THE SWITCH
DECLARATION BY COUNTING FROM LEFT TO RIGHT. ^SINCE THIS VALUE
ITSELF MAY BE A SWITCH DESIGNATOR, THE DEFINITION IS RECURSIVE.
.B 1
^THE EVALUATION OF THE SUBSCRIPT IS ANALOGOUS TO THAT OF SUBSCRIPTED VARIABLES.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.SUBTITLE ^^CHAPTER\\ 2.6.7
.LM 0;.RM 70;.F;.J;.SP 1;.PS 58,70;.LC
.IF FOA;.NUMBER 190;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.7##^^OBJECT EXPRESSIONS\\
.index ^^Object expression, syntax and semantics of\\
.index ^^Object expression\\
.B 1
^AN OBJECT-EXPRESSION IS A RULE FOR COMPUTING A REFERENCE TO
AN OBJECT OR ^^NONE.\\ ^THE TYPE OF THE EXPRESSION IS ^^REF\\
.index ^^Reference variable, use of in expression\\
.index ^^Pointer variable, use of in expression\\
.index ^^Object expression\\
.index ^^Object in expression\\
.index ^^Object\\
.index ^^NONE in object expression\\
.index ^^NONE\\
(QUALIFICATION).
.index ^^Qualification in object expression\\
.B 2
OBJECT-EXPRESSION
.index ^^Object expression\\
.B 1;.I 5
SIMPLE-OBJECT-EXPRESSION
.I 5
^I^F-CLAUSE SIMPLE-OBJECT-EXPRESSION
.I 9
^^ELSE\\ OBJECT-EXPRESSION
.index ^^ELSE in object expression\\
.index ^^Object expression\\
.B 2
SIMPLE-OBJECT-EXPRESSION
.B 1;.LM 10;.NF;.NJ
^^NONE\\
VARIABLE
.index ^^Variable\\
FUNCTION-DESIGNATOR
.index ^^Function designator\\
^^NEW CLASS\\-IDENTIFIER[ACTUAL-PARAMETER-PART]
.index ^^Object generator\\
.index ^^NEW, syntax\\
.index ^^CLASS identifier in NEW statement\\
.index ^^Actual parameter part in expression\\
.index ^^Actual parameter part\\
^^THIS CLASS\\-IDENTIFIER
.index ^^THIS\\
SIMPLE-OBJECT-EXPRESSION ^^QUA CLASS\\-IDENTIFIER
.index ^^QUA, syntax\\
(OBJECT-EXPRESSION)
.B 2;.I -10
^EXAMPLES:
.B 1
^^X
X.Y
SIDE (3)
THIS HEAD.SUC
NEW INFILE("CARDS")
THIS LINK QUA SUBCLASS.ATTRIB
.index ^^QUA, example of use\\
IF SUC IN LINK THEN SUC ELSE NONE
IF X =/= NONE
###THEN (IF X.F =/= NONE THEN X.F.F ELSE NONE)
###ELSE NONE\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 191;.PS 80,80;.PAGE;
.ENDIF FOA
^QUALIFICATION
.B 1
^THE QUALIFICATION OF AN OBJECT-EXPRESSION IS DEFINED BY THE FOLLOWING RULES:
.index ^^Object expression\\
.B 1;.LM 4;.I -4
1)##^THE EXPRESSION ^^NONE\\ IS QUALIFIED BY A FICTITIOUS CLASS
WHICH IS INNER TO ALL DECLARED CLASSES.
.B 1;.I -4
2)##^A VARIABLE, ARRAY OR FUNCTION DESIGNATOR IS QUALIFIED AS
STATED IN THE DECLARATION (OR SPECIFICATION, SEE BELOW) OF THE
VARIABLE OR ARRAY OR PROCEDURE IN QUESTION.
.B 1;.I -4
3)##^AN OBJECT-GENERATOR, LOCAL-OBJECT OR QUALIFIED-OBJECT IS
QUALIFIED BY THE CLASS OF THE IDENTIFIER FOLLOWING THE SYMBOL
^^NEW, THIS\\ OR ^^QUA\\ RESPECTIVELY.
.index ^^QUA, qualification of result\\
.B 1;.I -4
4)##^A CONDITIONAL OBJECT-EXPRESSION IS QUALIFIED BY THE CLASS
.index ^^Object expression\\
AT THE INNERMOST PREFIX LEVEL WHICH INCLUDES THE QUALIFICATION
OF BOTH ALTERNATIVES. ^IF THERE IS NO SUCH CLASS, THE EXPRESSION IS ILLEGAL.
.B 1
^IN
.B 1;.I 5
^^IF B THEN NONE ELSE S\\
.index ^^IF clause in object expression\\
.B 1
THE QUALIFICATION IS THAT OF ^S (BY RULE 1).
.B 1;.I -4
5)##^A FORMAL PARAMETER OF OBJECT-REFERENCE TYPE IS QUALIFIED
ACCORDING TO ITS SPECIFICATION REGARDLESS OF THE QUALIFICATION
OF THE CORRESPONDING ACTUAL PARAMETER.
.B 1;.I -4
6)##^THE QUALIFICATION OF A FUNCTION-DESIGNATOR WHOSE PROCEDURE
IDENTIFIER IS THAT OF A VIRTUAL QUANTITY, DEPENDS ON THE ACCESS LEVEL.
^THE QUALIFICATION IS THAT OF THE MATCHING DECLARATION, IF ANY,
OCCURRING AT THE HIGHEST PREFIX LEVEL EQUAL TO OR LESS THAN THE ACCESS LEVEL, OR IF NONE,
THAT OF THE VIRTUAL SPECIFICATION.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.F;.J;.TS 24
.IF FOA;.NUMBER 192;.PS 80,80;.PAGE;
.ENDIF FOA
^OBJECT GENERATORS	(^^NEW A....)\\
.index ^^CLASS object generation\\
.index ^^NEW operator, semantics\\
.index ^^Generation of new class objects\\
.index ^^Allocate of structure instances\\
.index ^^Creation of a new object\\
.B 1
^AN OBJECT-GENERATOR INVOKES THE GENERATION AND EXECUTION OF
AN OBJECT BELONGING TO THE IDENTIFIED CLASS. ^THE OBJECT IS
A NEW INSTANCE OF THE CORRESPONDING (CONCATENATED) CLASS BODY.
.index ^^CLASS body, generation of\\
^THE EVALUATION OF AN OBJECT GENERATOR CONSISTS OF THE FOLLOWING ACTIONS.
.B 1;.LM 4;.I -4
1)##^THE OBJECT IS GENERATED AND THE ACTUAL PARAMETERS OF THE
.index ^^Generated object\\
OBJECT GENERATOR ARE EVALUATED. ^THE PARAMETER VALUES AND/OR
REFERENCES ARE TRANSMITTED. (^FOR PARAMETER TRANSMISSION MODES,
SEE SECTION 5.4).
.B 1;.I -4
2)##^CONTROL ENTERS THE BODY OF THE OBJECT THROUGH ITS INITIAL
^^BEGIN\\ WHEREBY IT BECOMES OPERATING IN THE "ATTACHED" STATE.
.B 1
^THE EVALUATION OF THE OBJECT GENERATOR IS COMPLETED:
.B 1
^CASE A:##^WHENEVER THE BASIC PROCEDURE "DETACH" IS EXECUTED
.index ^^DETACH (outside CLASS SIMULATION)\\
"ON BEHALF OF" THE GENERATED OBJECT (SEE ^^CHAPTER 3,\\ SECTION 1) OR
.B 1
^CASE B:##UPON EXIT THROUGH THE FINAL END OF THE OBJECT.
.B 1;.LM 0
^THE VALUE OF AN OBJECT-GENERATOR IS THE OBJECT GENERATED AS THE
RESULT OF ITS EVALUATION. ^THE STATE OF THE OBJECT AFTER THE EVALUATION
IS EITHER "DETACHED" (CASE A) OR "TERMINATED" (CASE B).
.index ^^Terminated\\
.index ^^Detached state\\
.B 1;
.IF FOA;.NUMBER 231;.PS 80,80;.PAGE;
.ENDIF FOA
.index ^^Removal of CLASS objects\\
.index ^^Destroy of CLASS objects\\
.index ^^FREE of storage\\
.index ^^Dynamic memory allocation\\
.index ^^Deletion of CLASS objects\\
.index ^^Garbage collector\\
.index ^^Shared storage\\
.index ^^Equivalence = shared storage, use garbage collector\\
.index ^^Redefines = shared storage, use garbage collector\\
.index ^^Storage reorganisation\\
.index ^^Heap memory\\
^^In the SIMULA language, no command is available to explicitly remove
or destroy a class instance. This is instead done by
a so-called garbage collector, which automatically will remove
those class instances which are not accessible from a program.
.B 1
Example I: If the only way to access a certain class object
is the reference variable A, then changing the value of A
will cause removal of the object (e.g. "A:- NONE").
.B 1
Example II: If the only way to access a certain class object
is through its membership in a set, then the set operator
"out" will make it inaccessible and thus remove it.
If the only way for the program to reach members of a
set or other data structure is through one reference,
e.g. a reference to the head of the set, then assigning
a new value to this reference will remove the entire set.
\\
.B 2
.IF FOA;.NUMBER 193;.PS 80,80;.PAGE;
.ENDIF FOA
^QUALIFICATION IN CONNECTION WITH REFERENCE-ASSIGNMENT
.B 1
^CONSIDER THE OBJECT-REFERENCE-ASSIGNMENT
.B 1;.I 10
^V:- OBJECT-EXPRESSION
.B 1
^BOTH THE LEFT PART AND THE RIGHT PART HAVE A QUALIFICATION. ^LET THESE BE
^QL  AND ^QR  RESPECTIVELY#-#NOTE THAT ^^NONE\\ IS HERE CONSIDERED
AS HAVING A UNIVERSAL QUALIFICATION WHICH IS INNER TO EVERY
OTHER QUALIFICATION. ^THE SITUATIONS THAT CAN ARISE ARE ILLUSTRATED IN THE CONTEXT:
.B 1;.TS 7,29
	^^REF(CHAIN)C;	CLASS CHAIN.............;
.BR
	REF(MEMBER)M;	CLASS MEMBER............;
.BR
	REF(POINT)P:	MEMBER CLASS POINT......;
.BR
	REF(LINE)L;	MEMBER CLASS LINE.......;
.IFNOT FOA;.p 0,2,30
.ENDIF FOA;.LM 9;.I -9
^CASE 1:##Q\\L  IS EQUAL OR OUTER TO ^QR^^
.BR
E.G.

.B 1;.TS 14,21
	^^A)	M:-NEW MEMBER;
.BR
	B)	M:-NEW POINT......;
.BR
	C)	M:-P;
.BR
	D)	M:-NONE;\\
.B 1
^THE ASSIGNMENT IS LEGAL. ^IN ^B), THE ATTRIBUTES OF THE REFERENCED
^^POINT-\\OBJECT MAY BE ACCESSED BY USE OF ^^QUA\\ AS IN
.index ^^QUA, semantics\\
.index ^^Access into a CLASS object\\
.B 1;.I 12
^^M QUA POINT.X\\
.index ^^QUA, semantics\\
.B 1
OR BY USE OF ^^INSPECT\\ AS IN
.B 1;.I 12
^^INSPECT M QUA POINT DO ... X ...
.index ^^QUA, semantics\\
.B 1;.I 12
INSPECT M WHEN POINT DO ... X ...\\
.B 1
^NOTE THE DIFFERENCE - IN THE FIRST LINE A QUALIFICATION ERROR
WILL OCCUR IF ^M DENOTES A ^^LINE\\ OR IS ^^NONE\\, IN THE
SECOND LINE NOTHING WILL HAPPEN. ^SEE SECTION 2.7.2 ^CONNECTION
STATEMENTS.
.B 1;.I -9
.IF FOA;.NUMBER 194;.PS 80,80;.PAGE;
.ENDIF FOA
^CASE 2:##^QL  IS INNER TO ^QR
.BR
E.G.
.B 1;.TS 14,20
	^^A)	P:-NEW MEMBER;
.BR
	B)	P:-M;\\
.B 1;.LM 9
^THE ASSIGNMENT MAY BE LEGAL. ^A) IS CLEARLY NOT, BUT ^B) IS
LEGAL IF ^M IS CURRENTLY REFERENCING A ^^POINT\\ OBJECT OR AN OBJECT
OF A CLASS INNER TO ^^POINT,\\ E.G. AFTER
.B 1;.I 5
^^M:-NEW POINT...;\\
.B 1
^THIS MUST BE CHECKED AT RUNTIME.
.B 1;.LM 0;.F;.J
^IN CASES 1 AND 2, THE QUALIFICATIONS ^QL  AND ^QR  ARE SAID TO BE
COMPATIBLE. ^NOTICE THAT COMPATIBILITY IS DECIDED AT COMPILE TIME.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 9;.I -9
^CASE 3:##^QL  AND ^QR  ARE NOT COMPATIBLE.
.BR
E.G.
.B 1;.TS 14,20
	^^A)	P:-NEW LINE.....;
.BR
	B)	P:-NEW CHAIN;
.BR
	C)	M:-C;\\
.B 1
^THE ASSIGNMENT IS ILLEGAL.
.LM 0
.B 1
.LM 0;.RM 70;.F;.J;.PS 58,70;.SP 1;.LC
.IF FOA;.NUMBER 195;.PS 80,80;.PAGE;
.ENDIF FOA
^SIMILAR RULES APPLY TO THE OBJECT-REFERENCE ASSIGNMENTS
IMPLICIT IN THE PASSING OF PARAMETERS (^^FP:-#AP\\) AND
ASSIGNMENTS TO THE RESULT VARIABLE IN A FUNCTION PROCEDURE BODY.
.B 1
^MULTIPLE ASSIGNMENTS TAKE THE FORM
.B 1;.I 5
V1:-#V2:-#...#:-#VN:-#OBJECT-EXPRESSION
.B 1
AND ARE EQUIVALENT TO
.B 1;.I 5
VN:-#OBJECT-EXPRESSION
.BR;.I 5
VN-1:-#VN;
.BR;.I 5
_...
.BR;.I 5
V1:-#V2;
.B 1
^THE CONSIDERATIONS ABOVE APPLY AT EACH STEP.
.B 1
^THE FACT THAT AN OBJECT-REFERENCE-ASSIGNMENT IS ALWAYS
CHECKED FOR LEGALITY (MAINLY AT COMPILE TIME) HAS THE
FOLLOWING IMPLICATION.  ^FOR ANY OBJECT-REFERENCE-VARIABLE
OR INDEED, OBJECT-EXPRESSION WHOSE VALUE IS ^V AND WITH
QUALIFICATION ^QV, THE FOLLOWING IS ALWAYS TRUE UNDER PROGRAM EXECUTION:
.B 1;.I 5
(^^V#==#NONE)#OR#(V#IN#Q\\V)
.index ^^Reference equal (==)\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 196;.PS 80,80;.PAGE;
.ENDIF FOA
^LOCAL#OBJECTS
.BR
-------------
.B 1
^A LOCAL-OBJECT "^^THIS C"\\ IS A MEANINGFUL EXPRESSION WITHIN
.index ^^THIS\\
.index ^^Local object\\
.B 1;.LM 4;.I -4
1)##THE CLASS BODY OF ^C OR THAT OF ANY SUBCLASS OF ^C, OR
.B 1;.I -4
2)##A CONNECTION BLOCK WHOSE QUALIFICATION IS ^C OR A SUBCLASS OF ^C.
.index ^^Connection block\\
.B 1;.LM 0
^THE VALUE OF A LOCAL-OBJECT IN A GIVEN CONTEXT IS THE OBJECT
WHICH IS, OR IS CONNECTED BY, THE SMALLEST TEXTUALLY ENCLOSING
BLOCK INSTANCE, IN WHICH THE LOCAL OBJECT IS A MEANINGFUL EXPRESSION.
.index ^^Local object\\
^IF THERE IS NO SUCH BLOCK, THE LOCAL OBJECT IS ILLEGAL.
.index ^^Local object\\
^FOR AN INSTANCE OF A ^^PROCEDURE\\- OR ^^CLASS\\-BODY, "TEXTUALLY ENCLOSING"
MEANS CONTAINING ITS DECLARATION.
.B 3
.IF FOA;.NUMBER 197;.PS 80,80;.PAGE;
.ENDIF FOA
^INSTANTANEOUS#QUALIFICATION
.index ^^Instantaneous qualification\\
.BR
---------------------------
.B 1
^LET ^X REPRESENT ANY SIMPLE REFERENCE EXPRESSION, AND LET ^C AND
^D BE CLASS IDENTIFIERS SUCH THAT ^D IS THE QUALIFICATION OF ^X.
^THE QUALIFIED OBJECT "^^X#QUA#C\\" IS THEN A LEGAL OBJECT EXPRESSION,
PROVIDED THAT ^C INCLUDES ^D OR IS A SUBCLASS OF ^D.  ^OTHERWISE,
I.E., IF ^C AND ^D BELONG TO DISJOINT PREFIX SEQUENCES, THE QUALIFIED OBJECT IS ILLEGAL.
.B 1
^THE EVALUATION OF ^^X#QUA#C\\ AT RUN TIME GIVES AN ERROR IF THE
VALUE OF ^X IS ^^NONE\\, OR AN OBJECT BELONGING TO A CLASS NOT INCLUDED IN ^C.
^OTHERWISE THE VALUE OF ^^X#QUA#C\\ IS THAT OF ^X.
(^NOTE THE QUALIFICATION OF ^X IS ^D, WHILST THAT OF ^^X#QUA#C\\ IS ^C).
.SUBTITLE ^^CHAPTER\\ 2.6.8
.B 3
.IF FOA;.NUMBER 198;.PS 80,80;.PAGE;
.ENDIF FOA
2.6.8##^^TEXT EXPRESSIONS AND TEXT VALUES\\
.index ^^TEXT expression, syntax and semantics of\\
.index ^^TEXT expression\\
.B 1
^A ^^TEXT\\-EXPRESSION IS A RULE FOR COMPUTING A REFERENCE TO A
^^TEXT\\ OBJECT.  ^A ^^TEXT\\-VALUE IS A RULE FOR COMPUTING THE VALUE
OF A TEXT (I.E., STRING OF CHARACTERS).
.B 3
^^TEXT\\-EXPRESSION
.BR
---------------
.B 1;.LM 7;.NF;.NJ
 **                                                     **
 * SIMPLE-TEXT-EXPRESSION                                *
.index ^^Simple TEXT expression\\
.index ^^Simple TEXT expression\\
**                                                       **
 * ^^IF\\-CLAUSE SIMPLE-TEXT-EXPRESSION ^^ELSE TEXT\\-EXPRESSION *
.index ^^IF clause\\
.index ^^TEXT expression\\
.index ^^IF clause\\
 **                                                     **

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
SIMPLE-TEXT-EXPRESSION
.BR
----------------------
.B 1;.LM 7
****************************
* ^^NOTEXT                   *
.index ^^NOTEXT in TEXT expression\\
* TEXT\\-VARIABLE            *
.index ^^TEXT variable\\
* ^^TEXT\\-FUNCTION-DESIGNATOR *
.index ^^TEXT function designator\\
* (^^TEXT\\-EXPRESSION)        *
.index ^^TEXT expression\\
****************************
.B 3;.LM 0
^^TEXT\\-VALUE
.index ^^TEXT value\\
.index ^^TEXT expression and TEXT value\\
.BR
----------
.B 1;.LM 7
**************************
* SIMPLE-TEXT-EXPRESSION *
* TEXT-CONSTANT          *
.index ^^TEXT constant in TEXT expression\\
**************************
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 199;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLES:
.BR
--------
.B 2
VALID
.BR
-----
.B 1;.LM 18;.TS 18;.I -18
^^TEXT\\-EXPRESSION	^^NOTEXT\\
.index ^^TEXT expression\\
.BR
^^IF T.LENGTH < 5 THEN NOTEXT ELSE BLANKS(80)
.index ^^IF clause in text expression\\
.BR
(RUNE.T)
.BR
T.SUB(1,12)\\
.B 1;.I -18
^^TEXT\\-VALUE	"^^ANOTHER CONSTANT"
.index ^^TEXT constant in TEXT expression\\
.BR
NOTEXT\\
.BR
""###(SAME AS ^^NOTEXT\\)
.B 2;.I -18
INVALID
.BR;.I -18
-------
.B 1
^^IF T.LENGTH < 5 THEN "MAX FOUR"
.BR
################ELSE "MIN FIVE"\\
.B 1
^^TEXT\\-CONSTANTS MAY NOT BE CONSTITUENTS OF CONDITIONAL EXPRESSIONS.


.SUBTITLE ^^CHAPTER\\ 2.7
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 200;.PS 80,80;.PAGE;
.ENDIF FOA
2.7##^^BLOCKS AND STATEMENTS\\
.BR
#####---------------------
.B 1
^A PROGRAM IS STRUCTURED INTO BLOCKS.  ^A BLOCK CONSISTS OF A
BLOCK HEAD WHICH DEFINES PROPERTIES OF THE BLOCK, AND A COMPOUND
.index ^^Program\\
.index ^^Blocks and statements\\
.index ^^Block head\\
.index ^^Block\\
TAIL WHICH DEFINES THE ACTIONS OF THE BLOCK.  ^A BLOCK
.index ^^Compound tail\\
MAY BE PREFIXED WHICH MEANS THAT THE BLOCK IS BUILT INTO A
PREDEFINED ENVIRONMENT.
.B 1
^THERE IS NO WAY FOR A BLOCK ENVIRONMENT TO INTERACT WITH AN
INNER BLOCK (I.E., EXAMINE ITS CURRENT STATE).  ^THE ENVIRONMENT
CAN ONLY OBSERVE THE RESULT OF ITS ACTIONS.  ^A BLOCK MAY ONLY
BE ENTERED THROUGH ITS INITIAL ^^BEGIN\\ AND ATTEMPTS TO DO SO BY
^^GOTO\\ STATEMENTS ARE THUS ILLEGAL.
.SUBTITLE ^^CHAPTER\\ 2.7.1
.B 3
.IF FOA;.NUMBER 201;.PS 80,80;.PAGE;
.ENDIF FOA
2.7.1##^^BLOCKS AND COMPOUND STATEMENTS\\
.B 1
PROGRAM
.index ^^Program = block or compound statement\\
.index ^^Blocks and compound statements\\
.index ^^Block\\
.index ^^Block\\
.BR
-------
.B 1;.LM 7;.NF;.NJ
BLOCK ! COMPOUNT-STATEMENT
.index ^^Compound statement\\
.B 3;.LM 0
BLOCK
-----
.B 1;.LM 7
PREFIXED-BLOCK ! MAIN-BLOCK
.B 3;.LM 0
PREFIXED-BLOCK
.index ^^Prefixed block\\
--------------
.B 1;.LM 0;.F;.J
.LM 5;.NOFILL
.indent -4
######################**#######################**##MAIN-BLOCK
^^CLASS\\-IDENTIFIER#**#[ACTUAL-PARAMETER-LIST] **
.indent -4
######################**#######################****COMPOUND-STATEMENT
.index ^^Main block = part of block after prefix\\
.index ^^CLASS identifier as block prefix\\
.index ^^Statement, compound or block\\
.FILL;.B 3;.LM 0
MAIN-BLOCK
.BR
----------
.B 1;.I 5
^^BEGIN\\#[DECLARATION;]...[STATEMENT;]...#[STATEMENT]^^END\\
.index ^^END of a block\\
.index ^^Declaration as part of a block\\
.index ^^BEGIN as start of a block\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
COMPOUND-STATEMENT
.BR
------------------
.B 1;.I 5
^^BEGIN\\#[STATEMENT;]...[STATEMENT]^^END\\
.index ^^END of a compound statement\\
.index ^^END\\
.index ^^BEGIN as start of a compound statement\\
.B 1;.LM 0
^A BLOCK AUTOMATICALLY INTRODUCES A NEW LEVEL OF NOMENCLATURE.
^ANY IDENTIFIER MAY BE DECLARED OR APPEAR AS A LABEL IN THE
BLOCK AND IS THEN SAID TO BE LOCAL TO IT.  ^AN ENTITY REPRESENTED
.index ^^Local quantity in a block\\
INSIDE A BLOCK HAS NO EXISTENCE OUTSIDE IT AND ANY ENTITY
REPRESENTED BY THIS IDENTIFIER OUTSIDE THE BLOCK CANNOT
BE DIRECTLY ACCESSED BY USE OF IT (SEE THE EXPLANATION OF THE
BINDING RULE IN SECTION 2.3).
.B 1
.IF FOA;.NUMBER 202;.PS 80,80;.PAGE;
.ENDIF FOA
^WHEN A BLOCK IS PREFIXED, THE IDENTIFIERS DECLARED IN THE
CORRESPONDING ^^CLASS\\ ARE MADE AVAILABLE.  ^NEVERTHELESS, AN
IDENTIFIER IN THE ^^CLASS\\ MAY BE REDEFINED IN THE MAIN-BLOCK OR
COMPOUND-STATEMENT.
.B 1
^THE EXECUTION OF A BLOCK IS AS FOLLOWS:
.B 1
.LM 9;.I -9
STEP#1:##IF THE BLOCK IS PREFIXED THEN THE ACTUAL PARAMETERS
(IF ANY) ARE EVALUATED.
.B 1;.I -4
2:##IF THE DECLARATIONS OF THE BLOCK CONTAIN ARRAY BOUNDS
THEN THESE ARE EVALUATED.  (^THEY MAY MAKE REFERENCE TO PARAMETERS
OF THE PREFIX).
.B 1;.I -4
3:##^EXECUTION OF THE STATEMENTS BODY BEGINS WITH THE FIRST
STATEMENT OF THE PREFIX, IF ANY, OTHERWISE WITH THE
FIRST STATEMENT OF THE MAIN BLOCK.  ^AFTER EXECUTION
OF THE BLOCK BODY (UNLESS IT IS A ^^GOTO\\ STATEMENT)
A BLOCK EXIT OCCURS AND THE STATEMENT TEXTUALLY
FOLLOWING THE ENTIRE BLOCK IS EXECUTED.
.B 1;.LM 0
^A ^^CLASS\\ IDENTIFIER POSSIBLY FOLLOWED BY AN ACTUAL PARAMETER
LIST CAN PREFIX A MAIN-BLOCK OR COMPOUND-STATEMENT.  ^THIS RESULTS
IN CONCATENATING THE OBJECT OF THE STATED CLASS WITH
THAT MAIN-BLOCK OR COMPOUND-STATEMENT, WHICH MEANS THAT THE CAPABILITIES
OF THE STATED CLASS AND ITS INCLUDING CLASSES ARE AVAILABLE
WITHIN THAT MAIN-BLOCK OR COMPOUND STATEMENT.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^WHEN AN INSTANCE OF A PREFIXED BLOCK IS GENERATED, THE FORMAL
PARAMETERS OF THE CLASS ARE INITIALISED AS INDICATED BY THE
ACTUAL PARAMETERS OF THE BLOCK PREFIX.  ^A VIRTUAL QUANTITY IS
IDENTIFIED BY THE QUANTITY DEFINED BY A MATCHING DECLARATION IN
THE BLOCK HEAD OF THE MAIN-BLOCK OR COMPOUND-STATEMENT, OR BY
THE MATCHING DEFINITION AT THE INNERMOST PREFIX LEVEL OF THE
PREFIX SEQUENCE.  ^THE OPERATION RULE OF THE CONCATENATED OBJECT
.index ^^Prefix sequence\\
IS DEFINED BY PRINCIPLES SIMILAR TO THOSE GIVEN IN SECTION 5.5.
.B 1
.IF FOA;.NUMBER 203;.PS 80,80;.PAGE;
.ENDIF FOA
^A PREFIXED-BLOCK PLAYS A PARTICULAR ROLE IN THE QUASI-PARALLEL
.index ^^Quasi-parallel system, definition by a prefixed block\\
SEQUENCING OF ^^SIMULA\\:  IT DEFINES A QUASI-PARALLEL SYSTEM, A
SYSTEM WHOSE COMPONENTS HAVE INTERACTIONS INDEPENDENT FROM THE
PROGRAM OUTSIDE THE PREFIXED BLOCK, SEE ^^CHAPTER 3.\\
.B 1
^THE FOLLOWING RESTRICTIONS MUST BE OBSERVED WHEN PREFIXING BLOCKS:
.B 1
^AN OBJECT IN WHICH REFERENCE IS MADE TO THE OBJECT ITSELF
THROUGH USE OF ^^THIS\\ IS AN ILLEGAL BLOCK PREFIX.
.index ^^THIS, illegality for prefixed blocks\\
.B 1
^THE ^^CLASS\\-IDENTIFIER OF A PREFIX MUST REFER TO A CLASS LOCAL
TO THE SMALLEST BLOCK ENCLOSING THE PREFIXED BLOCK.  ^IF THAT
^^CLASS\\-IDENTIFIER IS THAT OF A SYSTEM CLASS, IT REFERS TO A
FICTITIOUS DECLARATION OF THAT SYSTEM CLASS OCCURRING IN THE
BLOCK HEAD OF THE SMALLEST ENCLOSING BLOCK.
.B 1
^A COMPOUND-STATEMENT IS A MEANS OF GROUPING SEVERAL STATEMENTS
TOGETHER TO ACT AS ONE UNIT, AS IN
.B 1
.LM 5
^^FOR#I#:=#1#STEP#1#UNTIL#10#DO
.BR
####BEGIN##SUM#:=#SUM#+#A[I];
.BR
###########SUMSQ#:=#SUMSQ#+#A[I]_^2;
.BR
####END\\
.B 1;.LM 0
WHERE THE CONTROLLED-STATEMENT IS A COMPOUND-STATEMENT,
.B 1
OR OF LEGALISING A STATEMENT STRUCTURE
.B 1;.LM 5
^^IF#X#>#0#THEN#BEGIN##IF#Y#>#0#THEN#QUADRANT#:=#1;
.BR
##############END\\
.B 1;.LM 0
^THE STRUCTURE IS ILLEGAL WITHOUT THE ^^BEGIN#-#END\\ PAIR.
.SUBTITLE ^^CHAPTER\\ 2.7.2
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 204;.PS 80,80;.PAGE;
.ENDIF FOA
2.7.2##^^STATEMENTS\\
.B 1
^A STATEMENT IS A UNIT OF ACTION IN A PROGRAM.  ^SEQUENCES OF
STATEMENTS MAY BE GROUPED TOGETHER TO FORM COMPOUND STATEMENTS OR BLOCKS.
.index ^^Statement\\
.index ^^Compound statement\\
.index ^^Block\\
.B 1
^SPECIAL NOTICE MUST BE TAKEN OF CONDITIONAL STATEMENTS WHICH
.index ^^Conditional statement, IF-THEN-ELSE ambiguity\\
EFFECTIVELY PREVENT A CERTAIN AMBIGUITY FROM ARISING.  ^FOR CONSIDER
.B 1;.LM 5
^^IF#\\CONDITION1#^^THEN#IF#\\CONDITION2#^^THEN#S2#ELSE#S3\\
.index ^^IF statement, ambiguity with\\
.B 1;.LM 0
WHICH HAS TWO INTERPRETATIONS
.B 1;.LM 4;.I -4
1)##^^IF\\#CONDITION1#^^THEN#IF\\#CONDITION2#^^THEN#S2#ELSE#S3\\
.BR
###################-----------------------------
.B 1;.I -4
2)##^^IF#\\CONDITION1#^^THEN#IF\\#CONDITION2#^^THEN#S2#ELSE#S3\\
.BR
###################---------------------
.B 2;.LM 0
^THIS AMBIGUITY IS RESOLVED BY NOT ALLOWING A CONDITIONAL STATEMENT
TO FOLLOW THE ^^THEN\\ SYMBOL.  ^NOW THE TWO MEANINGS ARE RESOLVED BY WRITING.
.index ^^THEN, ambiguity after\\
.B 1
.LM 4;.I -4
1)##^^IF\\#CONDITION1#^^THEN\\
.index ^^THEN\\
.BR
###^^BEGIN##IF#\\CONDITION2#^^THEN#S2#ELSE#S3##END\\
.B 1;.I -4
2)##^^IF\\#CONDITION1#^^THEN#BEGIN##IF\\#CONDITION2#^^THEN#S2##END\\
.BR
##############^^ELSE#S3\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0
.IF FOA;.NUMBER 205;.PS 80,80;.PAGE;
.ENDIF FOA
^THE SAME SORT OF AMBIGUITY CAN ARISE WITH A ^^WHILE\\-STATEMENT,
.index ^^WHILE, ambiguity with\\
A ^^FOR\\-STATEMENT, OR A CONNECTION STATEMENT FOLLOWING A ^^THEN\\.
.index ^^FOR statement, ambiguity with\\
.index ^^DO statement in PL/I\\
.B 1;.LM 5
^^IF\\#CONDITION1#^^THEN\\
.BR
####^^WHILE#J#<#10#DO\\
.BR
#######^^IF#\\CONDITION2#^^THEN#S1#ELSE#S2\\
.B 1
^^IF#\\CONDITION3#^^THEN\\
.BR
###^^INSPECT#X#DO
.index ^^INSPECT\\
.index ^^Connection statement\\
.BR
###IF\\#CONDITION4#^^THEN#S3#ELSE#S4\\
.B 1;.LM 0
^HERE THE SYNTAX FORCES THE ^^ELSE\\-BRANCH TO BELONG TO THE NEAREST
^^THEN\\, BUT MEANS THAT WHEREAS WE CAN WRITE:
.B 1;.LM 5;.TS 23;.NJ;.NF
	#**                    **
	#* ^^WHILE\\-STATEMENT      *
^^IF\\ CONDITION^^ THEN	** FOR\\-STATEMENT        **
	#* CONNECTION-STATEMENT *
	#**                    **
.B 2;.I -5
WE CAN NOT WRITE
.B 1
	#**                    **
	#* ^^WHILE\\-STATEMENT      *
^^IF\\ CONDITION^^ THEN	** FOR\\-STATEMENT        ** ^^ELSE S\\
	#* CONNECTION STATEMENT *
	#**                    **
.B 1;.LM 0;.F;.J
^IN THIS CASE, ^^BEGIN#-#END\\ ARE NECESSARY ROUND THE ^^WHILE-, FOR-,\\
OR CONNECTION-STATEMENT.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 206;.PS 80,80;.PAGE;
.ENDIF FOA
^^OPEN AND CLOSED STATEMENTS\\
.index ^^Open statement\\
.index ^^Closed statements\\
.BR
--------------------------
.B 2
STATEMENT
.BR
---------
.B 1;.LM 7;.NJ;.NF
**            **
*              *
* OPEN         *
.I -1
** CLOSED       **
* ^^IF\\-STATEMENT *
*              *
**            **
.B 2;.LM 0
OPEN
----
.B 1;.LM 0
            **                    **
            *                      *
            * ^^FOR\\-STATEMENT        *
[LABEL:].. ** ^^WHILE\\-STATEMENT      **
.index ^^Label\\
.index ^^Colon (:) after label\\
            * CONNECTION-STATEMENT *
            *                      *
            **                    **
.B 2
.LM 0
CLOSED
------
.B 1
            **                    **
            *                      *
            * BLOCK                *
            * COMPOUND-STATEMENT   *
            * ACTIVATION-STATEMENT *
.index ^^Statements, table of allowed kinds of\\
            * ^^PROCEDURE\\-STATEMENT  *
.index ^^Activation statement (in table of statement kinds)\\
[LABEL:].. ** DUMMY-STATEMENT      **
.index ^^Label\\
.index ^^Dummy statement\\
            * ^^GOTO\\-STATEMENT       *
            * ASSIGNMENT-STATEMENT *
.index ^^Assignment\\
            * OBJECT-GENERATOR     *
            *                      *
            **                    **
.B 2
LABEL
.index ^^Label\\
-----
.B 1
.I 10
^^LABEL\\-IDENTIFIER

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 207;.PS 80,80;.PAGE;
.ENDIF FOA
^^ASSIGNMENTS\\
.index ^^Assignment\\
.BR
-----------
.B 1
^ASSIGNMENT-STATEMENTS ASSIGN THE VALUE OF AN EXPRESSION TO
.index ^^Expression in assignment statement\\
.index ^^TEXT value assignment\\
ONE OR SEVERAL VARIABLES OR PROCEDURE IDENTIFIERS.  ^ASSIGNMENT
TO A PROCEDURE IDENTIFIER MAY OCCUR ONLY WITHIN THE BODY OF
THE FUNCTION PROCEDURE DEFINING THE VALUE OF THAT FUNCTION.
^THE PROCESS OF ASSIGNMENT TAKES PLACE IN THREE STEPS:
.B 1;.LM 4;.I -4
1)##ANY SUBSCRIPT EXPRESSIONS IN THE LEFT VARIABLES ARE EVALUATED
IN SEQUENCE FROM LEFT TO RIGHT
.B 1;.I -4
2)##THE EXPRESSION IS EVALUATED
.B 1;.I -4
3)##THE VALUE OF THE EXPRESSION IS ASSIGNED TO THE LEFT PART
VARIABLES FROM RIGHT TO LEFT (SEE EXAMPLE BELOW UNDER ^TYPES).
.B 2;.LM 0
ASSIGNMENT-STATE
.BR
----------------
.B 1;.LM 5;.NJ;.NF
 **                     **
 *                       *
 * VALUE-ASSIGNMENT      *
** ^^TEXT\\-VALUE-ASSIGNMENT **
 * REFERENCE-ASSIGNMENT  *
.index ^^Reference assignment\\
 *                       *
 **                     **
.B 2;.LM 0
VALUE-ASSIGNMENT
----------------
.B 1
.UC;.LM 5
**                        **
*                          *
* variable :=              * ... VALUE-expression
* PROCEDURE-identifier :=  *
*                          *
**                        **
.LC;.B 2;.LM 0;.F;.J
^EXAMPLES:
.BR
---------
.B 1;.LM 10
^X#:=#3.45;
.BR
^C#:=#^D[^I]#:=#'+';
.BR
^P.^X#:=#^R.^X#+#^S.^X;
.B 1
^Y#:=#^^IF#X#>#0#THEN#X#ELSE#-X;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 208;.PS 80,80;.PAGE;
.ENDIF FOA
^^TEXT\\-VALUE-ASSIGNMENT
.BR
---------------------

.B 2;.NJ;.NF;.LM 7
**                      **
*                        *
.IF FOA;.NUMBER 210;.PS 80,80;.PAGE;
.ENDIF FOA
* VARIABLE:=             *
* ^^PROCEDURE\\-IDENTIFIER:= *
.I -1
** FUNCTION-DESIGNATOR:=  **   ...^^TEXT\\-VALUE
.index ^^TEXT function designator\\
* ^^(IF\\-EXPRESSION):=      *
*                        *
**                      **
.B 1;.LM 0
^EXAMPLES:
---------
.B 1;.LM 10
^^T:="MESSAGE";
T.SUB(1,5):=S:="12345";
(IF BOL THEN T1 ELSE T2):=#"EOF";\\
.B 1
^CONSIDER THE ^^TEXT\\-VALUE-ASSIGNMENT
.B 1;.I 5
^^R#:=#T;\\
.B 1
LET THE LENGTH OF ^R BE ^LR AND THE LENGTH OF ^T BE ^LT.  ^THE
ASSIGNMENT IS LEGAL IF ^LR >= ^LT, OTHERWISE A RUN TIME ERROR
RESULTS.
.B 1;.LM 0;.TS 12
^LR#=#^LT	^THE TEXT VALUE OF ^T IS COPIED INTO ^R
.B 1;.LM 12;.TS 12;.I -12
^LR#>#^LT	^THE TEXT VALUE OF ^T IS COPIED INTO ^R LEFT JUSTIFIED
AND THE REMAINING ^LR-^LT POSITIONS ARE FILLED WITH BLANKS
.B 1;.LM 0
^ASSIGNMENTS TO OVERLAPPING TEXTS ARE UNPREDICTABLE.
.B 1
E.G., WITH
.B 1;.LM 10;.TS 10
^^T.SUB(10,10)#:=#T.SUB(15,10);\\
.BR;.I -5
OR	^^T.SUB(15,10)#:=#T.SUB(10,10);\\
.B 1;.LM 0
^THE VALUE ASSIGNMENT
.index ^^Value assignment\\
.B 1;.I 10
^^T#:=#NOTEXT;\\
.B 1;.LM 0
IS AN EFFICIENT WAY OF SETTING THE VALUE OF ^T TO BLANKS.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 210;.PS 80,80;.PAGE;
.ENDIF FOA
REFERENCE-ASSIGNMENT
.br
.index ^^Reference assignment\\
--------------------
.B 1;.LM 7
.NJ;.NF
**                      **
*                        *
* VARIABLE:-             *
.I -1
** ^^PROCEDURE\\-IDENTIFIER:- **   ...REFERENCE-EXPRESSION
*                        *
**                      **
.B 2;.LM 0
^EXAMPLES:
---------
.B 1;.LM 10
^^T:-S:-U;
T:-BLANKS(10);
T:-NOTEXT;
T:-T.STRIP;
.B 1
X:-Y:-Z;
X:-NEW CL;
X:-NONE;
X:-MEMBER.SUC;
.B 2;.C
^^NOTE\\
.B 1;.F;.J;.LM 15;.RM 55
^IN CASE OF TYPE ^^REF\\ THE RUNTIME QUALIFICATION OF THE
RIGHTHANDSIDE OF THE ASSIGNMENT MUST BE IDENTICAL WITH
.index ^^Reference assignment\\
OR A SUBCLASS TO THE QUALIFICATION OF THE LEFTHANDSIDE
(SEE SECTION 2.6.7).
.skip
^^The qualification CLASS on both sides of the assignment
statement must be declared in the same instance of the
.index Qualification error
.index Transplantation
same block (e.g_. CLASS body or PROCEDURE body).
.LC;.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.RM 70
.IF FOA;.NUMBER 212;.PS 80,80;.PAGE;
.ENDIF FOA
^TYPES
.BR
-----
.B 1
^THE TYPE OF THE EXPRESSION AND ALL THE LEFT PART VARIABLES
OR ^^PROCEDURE-\\IDENTIFIERS MUST BE IDENTICAL EXCEPT IN THE CASE
OF ARITHMETIC ASSIGNMENTS.  ^IN THIS CASE, THE ASSIGNMENT
.index ^^Arithmetic expression in assignment statement\\
.B 1;.I 10
V1#:=#V2#:=#......#VN#:=#EXPRESSION
.B 1
IS EQUIVALENT TO
.B 1;.LM 10
VN#:=#EXPRESSION
.BR
VN-1#:=#VN
.BR
##.....
.BR
V1#:=#V2
.B 1;.LM 0
^SO THAT IF ^X IS ^^REAL\\ AND ^^I INTEGER,\\
.B 1;.LM 10
^^X#:=#I#:=#3.57;\\
.B 1
.LM 0
IS EQUIVALENT TO
.B 1;.LM 10
^^I#:=#4;
.BR
X#:=#4.0;\\
.B 1;.LM 0
AND
.B 1;.I 10
^^I#:=#X#:=#3.57;\\
.B 1
IS EQUIVALENT TO
.B 1;.LM 10
^^X#:=#3.57;
.BR
I#:=#4;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0
.IF FOA;.NUMBER 209;.PS 80,80;.PAGE;
.ENDIF FOA
^^GOTO-STATEMENTS
.index ^^Jump statement\\
.index ^^GO TO statement\\
.index ^^GO TO\\
.BR
---------------
.B 1
^^A GOTO\\ STATEMENT INTERRUPTS THE NORMAL SEQUENCE OF OPERATIONS.
^THE VALUE OF A DESIGNATIONAL EXPRESSION INDICATES THE VALUE OF
.index ^^Designational expression\\
THE LABEL OF THE NEXT STATEMENT TO BE EXECUTED.
.index ^^Label\\
.B 3
^^GOTO\\-STATEMENT
.BR
--------------
.B 1;.I 10
^^GOTO \\DESIGNATIONAL-EXPRESSION
.B 2;.LM 0
^EXAMPLES:
.BR
---------
.B 1;.LM 10
^^GOTO L
.BR
GOTO S[4]
.BR
GOTO S[IF N=0 THEN 2 ELSE 6]
.BR
GOTO IF N=0 THEN L1 ELSE L2\\
.B 1;.LM 0
^A ^^GOTO\\ STATEMENT MAY NOT LEAD INTO
.B 1;.LM 5
A CONNECTION STATEMENT
.BR
A BLOCK WHICH IS NOT ALREADY ACTIVE
.BR
A ^^FOR\\-STATEMENT
.B 1;.LM 0
^^A GOTO\\ STATEMENT LEAVING AN ATTACHED OBJECT LEAVES THE OBJECT
IN THE TERMINATED STATE.
.B 1
^WHEN THE VALUE OF A DESIGNATIONAL EXPRESSION IS A SWITCH WITH
AN UNDEFINED VALUE (THE INDEX IS OUT OF RANGE), THE ^^GOTO\\ STATEMENT
IS EQUIVALENT TO THE DUMMY STATEMENT
.index ^^Dummy statement\\
.B 1
E.G.,
.B 1;.LM 10;.TS 30
^^;GOTO#S[-1];\\	IS EQUIVALENT TO
.BR
;#;
.B 1
.I -10
^THE EFFECT OF
.B 1
.LM 30;.I -20
;^^GOTO S[IP];\\	ASSUMING ^I^P IS AN ^^INTEGER PROCEDURE\\
RETURNING AN UNDEFINED VALUE IS EQUIVALENT TO
;^I^P;
.LM 10
.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0
.IF FOA;.NUMBER 213;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE:
.BR
-------
.B 1
^THE PROGRAM BELOW PRINTS OUT THE FIRST THREE VERSES OF
"^THE ^TWELVE ^DAYS OF ^CHRISTMAS".  ^THE PROGRAM LOGIC IS BUILT AROUND
A ^^SWITCH.\\
.TS 7;.B 1;.LM 7;.NJ;.NF;.I -7
^^BEGIN	SWITCH CASE := LINE1, LINE2, LINE3;
INTEGER VERSE;
TEXT ARRAY T[1:3];
T[1] :- COPY ("FIRST");
T[2] :- COPY("SECOND");
T[3] :- COPY("THIRD");
.B 2
WHILE VERSE <= 3 DO
BEGIN
.index ^^Label, local to a FOR statement\\
.B 1;.LM 15
VERSE := VERSE + 1;
OUTTEXT("ON THE"); OUTTEXT(T(VERSE));
OUTTEXT("DAY OF CHRISTMAS"); OUTIMAGE;
OUTTEXT("MY TRUE LOVE SENT TO ME"); OUTIMAGE;
GOTO CASE[VERSE];
.LM 0
.TS 14
LINE3:	#OUTTEXT("THREE FRENCH HENS");
LINE2:	#OUTTEXT("TWO TURTLE DOVES, AND");
LINE1:	#OUTTEXT("A PARTRIDGE IN A PEAR TREE");
.LM 15
EJECT(LINE + 2);
.LM 7
END OF LOOP -
NOTE THAT A FOR-LOOP WOULD HAVE MADE THE LABELS INVISIBLE;
.LM 0
END\\
.B 2;.F;.J;.LM 10;.I -10
.IF FOA;.NUMBER 214;.PS 80,80;.PAGE;
.ENDIF FOA
^^OUTPUT:
.B 1
^^ON THE FIRST DAY OF CHRISTMAS
.BR
MY TRUE LOVE SENT TO ME
.BR
A PARTRIDGE IN A PEAR TREE
.B 1
ON THE SECOND DAY OF CHRISTMAS
.BR
MY TRUE LOVE SENT TO ME
.BR
TWO TURTLE DOVES, AND
.BR
A PARTRIDGE IN A PEAR TREE
.B 1
ON THE THIRD DAY OF CHRISTMAS
.BR
MY TRUE LOVE SENT TO ME
.BR
THREE FRENCH HENS
.BR
TWO TURTLE DOVES, AND
.BR
A PARTRIDGE IN A PEAR TREE\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70
.F;.J
.IF FOA;.NUMBER 215;.PS 80,80;.PAGE;
.ENDIF FOA
^^DUMMY STATEMENTS\\
.index ^^Dummy statement\\
.B 1
^A DUMMY-STATEMENT EXECUTES NO ACTIONS.  ^IT IS A FICTIVE STATEMENT WHICH
.index ^^Dummy statement\\
SERVES SYNTACTICAL EXPLANATIONS.  ^IN THIS WAY IT IS POSSIBLE TO SET
SEVERAL SEMICOLONS AFTER EACH OTHER AND TO PLACE A LABEL BEFORE ^^END\\.
.index ^^Label before END\\
.B 3
DUMMY-STATEMENT
.index ^^Dummy statement\\
.BR
---------------
.B 2
^EXAMPLES:
.BR
---------
.B 1;.LM 10
^^IF#X#>#0#THEN#ELSE#X#:=#-X;\\   (^NOTE DUMMY ^^THEN\\-BRANCH)
.B 1
^^BEGIN###......###LAB#:#END;\\
.B 3;.LM 0
DUMMY-STATEMENT AND EXTERNAL PROCEDURES
.index ^^Dummy statement\\
.BR
---------------------------------------
.B 1
^A DUMMY-STATEMENT IS USED INSTEAD OF THE BODY FOR A SEPARATELY COMPILED
.index ^^Dummy statement\\
PROCEDURE WHICH IS ACTUALLY WRITTEN IN ANOTHER LANGUAGE THAN ^^SIMULA\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 216;.PS 80,80;.PAGE;
.ENDIF FOA
^^WHILE STATEMENTS\\
.index ^^Conditional loop\\
.index ^^Loop, conditional\\
.index ^^Repetition, conditional\\
.index ^^WHILE statement\\
.index ^^Logical condition governing loop\\
.index ^^BOOLEAN condition governing loop\\
.B 1
^THE ^^WHILE\\-STATEMENT IS USED WHEN A STATEMENT IS TO BE REPEATEDLY
EXECUTED AS LONG AS A CONDITION IS ^^TRUE\\.
.B 3
^^WHILE\\-STATEMENT
.BR
---------------
.B 1;.I 10
^^WHILE\\ CONDITION ^^DO\\ STATEMENT
.index ^^WHILE\\
.index ^^DO in WHILE statement\\
.B 2
^EXAMPLES:
.BR
---------
.B 1;.I 10
^^WHILE#NOT#LASTITEM DO\\
.BR;.LM 10
^^BEGIN##X#:=#ININT;
.BR
#######^^COUNT#:=#COUNT#+#1;\\
.BR
#######^^SUM#:=#SUM#+#X;\\
.B 1
^^END;
.B 1
X:-SET.FIRST;
.BR
WHILE#X#=/=#NONE DO
.BR
BEGIN##IF#X#IN#POINT#THEN#NOP#:=#NOP#+#1#ELSE
.BR
##########^^IF X IN LINE THEN NOL := NOL + 1 ELSE
.BR
#############ERROR("FALSE ENTRY");
.BR
#######X :- X.SUC;
.BR
END;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.F;.J;.LM 0
.IF FOA;.NUMBER 217;.PS 80,80;.PAGE;
.ENDIF FOA
^^ACTIVATION STATEMENTS\\
.index ^^Activation statements (in table of statement kinds)\\
.BR
---------------------
.B 1
^ACTIVATION STATEMENTS ARE ONLY VALID INSIDE A ^^SIMULATION\\
.index ^^CLASS SIMULATION makes activation statements valid\\
BLOCK.  ^THEY ARE FULLY DESCRIBED IN ^CHAPTER 3, SECTION 3.
.B 3
.IF FOA;.NUMBER 218;.PS 80,80;.PAGE;
.ENDIF FOA
^^FOR STATEMENTS\\
.index ^^Parallel processing of vectors\\
.index ^^Iteration statement\\
.index ^^DO statement in FORTRAN\\
.index ^^Loop statement\\
.index ^^Repetition\\
.index ^^Loop statement\\
.index ^^Repetition\\
.index ^^Iteration statement\\
.index ^^FOR statement\\
.B 1
^^FOR\\-STATEMENTS ARE CONTROL STATEMENTS WHICH CAUSE CONTROLLED-
.B
STATEMENTS
.index ^^Controlled statement\\
TO BE EXECUTED ZERO OR MORE TIMES.
.B 1
^THERE ARE THREE BASIC TYPES OF ^^FOR\\ STATEMENT ELEMENT.
.B 1;.LM 4;.I -4
1)##THE CONTROLLED-STATEMENT IS EXECUTED FOR A LIST OF VALUES (USUALLY IRREGULAR).
.B 1;.I 5
^^FOR I := 2, 13, 17 DO\\ CONTROLLED-STATEMENT
.index ^^DO in FOR statement\\
.B 1;.I -4
2)##THE CONTROLLED-STATEMENT IS EXECUTED A KNOWN NUMBER OF
TIMES
.B 1;.I 5
^^FOR I := 1 STEP 1 UNTIL 10 DO\\
.BR
.I 5
####^^X[I] := I*I;\\
.B 1;.I -4
3)##THE CONTROLLED-STATEMENT IS EXECUTED UNTIL A CONDITION IS MET
.B 1;.I 5
^^FOR X :- X.SUC WHILE X =/= NONE DO
.BR;.I 5
####X QUA A.DUMP;\\
.B 1
^TO INCREASE THE GENERALITY OF THE CONCEPT, THESE ELEMENTS
THEMSELVES ARE ALLOWED TO FORM A LIST
.B 1;.I 5
^^FOR I := 1, 2, 4 STEP 1 UNTIL 10, I*I WHILE I > 200 DO\\
.BR;.I 5
##CONTROLLED STATEMENT

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 219;.PS 80,80;.PAGE;
.ENDIF FOA
^^FOR\\-STATEMENT
.BR
-------------
.B 1;.I 5
[LABEL:]...###^^FOR\\ CONTROLLED-VARIABLE FOR-RIGHT-PART ^^DO\\
.index ^^Label in front of FOR-statement\\
.index ^^DO in FOR statement\\
.index ^^Controlled variable\\
.BR
#######################CONTROLLED STATEMENT
.B 3;.LM 0
FOR-RIGHT-PART
.BR
--------------
.B 1;.LM 7;.NJ;.NF
**                                   **
*                                     *
* := VALUE-ELEMENT [,VALUE-ELEMENT]   *
.I -1
** :- OBJECT-ELEMENT [,OBJECT-ELEMENT] **
.index ^^Object element\\
*                                     *
**                                   **
.B 1;.LM 0
VALUE-ELEMENT
-------------
.B 1;.LM 7
**                                                **
*                                                  *
* VALUE-EXPRESSION                                 *
* ARITHMETIC-EXPRESSION ^^STEP\\ ARITHMETIC-EXPRESSION *
.index ^^STEP\\
.I -1
**          ^^UNTIL\\ ARITHMETIC-EXPRESSION             **
.index ^^UNTIL\\
* VALUE-EXPRESSION ^^WHILE\\ CONDITION                 *
*                                                  *
**                                                **
.B 3;.LM 0
OBJECT-ELEMENT
--------------
.B 1;.LM 7
**                                 **
*                                   *
* OBJECT-EXPRESSION                 *
.I -1
** OBJECT-EXPRESSION ^^WHILE\\ CONDITION **
*                                   *
**                                 **
.B 2;.LM 0;.F;.J
^EACH EXECUTION OF THE CONTROLLED STATEMENT IS PRECEDED BY
AN ASSIGNMENT TO THE CONTROLLED-VARIABLE.  ^ASSIGNMENTS MAY
CHANGE THE VALUE OF THIS CONTROLLED VARIABLE DURING EXECUTION
OF THE CONTROLLED-STATEMENT.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 220;.PS 80,80;.PAGE;
.ENDIF FOA
FOR LIST ELEMENTS
.index ^^FOR list element\\
.BR
-----------------
.B 1
^THE FOR LIST ELEMENTS ARE CONSIDERED IN THE ORDER IN WHICH
THEY ARE WRITTEN.  ^WHEN ONE FOR LIST ELEMENT IS EXHAUSTED, CONTROL
PROCEEDS TO THE NEXT, UNTIL THE LAST FOR LIST ELEMENT IN
THE LIST HAS BEEN EXHAUSTED.  ^EXECUTION THEN CONTINUES AFTER
THE CONTROLLED STATEMENT.
.B 1
^THE EFFECT OF EACH TYPE OF FOR LIST ELEMENT IS DEFINED BELOW
USING THE FOLLOWING NOTATION:
.B 1;.LM 9;.I -4
^C:##CONTROLLED VARIABLE
.B 1;.I -4
^V:##VALUE EXPRESSION
.index ^^Value expression\\
.B 1;.I -4
^O:##OBJECT EXPRESSION
.index ^^Object expression\\
.B 1;.I -4
^A:##ARITHMETIC EXPRESSION
.B 1;.I -4
^B:##^BOOLEAN EXPRESSION
.B 1;.I -4
^S:##CONTROLLED STATEMENT
.B 1;.LM 0
^THE EFFECT OF THE OCCURRENCE OF EXPRESSIONS IN FOR LIST ELEMENTS
MAY BE ESTABLISHED BY TEXTUAL REPLACEMENT IN THE DEFINITIONS.
.B 1
.IF FOA;.NUMBER 221;.PS 80,80;.PAGE;
.ENDIF FOA
^ALPHA, BETA, GAMA ARE DIFFERENT IDENTIFIERS WHICH ARE NOT USED ELSEWHERE
IN THE PROGRAM. ^O IDENTIFIES A NON-LOCAL SIMPLE VARIABLE OF
.index ^^Simple variable\\
THE SAME TYPE AS ^A2.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 4;.I -4
.LS
.LE;^V
.B 1
^C := ^V;
.BR
^S;
.BR
NEXT FOR LIST ELEMENT
.B 1;.I -4
.LE;^A1 ^^STEP A2 UNTIL A3\\
.B 1
^C := ^A1;
.BR
sigma := ^A2;
.B 1
.I -4
A#:#^^IF\\  sigma*(^^C-A3) > 0 THEN GOTO\\ BETA;
.BR
^S;
.BR
.I -1
#sigma := ^A2;
.BR
^C := ^C + sigma;
.BR
^^GOTO\\ ALPHA;
.BR;.I -4
BETA : NEXT FOR LIST ELEMENT
.B 1;.I -4
.LE;^^V WHILE B\\
.B 1;.I -4
ALPHA : ^C := ^V;
.BR
^^IF NOT B THEN GOTO\\ BETA;
.BR
^S;
.BR
^^GOTO\\ ALPHA;
.BR;.I -4
^BETA : NEXT FOR LIST ELEMENT
.B 1;.I -4
.IF FOA;.NUMBER 222;.PS 80,80;.PAGE;
.ENDIF FOA
.LE;^O
.B 1
^C :- ^O;
.BR
^S;
.BR
NEXT FOR LIST ELEMENT
.B 1;.I -4
.LE;^O ^^WHILE B\\
.B 1;.I -4
ALPHA : ^C :- ^O;
.BR
^^IF NOT B THEN GOTO\\ BETA;
.BR
^S;
.BR
^^GOTO\\ ALPHA;
.BR;.I -4
BETA : NEXT FOR LIST ELEMENT
.ELS

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 223;.PS 80,80;.PAGE;
.ENDIF FOA
^THE CONTROLLED VARIABLE
.BR
-----------------------
.B 1
^THE CONTROLLED-VARIABLE IS A SIMPLE-VARIABLE WHICH IS NOT A
FORMAL-PARAMETER CALLED BY NAME, A ^^PROCEDURE\\-IDENTIFIER, A
.index ^^Call by NAME parameter in FOR statement\\
REMOTE-IDENTIFIER NOR A ^^TEXT\\-IDENTIFIER.
.B 1
^TO BE VALID, ALL FOR LIST ELEMENTS IN A FOR STATEMENT MUST
BE SEMANTICALLY AND SYNTACTICALLY VALID.
.B 1
^IN PARTICULAR EACH IMPLIED ASSIGNMENT IS SUBJECT TO THE RULES
OF SECTION 7.2.1.3.
.B 3
^THE VALUE OF THE CONTROLLED VARIABLE UPON EXIT
.index ^^Value of controlled variable on exit\\
.BR
----------------------------------------------
.B 1
^UPON EXIT FROM THE FOR STATEMENT, THE CONTROLLED VARIABLE WILL
HAVE THE VALUE GIVEN TO IT BY THE LAST (EXPLICIT OR IMPLICIT)
ASSIGNMENT OPERATION.
.B 3
^LABELS LOCAL TO THE CONTROLLED STATEMENT
.index ^^FOR statement and local labels\\
.BR
----------------------------------------
.B 1
^THE CONTROLLED STATEMENT IN A ^^FOR\\-LOOP ALWAYS ACTS AS IF IT WERE A BLOCK.
^HENCE, LABELS ON OR DEFINED WITHIN SUCH LOOPS
MAY NOT BE ACCESSED OUTSIDE THE CONTROLLED STATEMENT.
.B 1
^THUS IT IS ILLEGAL TO WRITE:
.B 1
^^GO TO LAB;
.br
^^FOR I:= 1,2,3 DO
.br
BEGIN   LAB: ... END;\\
.br 1
BUT LEGAL TO WRITE:
.br 1;.uc
GO TO START;
.br
WHILE ..... DO
.br
BEGIN
.br
.....
.br
START:
.br
....
.BR
END OF LOOP;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 224;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE STATEMENTS\\
.index ^^CALL statement of FORTRAN and PL/I\\
.index ^^Call of a subroutine\\
.index ^^Calling a procedure\\
.index ^^PROCEDURE statement\\
.BR
--------------------
.B 1
^A PROCEDURE-STATEMENT CALLS FOR THE EXECUTION OF THE ^^PROCEDURE\\-BODY.
^BEFORE EXECUTION, THE FORMAL-PARAMETERS OF THE PROCEDURE
ARE REPLACED BY THE ACTUAL-PARAMETERS.
.B 3
^^PROCEDURE\\-STATEMENT
.BR
-------------------
.B 1
[SIMPLE-OBJECT-EXPRESSION.]#^^PROCEDURE\\-IDENTIFIER#[(EXPRESSION
.index ^^Simple object expression\\
.index ^^Dot (.) preceding procedure call statement\\
.BR
.index ^^Comma (,) in procedure call statement\\
######################################[,#EXPRESSION]...)]
.B 2
^EXAMPLES:
.BR
---------
.B 1;.LM 5
^^INTO(H)
.BR
OUTTEXT("***0***")
.BR
SYSIN.INIMAGE\\
.B 1;.LM 0
^THE PROCEDURE STATEMENT MUST HAVE THE SAME NUMBER OF ACTUAL
PARAMETERS IN THE SAME ORDER AS THE FORMAL-PARAMETERS OF THE
PROCEDURE HEADING.
.B 3
^RESTRICTIONS
.BR
------------
.B 1;.LM 4;.I -4
1)##^AN ACTUAL-PARAMETER CORRESPONDING TO A FORMAL-PARAMETER
CALLED BY ^^NAME\\ WHICH IS ASSIGNED TO WITHIN THE ^^PROCEDURE-\\BODY
MUST BE A VARIABLE.
.B 1;.I -4
2)##^IF THE FORMAL-PARAMETER IS AN ^^ARRAY\\ (^^PROCEDURE)\\, THEN THE
NUMBER OF DIMENSIONS (ACTUAL-PARAMETERS) USED WITHIN THE
^^PROCEDURE\\-BODY MUST CORRESPOND TO THE NUMBER OF DIMENSIONS
(ACTUAL-PARAMETERS) OF THE ACTUAL ^^ARRAY (PROCEDURE).\\
.B 1;.I -4
3)##^ARITHMETIC TYPE PROCEDURES USED AS PARAMETERS MUST HAVE EXACT
TYPE CORRESPONDENCE. ^FOR ^^REF\\-PROCEDURES THE ACTUAL TYPE
MUST COINCIDE WITH THAT IF THE FORMAL PARAMETER.
.PG;.B 3;.LM 0
.IF FOA;.NUMBER 225;.PS 80,80;.PAGE;
.ENDIF FOA
^^CONDITIONAL STATEMENTS\\
.index ^^Logical IF statement\\
.index ^^Branch on condition\\
.index ^^Jump on condition\\
.index ^^Conditional branch\\
.BR
----------------------
.B 1
^CONDITIONAL STATEMENTS CAUSE CERTAIN STATEMENTS TO BE EXECUTED
OR SKIPPED DEPENDING ON THE CURRENT VALUES OF CERTAIN CONDITIONS.
^THEY PROVIDE AN IMPORTANT STRUCTURAL FRAMEWORK IN THE LANGUAGE.
.B 3
^^IF\\-STATEMENT
.index ^^IF statement\\
.BR
------------
.B 1;.LM 0
.NJ;.NF
              **                                      **
              *                                        *
              *             **                     **  *
              *             *                       *  *
              *             * ^^WHILE\\-STATEMENT       *  *
              *             *                       *  *
              *             * ^^FOR\\-STATEMENT         *  *
              * ^^IF\\-CLAUSE  **                       ** *
.index ^^IF clause\ \
              *             * CONNECTION-STATEMENT  *  *
              *             *                       *  *
[LABEL:]...  **             * CLOSED                *  **
              *             *                       *  *
              *             **                     **  *
              *                                        *
              * ^^IF\\-CLAUSE CLOSED                       *
              *                                        *
              *             ^^ELSE\\ STATEMENT             *
              *                                        *
              **                                      **
.B 2;.LM 0;.F;.J;.TS 5,9,12
^EXAMPLES:
.BR
---------
.B 1
	^L:	^^IF X > 0 THEN X := -X;
.B 2
		^^IF X = 0 AND Y = 0 THEN
.BR
	L:		BEGIN OUTTEXT("ORIGIN");
.BR
			######OUTIMAGE;
.BR
			END;
.B 2
.TS 12,19,40
	X :- T;
.BR
	WHILE X =/= NONE DO
.BR
	BEGIN	IF X QUA PERSON.MALE THEN MAN := MAN + 1
.BR
			ELSE WOMAN := WOMAN + 1;
.BR
		X :- X.SUC;
.BR
	END;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0
.IF FOA;.NUMBER 226;.PS 80,80;.PAGE;
.ENDIF FOA
^THE STATEMENT SEQUENCE
.B 1;.I 5
^^IF\\ CONDITION ^^THEN S1; S2\\
.B 1
IS EQUIVALENT TO
.B 1;.LM 0;.TS 30
(EVALUATE#CONDITION)#^S1;#^S2	IF THE CONDITION IS ^^TRUE\\
.BR
(EVALUATE CONDITION) ^S2	IF THE CONDITION IS ^^FALSE\\.
.B 1
^THE STATEMENT SEQUENCE
.B 1;.I 5
^^IF\\ CONDITION ^^THEN S1 ELSE S2; T\\
.B 1
IS EQUIVALENT TO
.B 1
.TS 30
(EVALUATE#CONDITION)#^S1;#^T	IF THE CONDITION IS ^^TRUE,\\ AND
.BR
(EVALUATE#CONDITION)#^S2;#^T	IF THE CONDITION IS ^^FALSE\\.
.B 1;.LM 0
^A ^^GOTO\\ STATEMENT MAY LEAD DIRECTLY INTO A CONDITIONAL STATEMENT
E.G.,
.B 1;.LM 5;.TS 10,16,22
^^IF B THEN	BEGIN	OUTTEXT("TRUE");
.BR
		L:	OUTIMAGE;
.BR
		END
.BR
	ELSE	BEGIN	OUTTEXT("FALSE");
.BR
			GOTO L;
.BR
		END\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 227;.PS 80,80;.PAGE;
.ENDIF FOA
.IF FOA;.NUMBER 228;.PS 80,80;.PAGE;
.ENDIF FOA
^^CONNECTION STATEMENTS\\
.BR
---------------------
.B 1
^CONNECTION-STATEMENTS CONSTITUTE A FORM OF REMOTE ACCESSING WHICH
.index ^^Reference variables, use of for accessing data\\
.index ^^REF variables, use of to access into CLASS objects\\
.index ^^Pointer variable, use of\\
.index ^^Access into a CLASS object\\
.index ^^Remote accessing\\
IS MAINLY USED AS A USER CONVENIENCE IF THERE ARE TO BE MANY
ACCESSES TO A PARTICULAR OBJECT.
.B 1
E.G.
.BR;.LM 5
WE MAY REPLACE
.B 1
^^SYSBIN.INIMAGE;
.BR
X#:=#SYSBIN.INREAL;
.BR
Y#:=#SYSBIN.INREAL;
.BR
C#:=#SYSBIN.INCHAR;\\
.B 1
BY
.B 1
^^INSPECT SYSBIN DO
.index ^^INSPECT\\
.index ^^Connection statement\\
.BR;.TS 12
BEGIN	INIMAGE;
.BR
	X#:=#INREAL;
.BR
	Y#:=#INREAL;
.BR
	C#:=#INCHAR;
.BR
END\\
.B 3;.LM 0
^CONNECTION STATEMENT
.BR
--------------------
.B 1;.NF;.NJ
.TS 22
	#**                                      **
	#*                                        *
	#*       STATEMENT                        *
^^INSPECT\\ OBJECT-REF ^^DO\\	** [^^WHEN CLASS\\-IDENTIFIER ^^DO\\ STATEMENT]...**
###############ERENCE	#*                [^^OTHERWISE\\ STATEMENT]   *
	#*                                        *
	#**                                      **
.index ^^WHEN\\
.index ^^INSPECT syntax and semantics\\
.index ^^DO in INSPECT statement\\
.index ^^Connection statement, syntax and semantics\\
.index ^^OTHERWISE\\
.B 2;.F;.J;.LM 0
^EXAMPLES:
.BR
---------
.B 1;.LM 5;.TS 12
^^INSPECT SYSOUT DO
.BR
BEGIN	OUTTEXT("TITLE");
.BR
	OUTIMAGE;
.BR
	EJECT(LINE+10);
.BR
END;\\
.B 1
.LM 5;.TS 15
^^INSPECT X WHEN A DO OUTTEXT("X IN A")
.index ^^CASE statement, see INSPECT\\
.BR
	WHEN B DO OUTTEXT("X IN B")
.BR
	OTHERWISE OUTTEXT("ERROR");
.B 1;.TS 17
INSPECT X DO
.BR
##INSPECT Y DO P := Q
.BR
	OTHERWISE OUTTEXT("Y==NONE");\\
.B 1;.LM 0;.F;.J
^TO AVOID AMBIGUITY, AN ^^OTHERWISE\\ REFERS BACK TO THE NEAREST ^^INSPECT\\.
.index ^^OTHERWISE\\
.B 1
^THE REMOTE ACCESSING OF OBJECTS OF CLASSES MAY BE ACCOMPLISHED
.index ^^Reference variables, use of for accessing data\\
.index ^^REF variables, use of to access into CLASS objects\\
.index ^^Pointer variable, use of\\
.index ^^Access into a CLASS object\\
.index ^^Remote accessing\\
.index ^^Binding rules, connection\\
BY THE DOT NOTATION OR BY CONNECTION.  ^IN MOST CASES THE METHODS
ARE INTERCHANGEABLE BUT IF THE OBJECT CONTAINS CLASS ATTRIBUTES (LOCAL CLASSES),
AT LEVEL ^K, THEN ATTRIBUTES AT  LEVELS ^K^K >= ^K
.index ^^INNER levels, access by connection statement\\
CAN ONLY BE ACCESSED BY CONNECTION.
.B 1
.IF FOA;.NUMBER 229;.PS 80,80;.PAGE;
.ENDIF FOA
^TO ACCESS AN ATTRIBUTE OF AN OBJECT WE HAVE TO KNOW:
.B 1;.LM 4;.I -4
1)##A REFERENCE TO THE OBJECT
.BR;.I -4
2)##THE QUALIFICATION OF THE REFERENCE
.BR;.I -4
3)##THE ATTRIBUTE IDENTIFIER.
.B 1;.LM 0
^THE TWO VARIATIONS ARE NOW EXPLAINED:
.B 1;.LM 4;.I -4
1)##A)##^^INSPECT X DO S1 OTHERWISE S2\\
.BR
B)##^^INSPECT X DO S1\\
.B 1
^IF ^X =/= ^^NONE\\ THEN THE STATEMENT ^S1 IS EXECUTED.  ^DURING
EXECUTION OF THIS STATEMENT THE REFERENCE VARIABLE OF ^X IS
.index ^^Binding rules, connection\\
EVALUATED ONCE AND STORED.  ^ACCESS IS NOW GAINED TO THE
DENOTED OBJECT AT THE QUALIFICATION LEVEL OF ^X.  ^ALL ATTRIBUTES
OF THE QUALIFYING CLASS ARE NOW AVAILABLE BY THE
OCCURRENCE OF THEIR IDENTIFIERS.
.B 1
^IF ^X == ^^NONE\\, THEN THE STATEMENT ^S1 IS SKIPPED AND THE
STATEMENT ^S2 IS EXECUTED IN CASE A), AND THE WHOLE CONNECTION
STATEMENT IS SKIPPED IN CASE B).
.B 1
^IN AN OTHERWISE BRANCH, NO CONNECTION HOLDS.
.B 1
E.G.
.B 1;.LM 19;.NJ;.NF
^^CLASS A;
BEGIN REAL X; ..... END;
.I -2
A CLASS B
BEGIN BOOLEAN Y; .. END;
REF(A)Q; REF(B)Z;\\
.B 1;.LM 9;.TS 40
^^INSPECT Q DO	INSPECT Q QUA B DO
BEGIN  X := 2;	BEGIN  X := 2;
.TS 16,40,47
	THIS B.Y := FALSE;		Y := FALSE;
	Z :- NONE;		Z :- NONE;
END		END\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 4;.F;.J;.I -4
.IF FOA;.NUMBER 230;.PS 80,80;.PAGE;
.ENDIF FOA
2)##^^INSPECT X WHEN A DO S1
.BR;.TS 14
	WHEN B DO S2
.BR
	###.....
.BR
	OTHERWISE T\\
.B 1;.LM 4
^THIS DESCRIMINATES ON CLASS MEMBERSHIP AT RUN TIME.  ^THE
^^WHEN\\ CLAUSES ARE CONSIDERED IN TURN.  ^IF ^X IS AN OBJECT
BELONGING TO A CLASS EQUAL TO OR INNER TO THE ONE IDENTIFIED
IN THE CLAUSE THEN THE ASSOCIATED STATEMENT IS EXECUTED AND
THE REST OF THE CONNECTION-STATEMENT IS SKIPPED.  ^THE
^^OTHERWISE-\\CLAUSE (IF PRESENT) IS ONLY EXECUTED IF ^^X#==#NONE\\
OR ALL PRECEDING ^^WHEN\\ CLAUSES ARE SKIPPED.
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 231;.PS 80,80;.PAGE;
.ENDIF FOA
^^OBJECT GENERATORS\\
.index ^^CLASS object generation\\
.index ^^NEW statement, semantics\\
.index ^^Generation of new class objects\\
.index ^^Allocate of structure instances\\
.index ^^Creation of a new object\\
.index ^^Object generator\\
.BR
-----------------
.B 1
^OBJECT-GENERATORS WERE DISCUSSED IN SECTION 2.6.7.  ^THEY MAY
ALSO STAND AS STATEMENTS IN THEIR OWN RIGHT, IN WHICH CASE
THEIR REFERENCE VALUE IS NOT ASSIGNED ON EXIT.  ^THIS DOES NOT
MEAN THAT THEY CANNOT BE REFERENCED AS THE FOLLOWING EXAMPLE SHOWS:
.B 1;.LM 5;.NJ;.NF
^^LINK CLASS B(H); REF (HEAD)H;
BEGIN  PTR :- THIS B;
.TS 12
	INTO(H);
END\\
.B 1;.LM 0
^AFTER EXECUTION OF THE STATEMENT
.B 1;.LM 5
^^NEW B(HD);\\
.B 1;.LM 0;.F;.J
THEN THE GENERATED OBJECT IS REFERENCED BY ^^PTR\\ AND ^^HD.LAST\\ (IF#^^HD#=/=#NONE\\).
.ST ^^CHAPTER 3\\
.IFNOT FOA;.PG
.ENDIF FOA;
.C
^^CHAPTER 3 PROGRAM STRUCTURE AND SYSTEM FEATURES\\
.BR
.C
-----------------------------------------------
.SUBTITLE ^^CHAPTER\\ 3.1
.IF FOA;.NUMBER 232;.PS 80,80;.PAGE;
.ENDIF FOA
.B 3;.LM 0;.F;.J
3.1##^^PROGRAM STRUCTURE\\
.BR
#####-----------------
.B 1
^WITHOUT THE ^^CLASS\\ CONCEPT, THE RUN TIME STRUCTURE OF A
^^SIMULA\\ PROGRAM IS ESSENTIALLY THAT OF A STACK OF BLOCKS
WITH THE LAST CREATED BLOCK "ACTIVE".  ^GIVEN THE PROGRAM
.index ^^Program structure\\
.index ^^Active\\
SKELETON
.B 1;.LM 5;.TS 12,19,26
.NJ;.NF
^^BEGIN	REAL X;
L1:	S1;
	BEGIN	BOOLEAN B;
		S2;
		BEGIN	TEXT X;
	L3;		S3;
		END;
L2:		S4;
	END;
	S5;
END\\
.B 1;.LM 0;.F;.J
(WHERE THE ^S'S DENOTE STATEMENT SEQUENCES) THEN THE STRUCTURES
AT RUN TIME ARE
.index ^^Run time structure\\
.B 1;.LM 4;.I -4
1.##DURING EXECUTION OF ^S1 OR ^S5
.B 1;.LM 5;.NJ;.NF
.TS 13,35
	-----------------
	!       !       !
	!       !       !
	-----------------
	! ^^REAL X        !	PSC \\DENOTES THE
.index ^^PSC\\
.index ^^Program sequence control\\
	-----------------
^^PSC --->! L1:  S1\\       !	CURRENT STATEMENT
^^	! <INNER BLOCK> !
	!      S5       !
	-----------------\\
.B 1;.LM 4
.F;.J
^ONLY ONE VARIABLE ^^REAL X\\ EXISTS.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 4;.I -4
.IF FOA;.NUMBER 233;.PS 80,80;.PAGE;
.ENDIF FOA
2.##DURING EXECUTION OF ^S2 (OR ^S4)
.B 5;.LM 6;.NJ;.NF
^^
	-----------------
        !       !       !<---
        !       !       !   !
        -----------------   !
        ! REAL X        !   !
        -----------------   !
        ! L1;  S1       !   !
    --->! <INNER BLOCK> !   !
    !   !      S5       !   !
    !   -----------------   !
    !                       !
    !                       !
    !   -----------------   !
    ----!--.    !    .--!---- 
        !       !       !
        -----------------
        ! BOOLEAN B     !
        -----------------
PSC --->!      S2       !
        ! <INNER BLOCK> !
        ! L2:  S4       !
        -----------------\\
.B 1;.LM 4
.F;.J
^TWO VARAIBLES ^^REAL X\\ AND ^^BOOLEAN B\\ EXIST.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 4;.I -4
3.##DURING EXECUTION OF ^S3
.B 1;.LM 6;.NJ;.NF
^^
        -----------------
        !       !    .  !<---
        !       !       !   !
        -----------------   !
        ! REAL X        !   !
        -----------------   !
        ! L1:  S1       !   !
    --->! <INNER BLOCK> !   !
    !   !      S5       !   !
    !   -----------------   !
    !                       !
    !                       !
    !                       !         STACK OF
.index ^^Stack of blocks\\
.index ^^Stack of attached blocks\\
    !   -----------------   !
    ----!--.    !    .--!----        "ATTACHED"
.index ^^Attached state\\
        !       !       !<---
        -----------------   !          BLOCKS
        ! BOOLEAN B     !   !
        -----------------   !
        !      S2       !   !
    --->! <INNER BLOCK> !   !
    !   ! L2:  S4       !   !
    !   -----------------   !
    !                       !
    !                       !
    !                       !
    !   -----------------   !
    --->!--.    !    .--!----
        !       !       !
        -----------------
        ! TEXT X        !
        -----------------
        !               !
PSC --->! L3:  S3       !
        !               !
        -----------------
\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 4;.RM 70;.F;.J
.IF FOA;.NUMBER 234;.PS 80,80;.PAGE;
.ENDIF FOA
^THREE VARIABLES EXIST: ^^REAL X, BOOLEAN B, TEXT X,\\ BUT
ONLY TWO ARE ACCESSIBLE BY ACTIONS IN THE ACTIVE BLOCK,
.index ^^Accessible\\
FOR THE ^^REAL X\\ OF THE OUTERMOST BLOCK HAS BECOME INACCESSIBLE
DUE TO AN IDENTIFIER CLASH WITH ^^TEXT X\\ OF THE
.index ^^Identifier clash\\
.index ^^Identifier\\
INNERMOST BLOCK.
.B 1
^NOTE THAT BESIDES EXITING FROM A BLOCK VIA ITS FINAL ^^END\\,
IT IS ALSO POSSIBLE TO EXIT VIA A ^^GOTO\\-STATEMENT.  ^IF THE
.index ^^GO TO statement\\
.index ^^GO TO exit\\
STATEMENT SEQUENCE ^S3 INCLUDES THE STATEMENT
.B 1;.I 10
^^GOTO L2\\
.B 1
THEN ON EXECUTION OF THAT STATEMENT, THE INNERMOST BLOCK
IS DELETED (THE VARIABLE ^^TEXT X\\ WILL NO LONGER EXIST).
.B 1
^IF THE STATEMENT SEQUENCE ^S3 INCLUDES THE STATEMENT
.B 1;.I 10
^^GOTO L1\\
.B 1
THEN BOTH THE INNER BLOCKS WILL BE DELETED WHEN THAT
STATEMENT IS  EXECUTED AND BOTH ^^BOOLEAN B\\ AND ^^TEXT X\\
WILL NO LONGER EXIST.
.B 2
.LM 0
.IF FOA;.NUMBER 235;.PS 80,80;.PAGE;
.ENDIF FOA
^THE ^^CLASS\\ CONCEPT INITIALLY GIVES THE OPPORTUNITY FOR DATA
STRUCTURES TO EXIST IN PARALLEL.  ^THE PROGRAM
.B 1;.LM 5;.NJ;.NF;.TS 12,19
^^BEGIN	CLASS A;..........;
	REF(A)U,V;
	U :- NEW A;
	BEGIN	CLASS B;..........;
		REF(B)X;
		REF(A)W;
		V :- W :- NEW A;
		X :- NEW B;
	L:	..........
	END ***INNER BLOCK*** ;
	_..........
END ***PROGRAM*** ;\\
.B 1;.LM 0;.F;.J
HAS THE REPRESENTATION BELOW AT THE LABEL ^L.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.NJ;.NF
^^
                               ------------------------------------
                               !                                  !
                               V                                  !
                 -----------------                                !
                 !       !       !<-----------------              !
OB:\\ OUTER BLOCK^^  ! OB    !       !<---             !              !
                 -----------------   !             !              !
                 ! CLASS A       !   !       ---------      ---------
                 ! REF(A) U   .--!---!------>!   ! . !  --->!   ! . !
                 ! REF(A) V   .--!---!----   ---------  ! ^ ---------
                 -----------------   !   !   !       !  ! ! !       !
                 ! <INNER BLOCK> !   !   !   !       !  ! ! !       !
                 ! ............  !   !   !   ---------  ! ! ---------
                 -----------------   !   !              ! !
                                     !   ---------------- !
                                     !                    !
                 -----------------   !                    !
IB:\\ INNER BLOCK^^  ! IB    !    .--!---_^ <-------           !
                 -----------------   >-------!------------
                 ! CLASS B       !   _^        !
                 ! REF(A) W   .--!----  ---------
                 ! REF(B) X   .--!----->!   ! . !
                 -----------------      ---------
                 ! ..........    !      !       !
                 ! L: .......    !      !       !
                 -----------------      ---------
.B 2;.LM 0;.RM 70;.F;.J
\\
.IF FOA;.NUMBER 236;.PS 80,80;.PAGE;
.ENDIF FOA
^WHEN THE INNER BLOCK IS DELETED, THE SECOND ^A OBJECT IS STILL
AVAILABLE AS IT IS REFERENCED BY ^V.  ^ON THE OTHER HAND, THE ^B
OBJECT MUST BE DELETED AS ITS DECLARATION DISAPPEARS AND THEREFORE
NO REFERENCES EXIST.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^AT THIS LEVEL, THE ACTIONS OF EACH OBJECT ARE EXECUTED UNTIL
EXHAUSTION AND THEN THE OBJECT IS LEFT AS AN ATTRIBUTE STRUCTURE
IN THE TERMINATED STATE.  ^BUT THERE IS A BROAD CLASS OF PROBLEMS
.index ^^Terminated\\
WHICH CANNOT BE MODELLED BY THIS MECHANISM, E.G., WHEN THE ACTIONS
ARE EXECUTED IN PHASES CORRESPONDING TO THE ACTUAL CONCEPT REPRESENTED
BEING ACTIVE OR PASSIVE.  ^FOR EXAMPLE, A CUSTOMER IN A
.index ^^Passive\\
SHOP GOES THROUGH THE STAGES OF QUEUING (PASSIVE) AND BUYING
(ACTIVE), PLAYERS IN A GAME OF CARDS PLAY, AND THEN ARE PASSIVE
UNTIL THEIR TURN COMES AGAIN.  ^WE COULD PICTURE A CUSTOMER OBJECT, ^C, BY:
.B 1;.LM 5;.NJ;.NF
        -----------------
        !       !       !
        !       !       !
^C------>-----------------
        ! ENTER SHOP    !
        !               !...ACTIVE
        ! ENTER QUEUE 1 !
        !               !
        !               !
        !               ! . . . PASSIVE
        !               !
        !               !
        ! SERVED        !
        !               !...ACTIVE
        ! ENTER QUEUE 2 !
        !               !
        !               !
        !               ! . . . PASSIVE
        !               !
        !               !
        ! SERVED        !
        !               !...ACTIVE
        ! ENTER QUEUE 3 !
        !               !
        !...............!
        !               !
        ! LEAVE SHOP    !
        !               !
        -----------------
.B 2;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 237;.PS 80,80;.PAGE;
.ENDIF FOA
^WHEN ^C IS PASSIVE ITS ACTIONS MAY BE MADE ACTIVE AGAIN BY A
CALL ^^RESUME(C)\\.  ^THE ACTIONS OF ^C ARE RESUMED FROM WHERE THEY
.index ^^RESUME, semantics\\
.index ^^RESUME procedure operating on class instances\\
WERE LEFT OFF LAST.  ^TO MARK OFF THIS PROGRAM POINT OBJECTS
CAN BE MADE INTO PROGRAM COMPONENTS SUPPLIED WITH A ^^LOCAL SEQUENCE\\
^^CONTROL (LSC)\\ WHICH MARKS THE CURRENT STAGE OF EXECUTION OF THEIR ACTIONS.
.index ^^LSC\\
.index ^^Local sequence control (LSC)\\
.index ^^Parallel processing without implicit time axis\\
.index ^^Quasi-parallel processing without implicit time axis\\
.index ^^Co-routine sequensing\\
.index ^^Scheduling without implicit time axis\\
.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
.index ^^Parallel processing without implicit time axis\\
.index ^^Quasi-parallel processing without implicit time axis\\
.index ^^Co-routine sequensing\\
.index ^^Scheduling without implicit time axis\\
^A VERY SIMPLE EXAMPLE IS THAT OF TWO PLAYERS PLAYING A GAME.
^THEIR ACTIONS MAY BE LOOSELY DESCRIBED BY
.B 1;.LM 10
_..........
.BR;.I -4
^L:##PLAY
.BR
^^RESUME\\(OPPONENT);
.index ^^RESUME, semantics\\
.BR
^^GOTO L\\
.B 1;.LM 0
^WHEN THE FIRST PLAYER IS GENERATED, WE DO NOT WISH TO EXECUTE
THESE ACTIONS AS THE OPPONENT IS NOT YET GENERATED.  ^SO WE
HAVE TO RETURN CONTROL TO THE MAIN BLOCK AND RETURN A REFERENCE
TO THIS PLAYER, AND THEN CREATE THE SECOND PLAYER.  ^A SECOND
SYSTEM ^^PROCEDURE DETACH\\ SERVES THIS PURPOSE.  ^ON MEETING
.index ^^DETACH (outside CLASS SIMULATION), semantics\\
.index ^^DETACH (outside CLASS SIMULATION)\\
.index ^^RETURN from a CLASS execution\\
^^DETACH\\, THE OBJECT BECOMES A SYSTEM COMPONENT WITH AN ^^LSC\\
REFERENCING THE NEXT STATEMENT, CONTROL IS RETURNED TO ITS
OBJECT GENERATOR AND WITH IT A REFERENCE TO THE OBJECT.
.B 1
.IF FOA;.NUMBER 238;.PS 80,80;.PAGE;
.ENDIF FOA
^THE OUTLINE OF A SIMPLE PROGRAM FOR A TWO MAN GAME IS:
.B 1;.LM 5;.TS 12,19;.NJ;.NF
^^BEGIN	CLASS PLAYER;
	BEGIN	REF(PLAYER) OPPONENT;
		DETACH;
	L:\\	PLAY;
		^^RESUME(OPPONENT);
		GOTO L
	END;
	REF(PLAYER)P1,P2;
	P1 :- NEW PLAYER;
	P2 :- NEW PLAYER;
	P1.OPPONENT :- P2;  P2.OPPONENT :- P1;
	RESUME(P1);
	_..........
END\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 239;.PS 80,80;.PAGE;
.ENDIF FOA
^A SNAPSHOT AT THE POINT WHERE ^^RESUME(P1)\\ HAS JUST BEEN EXECUTED IS:
.B 1;.NJ;.NF;.LM 0
^^
                           ----------------------
                         --! MB       !         !
                         ! ----------------------
                         ! ! PLAYER CLASS       !
                         ! ! P1     REF(PLAYER).!----
                         ! ! P2     REF(PLAYER).!---!---
                         ! !   ............     !   !  !
                         ! ! RESUME(P1)         !   !  !
               LSC       ->!   ............     !   !  !
                           ----------------------   !  !
                                                    !  !
                                                    !  !
                                                    !  !
                             -----------------------   !
                             !                         !    <--------
                             !                         !            !
                             !                         !            !
                             V                         V            !
           ------------------------  !--->------------------------  !
         --!-.        !       MB  !  !  --!-.        !       MB  !  !
         ! ------------------------  !  ! ------------------------  !
         ! ! OPPONENT REF(PLAYER).!---  ! ! OPPONENT REF(PLAYER).!---
         ! !     DETACH           !  LSC->!     DETACH           !
 LSC,PSC ->! L:  PLAY             !       ! L:  PLAY             !
           !     RESUME(OPPONENT) !       !     RESUME(OPPONENT) !
           !     GOTO L           !       !     GOTO L           !
           ------------------------       ------------------------\\
.B 1;.LM 0;.F;.J
^THE ^^PSC\\ COINCIDES WITH THE ^^LSC\\ OF THE CURRENTLY ACTIVE COMPONENT.
.B 1
.IF FOA;.NUMBER 240;.PS 80,80;.PAGE;
.ENDIF FOA
^AFTER ^P1 HAS PLAYED, ^P2 IS RESUMED AND THE NEW SNAPSHOT IS:
.B 2;.LM 0;.NJ;.NF
^^
                            -----------------
                         ---!---. MB !      !
                         !  -----------------
                         !  !  ..........   !
                         !  !               !
                  LSC    -->!  RESUME(P1)   !
                            !               !
                            !  ..........   !
                            -----------------
                   
                   
       -----------------------             -----------------------
    ---!------.   !    MB    !          ---!------.   !   MB     !
    !  -----------------------          !  -----------------------
    !  !     ..........      !          !  !     ..........      !
    !  ! ^L: \\PLAY             !  ^^LSC,PSC -->! ^L: PLAY             !^^
LSC -->!    RESUME(OPPONENT) !             !    RESUME(OPPONENT) !
       !    GOTO L           !             !    GOTO L           !
       -----------------------             -----------------------\\
.B 2;.LM 0;.F.J

.IFNOT FOA;.PG
.ENDIF FOA;
^NOTE THAT THERE ARE THREE COMPONENTS HERE WITH ^^LSC\\'S:  THE TWO
PLAYERS AND THE PROGRAM BLOCK.  ^THE CURRENT STATE OF THE TWO
OBJECTS IS "DETACHED" - WHEN THEY ARE PROGRAM COMPONENTS WITH
^^LSC\\'S.  ^WHEN THEIR ACTIONS ARE EXHAUSTED, THEY LOSE THEIR ^^LSC\\'S
AND BECOME "TERMINATED".  ^CONTROL RETURNS TO THE MAIN PROGRAM
BLOCK AND CONTINUES FROM ITS ^^LSC\\.  ^ONLY A "DETACHED" OBJECT MAY
BE RESUMED.
.B 1
^ONE QUESTION REMAINS:  HOW TO TRANSFER CONTROL BACK TO THE
(UNREFERENCED) MAIN PROGRAM BLOCK WITHOUT TERMINATING AN OBJECT.
^THIS IS ACHIEVED BY A FURTHER CALL ON ^^DETACH\\.
.B 1
.IF FOA;.NUMBER 241;.PS 80,80;.PAGE;
.ENDIF FOA
^IN ADDITION TO SEQUENCING ^^PROCEDURES, "DETACH"\\ AND ^^"RESUME"\\,
THERE IS THE ^^PROCEDURE CALL\\ WHICH HAS ONE REFERENCE PARAMETER
.index ^^CALL, procedure for attaching class objects\\
WHICH MUST BE A REFERENCE TO A DETACHED OBJECT.
.B 1
^THE EXECUTION OF ^^CALL(Y)\\ FROM WITHIN A BLOCK ^X, WILL "ATTACH"
THE DETACHED OBJECT ^Y TO ^X AND CONTINUE EXECUTION OF THE ACTIONS OF ^Y.
.B 1
^THE DETAILED DESCRIPTION OF PROGRAM SEQUENCING GIVEN IN THE ^^"SIMULA 67\\ ^COMMON ^BASE ^LANGUAGE"
IS NOT REPEATED HERE.  ^FURTHER ENQUIRIES ARE DIRECTED TO THAT DOCUMENT.
.B 1
^^Semaphore variables to control critical regions are normally not
.index ^^Semaphore variables\\
.index ^^Critical regions\\
necessary in SIMULA, since control is only passed between
parallel processes by explicit commands. However, it is very easy
to program semaphore variables as a CLASS semaphore.\\

.SUBTITLE ^^CHAPTER\\ 3.2
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 242;.PS 80,80;.PAGE;
.ENDIF FOA
3.2##^^THE SYSTEM CLASS SIMSET\\
.BR
#####-----------------------
.B 1
^LIST PROCESSING CONCEPTS AND LIST MANIPULATING PROCEDURES ARE
DECLARED IN THE SYSTEM CLASSES WITHIN THE ^^CLASS SIMSET.  SIMSET\\
.index ^^SIMSET\\
.index ^^List processing\\
.index ^^CLASS SIMSET\\
CAN BE USED AS A BLOCK PREFIX OR AS A PREFIX TO ANOTHER ^^CLASS\\
.index ^^Block prefix SIMSET\\
AT ONE AND ONLY ONE BLOCK LEVEL IN A PROGRAM.
.B 1
^IN ^^SIMSET\\ ARE PROVIDED THE CONCEPTS FOR MANIPULATING TWO-WAY
.index ^^Chaining of items\\
.index ^^Linked lists of items\\
LISTS CALLED "SETS".  ^BESIDES THE SET MEMBERS WHICH CARRY INFORMATION
.index ^^Set handling\\
AND ARE PREFIXED BY ^^LINK\\, A SET ALSO HAS A ^^HEAD\\ WHICH
.index ^^LINK in SIMSET\\
.index ^^HEAD in SIMSET\\
.index ^^CLASS LINK in SIMSET\\
HAS ATTRIBUTES GIVING GLOBAL INFORMATION ABOUT THE SET (E.G.,
HOW MANY MEMBERS IT HAS).
.B 1
^A SET IS ORGANISED ON THE BASIS OF REFERENCES ^^SUC\\ AND ^^PRED\\
.index ^^SUC in SIMSET\\
.index ^^PRED in SIMSET\\
WHICH ARE COMMON TO ^^LINK\\ AND ^^HEAD.\\
.B 2;.LM 0;.NJ;.NF
^^
       ------------
H ---->! . SUC    !  SET HEAD
       ! !        !
       ! ! PRED .-!-------------------
       --!---------                  !
         !                           !
     !----                           !
     V                               !
-----------     -----------     -----------
_! SUC .---!---->! SUC .---!---->! SUC     !       SET MEMBERS
.index ^^Bi-directional list\\
.index ^^Two way list\\
.index ^^Circular list\\
_!         !     !         !     !         !       PREFIXED BY
_!   PRED  !<----!-. PRED  !<----!-. PRED  !       LINK\\
.index ^^LINK in SIMSET\\
-----------     -----------     -----------
.B 2;.LM 0;.F;.J
^TO PROTECT THE USER FROM CERTAIN KINDS OF ERROR, ^^SUC\\ AND ^^PRED\\
ARE MADE ^^REF(LINK) PROCEDURES\\ AND SO MAY NOT BE ASSIGNED TO.
.B 1
^THE PART COMMON TO BOTH ^^HEAD\\ AND ^^LINK\\ IS DECLARED SEPARATELY
IN ^^CLASS LINKAGE\\ WHICH IS THEN USED AS A PREFIX TO ^^HEAD\\ AND ^^LINK\\.
.index ^^LINKAGE in SIMSET\\
.index ^^CLASS LINKAGE in SIMSET\\
.index ^^CLASS LINKAGE in SIMSET\\
.B 1
.IF FOA;.NUMBER 243;.PS 80,80;.PAGE;
.ENDIF FOA
^A SKELETON OF THE ^^CLASS SIMSET\\ IS THUS
.B 1;.LM 5;.TS 12
.NJ;.NF
^^CLASS SIMSET;
BEGIN	CLASS LINKAGE............;
.index ^^LINKAGE in SIMSET\\
	LINKAGE CLASS LINK.......;
.index ^^LINK in SIMSET\\
	LINKAGE CLASS HEAD.......;
.index ^^HEAD in SIMSET\\
.index ^^CLASS HEAD in SIMSET\\
.index ^^CLASS HEAD\\
END ***SIMSET***\\
.B 1

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^THIS HIERARCHY MAY BE PICTORIALLY REPRESENTED BY:
.B 1;.LM 24
^^
--------
_! PREV !
--------
_! SUC  !
.index ^^SUC in SIMSET\\
--------
_! PRED !
.index ^^PRED in SIMSET\\
.I -15
------------------------------------
.LM 9;.NJ;.NF
_!              LINKAGE             !
_!                                  !
_!                                  !
_!                                  !
V                                  V
.LM 4;.TS 41
------------	-----------
_! FIRST    !	! OUT     !
_! LAST     !	! INTO    !
.index ^^INTO in SIMSET\\
_! EMPTY    !	! PRECEDE !
_! CARDINAL !	! FOLLOW  !
.index ^^FOLLOW in SIMSET\\
_! CLEAR    !	-----------
------------
	    LINK
   HEAD\\
.index ^^HEAD in SIMSET\\
.B 2;.LM 0;.F;.J
IN WHICH THE PROCEDURES LOCAL TO EACH OF THE CLASSES ARE
DENOTED BY THEIR IDENTIFIERS.
.B 1
^AN OUTLINE OF THE INDIVIDUAL CLASSES IS NOW GIVEN CONTAINING
THE PROCEDURE-HEADINGS AND A PROSE DESCRIPTION OF THEIR ACTIONS.
^THROUGHOUT THE PROSE DESCRIPTIONS WHICH ARE ILLUSTRATED BY REPRESENTATIVE
CALLS, WE ASSUME THAT THE DECLARATIONS
.B 1;.LM 10
^^REF(HEAD)HD;
.BR
REF(LINK)LK;
.BR
REF(LINKAGE)LG;\\
.B 1;.LM 0
ARE VALID.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 244;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS LINKAGE\\
.index ^^LINKAGE in SIMSET\\
.BR
-------------
.B 1;.LM 10;.TS 17
.NJ;.NF
^^CLASS LINKAGE;
.index ^^LINKAGE in SIMSET\\
BEGIN	REF(LINK) PROCEDURE SUC;.....;
.index ^^SUC in SIMSET\\
	REF(LINK) PROCEDURE PRED;....;
.index ^^PRED in SIMSET\\
	REF(LINKAGE) PROCEDURE PREV;.;
.index ^^PREV in SIMSET\\
END ***OF LINKAGE*** ;\\
.B 2;.LM 0
^^REF(LINK) PROCEDURE SUC;.....;
.index ^^SUC in SIMSET\\
.B 1;.LM 20;.TS 20;.I -20
.F;.J
^^LK.SUC\\	RETURNS A REFERENCE TO THE SUCCEEDING SET MEMBER
IF ^^LK\\ IS IN A SET, AND ^^LK\\ IS NOT THE LAST MEMBER OF THE SET,
OTHERWISE IT RETURNS ^^NONE\\.
.B 1;.I -20
.IF FOA;.NUMBER 245;.PS 80,80;.PAGE;
.ENDIF FOA
^^HD.SUC\\	RETURNS A REFERENCE TO THE FIRST SET MEMBER IF THE SET
IS NOT EMPTY, OTHERWISE ^^NONE\\.
.B 2;.I -20
^^REF(LINK) PROCEDURE PRED;....;
.index ^^PRED in SIMSET\\
.B 1;.I -20
^^LK.PRED\\	RETURNS A REFERENCE TO THE PRECEDING SET MEMBER IF ^^LK\\ IS
IN A SET AND ^^LK\\ IS NOT THE FIRST MEMBER OF THE SET, OTHERWISE ^^NONE\\.
.B 1;.I -20
^^HD.PRED\\	RETURNS A REFERENCE TO THE LAST SET
MEMBER IF THE SET IS NOT EMPTY, OTHERWISE ^^NONE\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.I -20
^^REF(LINKAGE) PROCEDURE PREV;....;
.index ^^PREV in SIMSET\\
.B 1;.I -20
LK.PREV\\	RETURNS ^^NONE\\ IF ^^LK\\ IS NOT IN A SET, A
REFERENCE TO THE SET HEAD IF ^^LK\\ IS FIRST MEMBER OF A SET,
OTHERWISE IT RETURNS A REFERENCE TO ^^LK\\'S PREDECESSOR.
.B 1;.I -20
^^HD.PREV\\	RETURNS A REFERENCE TO ^^HD\\ IF ^^HD\\ IS EMPTY,
OTHERWISE A REFERENCE TO THE LAST MEMBER OF THE SET WITH HEAD ^^HD\\.
.B 1;.LM 15;.RM 55;.C
^^NOTE\\
.B 1
^BY FOLLOWING ^^PREV\\ IT IS POSSIBLE TO GIVE A REFERENCE TO THE HEAD OF A SET
IN WHICH A ^^LINK\\ OBJECT IS A MEMBER, AS SHOWN IN THE FOLLOWING PROCEDURE
(NOT LOCAL TO ^^LINKAGE\\, ^^LINK\\ OR ^^HEAD).\\
.B 1;.LM 10;.RM 70
.NJ;.NF
.TS 17
^^REF(HEAD) PROCEDURE THESETHEADOF(LK); REF(LINK)LK;
BEGIN	REF(LINKAGE)X;
	IF LK =/= NONE THEN
	BEGIN	X :- LK.PREV;
	######WHILE X IN LINK DO
.TS 17,22
		#######X :- X.PREV;
	######THESETHEADOF :- X;
	END;
END ***THESETHEADOF***\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 246;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS HEAD\\
.index ^^HEAD in SIMSET\\
.BR
----------
.B 1
.B 1;.LM 10;.TS 17
.NJ;.NF
^^LINKAGE CLASS HEAD;
BEGIN	PROCEDURE CLEAR;................;
	REF(LINK) PROCEDURE FIRST;......;
	REF(LINK) PROCEDURE LAST;.......;
	BOOLEAN PROCEDURE EMPTY;........;
	INTEGER PROCEDURE CARDINAL;.....;
END ***OF HEAD***
.B 2;.F;.J;.LM 20;.TS 20;.I -20
REF(LINK) PROCEDURE FIRST;.....;\\
.B 1;.I -20
^^HD.FIRST\\	IS EQUIVALENT TO ^^HD.SUC\\
.B 2;.I -20
^^REF(LINK) PROCEDURE LAST;.....;
.B 1;.I -20
HD.LAST\\	IS EQUIVALENT TO ^^HD.PRED\\
.B 2;.I -20
^^BOOLEAN PROCEDURE EMPTY;.....;
.B 1;.I -20
HD.EMPTY\\	RETURNS ^^TRUE\\ IF ^^HD\\ REFERENCES A SET WITH NO MEMBERS,
^^FALSE\\ IF ^^HD\\ REFERENCES A SET WITH ONE OR MORE MEMBERS.
.B 2;.I -20
^^INTEGER PROCEDURE CARDINAL;.....;
.B 1;.I -20
HD.CARDINAL\\	RETURNS HOW MANY MEMBERS THE SET ^^HD\\ CONTAINS (0 IF ^^HD\\ IS EMPTY).
.B 2;.I -20
^^PROCEDURE CLEAR;.....;
.B 1;.I -20
HD.CLEAR\\	REMOVES ALL MEMBERS FROM THE SET, MAKING IT EMPTY.
.NJ;.NF

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 247;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS LINK
----------
.B 1
.LM 10;.TS 17
LINKAGE CLASS LINK;
.index ^^LINK in SIMSET\\
BEGIN	PROCEDURE OUT;..........;
.index ^^OUT in SIMSET\\
	PROCEDURE INTO(H); REF(HEAD)H;..........;
.index ^^INTO in SIMSET\\
	PROCEDURE PRECEDE(X); REF(LINKAGE)X;....;
.index ^^PRECEDE in SIMSET\\
	PROCEDURE FOLLOW(X); REF(LINKAGE)X;.....;
.index ^^FOLLOW in SIMSET\\
END ***OF LINK***
.B 2;.LM 20;.TS 20;.F;.J;.I -20
PROCEDURE OUT;.....;
.index ^^OUT in SIMSET\\
.B 1;.I -20
LK.OUT\\	REMOVES ^^LK\\ FROM A SET AND RE-ESTABLISHES
THE ^^SUC, PRED\\ CONNECTIONS BETWEEN ITS PREVIOUSLY NEIGHBOURING
MEMBERS.  ^IF ^^LK\\ WAS NOT A SET MEMBER, NO ACTION IS TAKEN.
.B 2;.I -20
^^PROCEDURE INTO(H); REF(HEAD)H;......;
.B 1;.I -20
LK.INTO(HD)\\	^^LK.OUT\\ IS CALLED FIRST.  ^IF ^^HD == NONE\\
NO ACTION IS TAKEN.  ^IF ^^HD =/= NONE, LK\\ GOES INTO THE SET
^^HD\\ AS THE NEW LAST MEMBER.
.B 2;.I -20
^^PROCEDURE PRECEDE(X); REF(LINKAGE)X;......;
.B 1;.I -20
LK.PRECEDE(LG)\\	^^LK.OUT\\ IS CALLED FIRST.  ^IF ^^LG == NONE\\ OR IS
NOT IN A SET THEN NO ACTION IS TAKEN, OTHERWISE ^^LK\\ GOES INTO THE SAME
SET AS ^^LG\\ AS THE NEW ^^LG.PRED (LG\\ MAY REFERENCE EITHER A ^^HEAD\\ OR A ^^LINK\\ OBJECT).
.B 2;.I -20
^^PROCEDURE FOLLOW(X); REF(LINKAGE)X;......;
.B 1;.I -20
LK.FOLLOW(LG)\\	AS ^^PRECEDE\\ EXCEPT THAT ^^LK\\ BECOMES THE NEW ^^LG.SUC\\
.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 248;.PS 80,80;.PAGE;
.ENDIF FOA
^THE USE OF REFERENCE VARIABLES AND THE FACT THAT AN OBJECT
OF ANY ^^CLASS\\ INNER TO ^^CLASS LINK\\ MAY BE INSERTED IN A SET
GIVE THE FOLLOWING DESIRABLE FEATURES:
.B 1;.LM 4;.I -4
1)##ORDERED SETS CAN BE MANIPULATED BY EFFICIENT STANDARD PROCEDURES
.B 1;.I -4
2)##BOTH THE SUCCESSOR AND PREDECESSOR OF A ^^LINK\\ OBJECT ARE IMMEDIATELY ACCESSIBLE
.B 1;.I -4
3)##THE SET MEMBERS CAN BE OBJECTS OF DIFFERENT CLASSES.
.B 1;.LM 0
^NOTE THAT A ^^LINK\\ OBJECT CAN ONLY BE IN ONE SET AT A TIME.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 249;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE ON THE USE OF ^^SIMSET\\
.BR
----------------------------
.B 1
^THE EXAMPLE IS CONCERNED WITH THE DEALING OF A HAND OF CARDS,
13 CARDS EACH IN ROTATION, TO A TABLE OF FOUR PLAYERS.  ^IT SHOWS
HOW THE CONCEPTS ^^HEAD\\ AND ^^LINK\\ OF ^^SIMSET\\ MAY BE USED AS A PLATFORM
UPON WHICH TO BUILD MORE GENERAL CONCEPTS.
.B 1
^THE PATTERNS TO BE DESCRIBED ARE
.B 1;.LM 10
^^CLASS CARD
.BR
CLASS DECK
.BR
CLASS HAND\\
.B 1;.LM 0
^INITIALLY THE ^^CARD\\ OBJECTS ARE CREATED AND INSERTED INTO A ^^DECK\\
IN THE ORDER OF THEIR GENERATION (WHICH IS NON-RANDOM).  ^SKELETONS
OF THESE TWO ^^CLASSES\\ ARE
.B 1;.LM 5
^^LINK CLASS CARD(COLOUR,RANK); INTEGER COLOUR, RANK;
.BR
BEGIN..........................................#END;
.BR
HEAD CLASS DECK;
.BR
BEGIN ..... END;\\
.B 1;.LM 0
^IMMEDIATELY PRIOR TO THE DEALING, THE SITUATION MAY BE REPRESENTED BY
.B 1;.LM 22;.NJ;.NF
###^^--------
.I -20;.TS 22
CARDDECK--->	---! HEAD !-------------------
_!  --------##################!
_!  ! DECK !##################!
_!  --------##################!
_!############################!
_!############################!
_!############################!
V############################V
.LM 11;.TS 11
------------<-->------------<- ... ->------------
.I -11
CARD	!  LINK    !   !  LINK    !          !  LINK    !
------------   ------------          ------------
.I -11
OBJECTS	! COLOUR 1 !   ! COLOUR 2 !          ! COLOUR 4 !
_!  RANK  1 !   !  RANK  1 !          !  RANK 13 !
------------   ------------          ------------\\
.B 2;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 250;.PS 80,80;.PAGE;
.ENDIF FOA
^A DEAL CONSISTS OF REMOVING THE 52 CARDS IN RANDOM ORDER FROM
^^CARDDECK\\ AND INSERTING THEM INTO THE ^^HANDS\\ IN ROTATION.

.IFNOT FOA;.PG
.ENDIF FOA;
^IT IS CONVENIENT TO DESCRIBE EACH ^^HAND\\ BY
.B 1;.LM 10;.TS 17,22
^^CLASS HAND;
.BR
BEGIN	REF(HEAD) ARRAY SUIT[1:4];\\
.BR
	GENERATE FOUR HEADS REPRESENTING THE FOUR
.BR
		POSSIBLE SUITS;
.BR
^^END ***HAND\\***
.B 1;.LM 0
^AFTER GENERATION AND THE DEALING OF THE ^^CARDS,\\ A ^^HAND\\ OBJECT
CAN BE VISUALISED BY:
.B 1;.LM 10;.NJ;.NF;.TS 50
^^
-----------    --- --- --- ---
_! SUIT[1] !--->! ! ! ! ! ! ! !	4 CLUBS
_!         !    --- --- --- ---
-----------    --- --- ---
_! SUIT[2] !--->! ! ! ! ! !	3 DIAMONDS
_!         !    --- --- ---
-----------    --- ---
_! SUIT[3] !--->! ! ! !	2 HEARTS
_!         !    --- ---
-----------    --- --- --- ---
_! SUIT[4] !--->! ! ! ! ! ! ! !	4 SPADES
_!         !    --- --- --- ---
-----------\\
.B 2;.LM 0;.F;.J
^NOW THE ^^CARDS\\ MAY BE RANKED IN ORDER OF THEIR ATTRIBUTE ^^RANK\\
AND IN THE APPROPRIATE ^^SUIT\\.  ^THE ACTIONS OF THE PROGRAM ARE:
.B 1;.LM 10
.IF FOA;.NUMBER 251;.PS 80,80;.PAGE;
.ENDIF FOA
^GENERATE THE DECK;
.BR
^DEAL THE HANDS;

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^GENERATE THE DECK
.BR
-----------------
.B 1
^THESE ACTIONS MAY BE MADE LOCAL TO ^^CLASS DECK,\\ WHICH NOW HAS
THE OUTLINE
.B 1;.LM 10;.TS 17,21,25
^^HEAD CLASS DECK;
.BR
BEGIN	INTEGER I,J;
.BR
	FOR J := 1 \\THROUGH 13 ^^DO
.BR
		FOR I := 1\\ THROUGH 4 ^^DO
.BR
			NEW CARD(I,J).INTO(THIS HEAD)
.BR
END ***DECK***\\
.B 1;.LM 0;.F;.J
^ON GENERATION OF A ^^DECK\\ OBJECT, THE REPRESENTATION OF THE
^^CARDS\\ IS AUTOMATICALLY GENERATED.
.B 3
^DEAL THE HANDS
.BR
--------------
.B 1
^THIS PART CONSISTS OF RANDOMLY SELECTING THE ^NTH CARD AND
PLACING IT IN THE APPROPRIATE ^^SUIT\\ OF THE CURRENT ^^PLAYER.\\  ^LET
^J DENOTE THE INDEX OF THE CURRENT ^^PLAYER (J = 1,2,3\\ OR 4), THEN
THE ACTIONS ARE:
.B 1;.LM 10;.TS 17
^^J := 0;
.BR
FOR I := 52 STEP -1 UNTIL 1 DO
.BR
BEGIN	C\\ :- THE RANDOMLY SELECTED CARD;
.BR
	^^IF J = 4 THEN J := 1 ELSE J := J + 1;
.BR
	COMMENT ***SELECT INDEX OF CURRENT PLAYER*** ;\\
.BR
	PLACE ^C IN ^^PLAYER(J)
.BR
END;\\
.B 1;.LM 0
^THERE REMAINS THE TASKS OF WRITING THE SELECTION PROCEDURE, AND
THE PROCEDURE TO PLACE THE ^^CARD C\\ IN THE CURRENT ^^HAND\\.  ^THESE ARE
DONE BY ^^PROCEDURE SELECT\\ LOCAL TO ^^CLASS DECK\\ AND ^^PROCEDURE PLACE\\
.index ^^PROCEDURE SELECT\\
.index ^^PROCEDURE PLACE\\
LOCAL TO ^^CLASS HAND\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
.IF FOA;.NUMBER 252;.PS 80,80;.PAGE;
.ENDIF FOA
^THE FINAL PROGRAM IS:
.B 1;.LM 0;.TS 7,14,21
.NJ;.NF
^^SIMSET
BEGIN	HEAD CLASS DECK;
	BEGIN	REF(CARD) PROCEDURE SELECT(N); INTEGER N;
.index ^^PROCEDURE SELECT\\
		BEGIN	REF(CARD)X; INTEGER I;
			X :- FIRST QUA CARD;
			FOR I := 2 STEP 1 UNTIL N DO
			####X :- X.SUC;
			SELECT :- X;
		END ***SELECT*** ;
		INTEGER I,J;
		FOR I := 1 STEP 1 UNTIL 13 DO
		####FOR J := 1 STEP 1 UNTIL 4 DO
			NEW CARD(J,I).INTO(THIS HEAD);
	END ***DECK*** ;
.B 1
.LM 7
LINK CLASS CARD(COLOUR,RANK); INTEGER COLOUR, RANK;;
COMMENT ***COLOUR = 1  REPRESENTS CLUBS
.TS 27
	2  REPRESENTS DIAMONDS
	3  REPRESENTS HEARTS
	4  REPRESENTS SPADES
.TS 20
	RANK = 1  REPRESENTS ACE
.TS 26
	2-10  OBVIOUS
	11  JACK
	12  QUEEN
	13  KING*** ;\\
.B 1
.LM 0
.IF FOA;.NUMBER 253;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS HAND;
.TS 7
BEGIN	PROCEDURE PLACE(C); REF(CARD)C;
.index ^^PROCEDURE PLACE\\
	BEGIN  REF(HEAD)S; REF(CARD)X;
.TS14
	S :- SUIT[C.COLOUR];
	IF NOT S.EMPTY THEN
	BEGIN  X :- S.FIRST QUA CARD;
.TS 21
	WHILE X =/= NONE DO
	BEGIN  IF X.RANK > C.RANK THEN
.TS 31
	BEGIN  C.PRECEDE(X);
.TS 38
	GOTO L;
.TS 31
	END;
	X:- X.SUC;
.TS 21
	END;
.TS 14
	END;

.IFNOT FOA;.PG
.ENDIF FOA;
	COMMENT ***WE ENTER HERE IF S IS EMPTY OR
.TS 25
	IF C.RANK IS THE HIGHEST MET
	SO FAR*** ;
.TS 14
	C.INTO(S);
.TS 7
  L:   END ***PLACE*** ;
.B 1
	REF(HEAD) ARRAY SUIT[1:4];
	SUIT[1] :- NEW HEAD;
	SUIT[2] :- NEW HEAD;
	SUIT[3] :- NEW HEAD;
	SUIT[4] :- NEW HEAD;
END ***HAND*** ;\\
.B 1;.LM 7;.NJ;.NF
.IF FOA;.NUMBER 254;.PS 80,80;.PAGE;
.ENDIF FOA
^^REF (CARD) C;
REF (DECK) CARDDECK;
INTEGER I,J,U;
REF(HAND) ARRAY PLAYER[1:4];
U := ININT; COMMENT ***INPUT THE RANDOM STREAM BASE*** ;
CARDDECK :- NEW DECK;
COMMENT ***GENERATES THE WHOLE PACK OF 52 CARDS IN
.TS 23
	NON-RANDOM ORDER***;
FOR I := 1 STEP 1 UNTIL 4 DO
.TS 11
	PLAYER[I] :- NEW HAND;
FOR I := 52 STEP -1 UNTIL 1 DO
.TS 14
BEGIN	C :- CARDDECK.SELECT(RANDINT(1,I,U));
	IF J = 4 THEN J := 1 ELSE J := J + 1;
	PLAYER[J].PLACE(C);
END;
.LM 0
END ***PROGRAM***\\
.SUBTITLE ^^CHAPTER\\ 3.3
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 255;.PS 80,80;.PAGE;
.ENDIF FOA
3.3##^^THE SYSTEM CLASS SIMULATION\\
.BR
#####---------------------------
.B 1
^THE ^^CLASS SIMULATION\\ IS PREFIXED BY ^^SIMSET\\ AND PROVIDES, IN
ADDITION TO ^^SIMSET\\'S SET CONCEPTS, THE NOTIONS OF A TIME AXIS
.index ^^Time axis in CLASS SIMULATION\\
.index ^^Time in CLASS SIMULATION\\
.index ^^CLASS SIMSET, prefix to CLASS SIMULATION\\
AND PROCESSES (ENTITIES WHICH INTERACT OVER A PERIOD OF TIME).
.index ^^PROCESS in CLASS SIMULATION\\
.B 1
^THE TIME AXIS CONSISTS OF A SET OF EVENT NOTICES WHICH HAVE
.index ^^Event notice in CLASS SIMULATION\\
.index ^^Event in CLASS SIMULATION\\
TWO ATTRIBUTES, A REFERENCE TO THE ^^PROCESS\\ THEY REPRESENT (^^PROC\\) AND
THE TIME OF ITS NEXT SCHEDULED EVENT (^^EVTIME\\).  ^THE EVENT NOTICES ARE
RANKED ACCORDING TO THE VALUES OF THE TIME VARIABLE (^^EVTIME\\).
.index ^^Evtime in CLASS SIMULATION\\
^WE CAN PICTURE THE TIME AXIS WITH FOUR SCHEDULED EVENTS BY:
.B 2;.LM 0;.NJ;.NF;.RM 90
^^
        **************   ***************   ***************   ***************
EVENT   * EVTIME 5.0 *   * EVTIME 10.0 *   * EVTIME 11.0 *   * EVTIME 11.0 *
.index ^^Evtime in CLASS SIMULATION\\
NOTICES * PROC   .   *   * PROC   .    *   *  PROC   .   *   * PROC   .    *
        **************   ***************   ***************   ***************
                 !                !                  !                !
                 !                !                  !                !
                 V                V                  V                V
        **************   ***************   ***************   ***************
      --*-- .  *     * --*-- .  *      * --*-- .  *      * --*-- .  *      *
      ! ************** ! *************** ! *************** ! ***************
      ! *            * ! *             * ! *             * ! *             *
      ! *            * ! * L: DETACH;  * ! *             * ! *             *
      ->*            * ->*  GOTO L;    * ->*             * ->*             *
        *            *   *             *   *             *   *             *
        **************   ***************   ***************   ***************
               _^                 _^
               !                 !
               !                 !
            CURRENT            MAIN\\
.index ^^MAIN in CLASS SIMULATION\\
.index ^^CURRENT in CLASS SIMULATION\\
.B 2;.LM 0;.RM 70;.F;.J;.PS 58,70
^THE FIRST ^^PROCESS\\ REPRESENTED IN THE TIME AXIS IS ALWAYS REFERENCED
BY ^^CURRENT\\ AND THE SYSTEM TIME IS THE VALUE OF ITS SCHEDULED
.index ^^CURRENT in CLASS SIMULATION\\
NEXT EVENT (HERE 5.0).  ^AN OBJECT OF ANY CLASS PREFIXED BY ^^PROCESS\\
MAY TAKE AN ACTIVE AND PASSIVE PART IN A SIMULATION.  ^THE ORGANIZATION
IS SO FRAMED THAT THE ^^PSC\\ LIES WITHIN ^^CURRENT\\ AND ITS
.index ^^CURRENT in CLASS SIMULATION\\
.IF FOA;.NUMBER 256;.PS 80,80;.PAGE;
.ENDIF FOA
ACTIONS ARE EXECUTED.  ^WHEN THE ACTIVE PHASE IF OVER, THAT ^^PROCESS\\
MAY BE RESCHEDULED FOR A LATER ACTIVE PHASE (FOR EXAMPLE, BY
^^REACTIVATE\\ OR ^^HOLD\\) OR REMOVED FROM THE TIMING TREE (BY ^^PASSIVATE\\
.index ^^REACTIVATE in CLASS SIMULATION\\
.index ^^PASSIVATE in CLASS SIMULATION\\
.index ^^HOLD in CLASS SIMULATION\\
OR ^^WAIT).\\  ^IT IS APPARENT THAT ^^RESUME\\ IS TOO PRIMITIVE FOR THIS
.index ^^WAIT in CLASS SIMULATION\\
.index ^^RESUME in CLASS SIMULATION\\
PURPOSE SINCE RESCHEDULING OR REMOVING ^^EVENT NOTICES\\ IS INVOLVED AS
WELL AS SWITCHING THE ^^PSC\\ FROM ONE ^^PROCESS\\ OBJECT TO ANOTHER.
.index ^^PROCESS object (table of states)\\

.IFNOT FOA;.PG
.ENDIF FOA;
^HOWEVER, ^^RESUME\\ AND ^^DETACH\\ DO FORM THE BASIS FOR THE SCHEDULING
.index ^^RESUME in CLASS SIMULATION\\
.index ^^DETACH in CLASS SIMULATION\\
PROCEDURES.  ^TO PREVENT THE USER FROM DESTROYING SYSTEM SECURITY,
EVENT NOTICES MAY NOT BE EXPLICITLY REFERENCED BY THE USER - HE
MUST USE THE SYSTEM PROCEDURES FOR SCHEDULING OR RESCHEDULING.
^IN ADDITION, IT IS STRONGLY RECOMMENDED THAT EXPLICIT USE OF
^^"DETACH", "RESUME"\\ AND ^^"CALL"\\ BE AVOIDED WITHIN A ^^SIMULATION\\ BLOCK.
.index ^^RESUME in CLASS SIMULATION\\
.B 1
^THERE IS ONE SPECIAL ^^PROCESS\\ OBJECT WHICH PLAYS A KEY ROLE IN
.index ^^PROCESS object (table of states)\\
ANY ^^SIMULATION\\ - ONE REFERENCED BY ^^MAIN\\.  ^WHENEVER ^^MAIN\\ BECOMES
.index ^^MAIN in CLASS SIMULATION\\
^^CURRENT\\, IT CAUSES THE ACTIONS OF THE ^^SIMULATION\\ BLOCK ITSELF TO
.index ^^CURRENT in CLASS SIMULATION\\
BE CONTINUED.  ^THE CORRESPONDING EVENT NOTICE CAN THEN BE RESCHEDULED (TYPICALLY BY A CALL ON ^^HOLD\\) AND THEN THE ACTION SWITCHES
FROM THE ^^SIMULATION\\ BLOCK TO THE NEW ^^CURRENT\\.  ^THUS THE
^^SIMULATION\\ BLOCK IS ITSELF TREATED AS A PROGRAM COMPONENT DURING
THE ^^SIMULATION\\.
.B 1
.IF FOA;.NUMBER 257;.PS 80,80;.PAGE;
.ENDIF FOA
^THE CLASS OUTLINE IS
.B 1;.LM 5;.TS 12
.NJ;.NF
^^SIMSET CLASS SIMULATION;
.index ^^SIMSET, prefix to SIMULATION\\
.index ^^CLASS SIMULATION\\
BEGIN	LINK CLASS PROCESS.....;
.index ^^PROCESS in CLASS SIMULATION\\
.LM 12
REF(PROCESS) PROCEDURE CURRENT;.....;
.index ^^CURRENT in CLASS SIMULATION\\
REAL PROCEDURE TIME;.....;
.index ^^Time, procedure in CLASS SIMULATION\\
COMMENT ***SCHEDULING PROCEDURES*** ;
PROCEDURE HOLD;.......;
.index ^^HOLD in CLASS SIMULATION\\
PROCEDURE PASSIVATE;..;
.index ^^PASSIVATE in CLASS SIMULATION\\
PROCEDURE WAIT;.......;
.index ^^WAIT in CLASS SIMULATION\\
PROCEDURE CANCEL;.....;
.index ^^CANCEL\\
PROCEDURE ACTIVATE;...;
.index ^^Activate\\
PROCEDURE ACCUM;......;
.index ^^ACCUM\\
REF("\\THE MAIN PROGRAM")^^MAIN;
COMMENT ***HERE FOLLOW ACTIONS WHICH SET UP THE
.TS 23
	TIME AXIS AT TIME ZERO*** ;
.LM 5
END ***SIMULATION***\\
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 258;.PS 80,80;.PAGE;
.ENDIF FOA
^WE NOW GIVE A PROSE DISCUSSION OF THE ATTRIBUTES OF ^^CLASS\\
^^SIMULATION\\:

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^^CLASS PROCESS\\
.index ^^PROCESS in CLASS SIMULATION\\
.BR
-------------
.B 1
.LM 5;.NJ;.NF
^^LINK CLASS PROCESS;
.index ^^PROCESS in CLASS SIMULATION\\
.TS 12
BEGIN	BOOLEAN PROCEDURE IDLE;..........;
.index ^^Idle in CLASS SIMULATION\\
.LM 12
BOOLEAN PROCEDURE TERMINATED;....;
.index ^^Terminated in CLASS SIMULATION\\
REAL PROCEDURE EVTIME;...........;
.index ^^Evtime in CLASS SIMULATION\\
REF(PROCESS) PROCEDURE NEXTEV;...;
.index ^^Nextev in CLASS SIMULATION\\
DETACH;
INNER;
PASSIVATE;
.LM 5
END ***PROCESS***\\
.B 1;.LM 0;.F;.J
^AN OBJECT OF A CLASS INNER TO ^^CLASS PROCESS\\ IS A ^^PROCESS\\
OBJECT.  ^A ^^PROCESS\\ OBJECT HAS THE PROPERTIES OF ^^CLASS LINK\\ AND
.index ^^PROCESS object (table of states)\\
CAN BE MANIPULATED BY SEQUENCING STATEMENTS.  ^SEQUENCING STATEMENTS
ARE USED TO INSERT OR DELETE A ^^PROCESS\\ OBJECT FROM THE
.index ^^PROCESS object (table of states)\\
TIME AXIS.  ^THE STATE OF A ^^PROCESS\\ OBJECT AFTER GENERATION IS
.index ^^Event generation in CLASS SIMULATION\\
.index ^^PROCESS object (table of states)\\
"DETACHED" AND ITS ^^LSC\\ IS POSITIONED TO THE FIRST STATEMENT OF
THE USER DEFINED OPERATIONS RULE.  ^WHEN THE ACTIONS OF THE USER
DEFINED SUBCLASS ARE EXHAUSTED, THE UNFINISHED ACTIONS OF THE
^^PROCESS\\ LEVEL ARE CONTINUED (FOLLOWING THE ^^INNER\\).  ^THESE REMOVE
THE OBJECT FROM THE TIME AXIS (^^PASSIVATE)\\ AND ITS STATE BECOMES "TERMINATED".
.index ^^Terminated in CLASS SIMULATION\\
.B 1
.IF FOA;.NUMBER 259;.PS 80,80;.PAGE;
.ENDIF FOA
^IF A ^^PROCESS\\ OBJECT IS NOT REPRESENTED IN THE TIME AXIS, THEN IT
.index ^^PROCESS object (table of states)\\
IS TERMINATED OR PASSIVE (ITS ACTIONS ARE NOT YET EXHAUSTED) AND
.index ^^Terminated in CLASS SIMULATION\\
THE ^^BOOLEAN PROCEDURE IDLE\\ RETURNS ^^TRUE\\.  ^ALL ^^PROCESS\\ OBJECTS REPRESENTED
.index ^^PROCESS object (table of states)\\
IN THE TIME AXIS ARE SAID TO BE SUSPENDED EXCEPT FOR
THE FIRST (^^CURRENT)\\ WHICH IS SAID TO BE ACTIVE.
.B 1
^A CALL ON ^^EVTIME\\ FOR A SUSPENDED OR ACTIVE ^^PROCESS\\ OBJECT RETURNS
.index ^^Parallel processing with implicit time axis\\
.index ^^Quasi-parallel processing with implicit time axis\\
.index ^^Co-routine sequensing\\
.index ^^Scheduling with implicit time axis\\
.index ^^PROCESS object (table of states)\\
.index ^^Evtime in CLASS SIMULATION\\
THE SCHEDULED TIME OF ITS NEXT EVENT.  ^IF THE OBJECT IS PASSIVE
OR TERMINATED, THEN A CALL ON ^^EVTIME\\ RESULTS IN A RUN TIME ERROR.
.index ^^Terminated in CLASS SIMULATION\\
.index ^^Evtime in CLASS SIMULATION\\
.B 1;.LM 0;.NJ;.NF
-----------------------------------------------------------
_!  ^^PROCESS\\   !                                            !
_!  OBJECT    !  RESULT OF PROCEDURE CALL                  !
-----------------------------------------------------------
_!   STATE    ! ^^IDLE  ! TERMINATED ! EVTIME\\                !
.index ^^Terminated in CLASS SIMULATION\\
-----------------------------------------------------------
_! ACTIVE     ! ^^FALSE !  FALSE\\     ! TIME OF CURRENT EVENT !
_! SUSPENDED  ! ^^FALSE !  FALSE\\     ! TIME OF NEXT EVENT    !
_! PASSIVE    ! ^^TRUE  !  FALSE\\     ! RUN TIME ERROR        !
_! TERMINATED ! ^^TRUE  !  TRUE\\      ! RUN TIME ERROR        !
.index ^^Terminated in CLASS SIMULATION\\
-----------------------------------------------------------

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 20;.TS 20;.F;.J;.I -20
^^REF(PROCESS) PROCEDURE CURRENT;......;\\
.BR
RETURNS A REFERENCE TO THE CURRENTLY ACTIVE ^^PROCESS\\ OBJECT.
.index ^^PROCESS object (table of states)\\
^THERE IS ONE SPECIAL ^^PROCESS\\ OBJECT IN THE SYSTEM REFERENCED BY ^^MAIN\\.
.index ^^PROCESS object (table of states)\\
.index ^^MAIN in CLASS SIMULATION\\
^EVERY TIME ^^MAIN\\ BECOMES ^^CURRENT\\ IT CAUSES THE ACTIONS OF THE ^^SIMULATION\\
BLOCK TO BE RESUMED.
.B 2;.I -20
^^REAL PROCEDURE TIME;.....;\\
.index ^^Time, procedure in CLASS SIMULATION\\
.BR
ALWAYS RETURNS THE CURRENT VALUE OF THE SYSTEM TIME.
.B 2;.I -20
.IF FOA;.NUMBER 260;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE HOLD(T); REAL T;......;\\
.index ^^Event generation in CLASS SIMULATION\\
.index ^^HOLD in CLASS SIMULATION\\
.BR
^^HOLD(N)\\ RESCHEDULES ^^CURRENT\\ SO THAT ITS
NEXT ACTIVE PHASE WILL OCCUR AT ^^TIME + N\\.  ^IF THE VALUE OF THE
ACTUAL PARAMETER ^N IS NEGATIVE, THE CALL IS EQUIVALENT TO ^^HOLD\\(0).  ^AFTER
THE RESCHEDULING, THE ACTIONS OF ^^CURRENT\\ ARE RESUMED.
.B 1
^NOTICE THAT ^^HOLD(T)\\ CAN BE CALLED FROM THE USER DEFINED ^^SIMULATION\\ BLOCK
IN WHICH CASE ^^MAIN\\ WILL BE RESCHEDULED - I.E., THE
.index ^^MAIN in CLASS SIMULATION\\
ACTIONS OF THE PROGRAM BLOCK ARE SUSPENDED FOR ^N TIME UNITS.
.B 2;.I -20
^^PROCEDURE PASSIVATE;......;\\
.index ^^PASSIVATE in CLASS SIMULATION\\
.BR
REMOVES ^^CURRENT\\ FROM THE TIME AXIS AND RESUMES THE ACTIONS OF THE
NEW ^^CURRENT\\.  ^A RUN TIME ERROR WILL OCCUR IF THE TIME AXIS IS NOW EMPTY.
.B 2;.I -20
^^PROCEDURE WAIT(S); REF(HEAD)S;......;\\
.index ^^WAIT in CLASS SIMULATION\\
.B 1;
.LM 20
^^PROCEDURE WAIT(S); REF(HEAD)S;
.BR
BEGIN  CURRENT.INTO(S);
.BR
#######PASSIVATE
.BR
END ***WAIT***\\
.B 1;.LM 20
^^WAIT\\ INCLUDES THE CURRENTLY ACTIVE ^^PROCESS\\ OBJECT (THIS COULD BE ^^MAIN\\) INTO A
.index ^^PROCESS object (table of states)\\
REFERENCED SET, AND THEN CALLS ^^PASSIVATE\\.
.B 2;.TS 20;.I -20
.IF FOA;.NUMBER ;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE CANCEL(X); REF(PROCESS)X;......;\\
.index ^^CANCEL\\
.BR
^^CANCEL(P)\\ WHERE ^P IS A REFERENCE TO A ^^PROCESS\\ OBJECT WILL DELETE THE
.index ^^PROCESS object (table of states)\\
CORRESPONDING EVENT NOTICE IF ANY.  ^IF ^P IS CURRENTLY ACTIVE OR SUSPENDED,
IT THUS BECOMES PASSIVE.  ^IF ^P IS A REFERENCE TO A PASSIVE OR TERMINATED ^^PROCESS\\
.index ^^Terminated in CLASS SIMULATION\\
OBJECT OR ^^NONE, CANCEL(P)\\ HAS NO EFFECT.  ^THUS ^^CANCEL(CURRENT)\\ IS
EQUIVALENT TO ^^PASSIVATE\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
^^PROCEDURE ACTIVATE\\
.index ^^Activate statement, syntax and semantics\\
.BR
------------------
.B 1
^FOR USER CONVENIENCE, CALLS ON THE PROCEDURE ^^ACTIVATE\\ ARE
.index ^^Activate\\
WRITTEN IN TERMS OF THE CORRESPONDING ACTIVATION-STATEMENTS.
.B 3
ACTIVATION-STATEMENT
.BR
--------------------
.B 1
.LM 0
.NJ;.NF
#**          **                       **                      **
#* ^^ACTIVATE   *                       * [AT/DELAY\\ TIME]^^[PRIOR] *
.index ^^PRIOR in activate statement\\
.index ^^DELAY in ACTIVATE statement\\
.index ^^AT in the activate statement\\
.index ^^Activate\\
**            ** PROCESS\\-EXPRESSION1^^ ** [BEFORE/AFTER]PROCESS  **
.index ^^PROCESS expression\\
.index ^^BEFORE in the activate statement\\
.index ^^AFTER in the activate statement\\
#* REACTIVATE\\ *                       *            EXPRESSION2 *
.index ^^REACTIVATE in CLASS SIMULATION\\
#**          **                       **                      **
.B 2;.LM 0;.F;.J
^LET ^X BE THE VALUE OF ^^PROCESS\\-EXPRESSION1.  ^IF THE ACTIVATOR
^^ACTIVATE\\ IS USED, THEN THE ACTIVATION-STATEMENT WILL HAVE NO
.index ^^Activate\\
EFFECT (OTHER THAN EVALUATING ^X) UNLESS ^X IS PASSIVE.  ^IF THE
ACTIVATOR ^^REACTIVATE\\ IS USED, THEN ^X MAY BE ACTIVE, SUSPENDED,
OR PASSIVE (IN WHICH LATTER CASE, THE ACTIVATION-STATEMENT ACTS
AS AN ^^ACTIVATE\\ STATEMENT).
.index ^^Activate\\
.B 1
^THE TYPE OF SCHEDULING IS DETERMINED BY THE FORM OF THE ACTIVATION STATEMENT.
.B 3
.IF FOA;.NUMBER 262;.PS 80,80;.PAGE;
.ENDIF FOA
^DIRECT ACTIVATION
.index ^^Direct activation\\
.BR
-----------------
.B 1
.LM 10;.NJ;.NF
^^
#**            **
#* ACTIVATE X   *
** REACTIVATE X **
#*              *
#**            **\\
.B 1;.LM 0;.F;.J
^X BECOMES THE NEW ^^CURRENT\\ AND THE SYSTEM TIME IS UNCHANGED.
^THE FORMERLY ACTIVE ^^PROCESS\\ OBJECT FROM WHERE THE CALL WAS MADE
.index ^^PROCESS object (table of states)\\
BECOMES SUSPENDED.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^TIMING CLAUSE
.index ^^Timing clause in CLASS SIMULATION\\
.BR
-------------
.B 1
.NJ;.NF
^^
#**          **     **     **
#*ACTIVATE    *     *  AT   *
**            ** X **       **  T    [PRIOR] 
#* REACTIVATE *     * DELAY *
#**          **     **     **
\\
.B 1;.LM 0;.F;.J
^THE TIMING CLAUSE ^^AT\\ SPECIFIES THE SYSTEM TIME OF THE SCHEDULED
ACTIVE PHASE.  ^THE CLAUSE
.B 1;.I 5
^^DELAY T\\
.B 1
IS EQUIVALENT TO
.B 1;.I 5
^^AT \\CURRENT-SYSTEM-TIME#+#^T
.B 1
^THE CORRESPONDING ^^EVENT NOTICE\\ IS INSERTED ACCORDING TO THE
SPECIFIED TIME, NORMALLY AFTER ANY ^^EVENT NOTICE\\ WITH THE SAME
SYSTEM TIME; THE SYMBOL ^^PRIOR\\ MAY BE USED TO SPECIFY INSERTION
IN FRONT OF ANY ^^EVENT NOTICE\\ WITH THE SAME SYSTEM TIME.
.B 3
^DEFAULT ACTIONS
.index ^^Default action (AT/DELAY)\\
.index ^^Default action (AFTER/BEFORE)\\
.BR
---------------
.B 1
"^^AT T", \\WHEN ^T < THE CURRENT-SYSTEM-TIME, IS EQUIVALENT TO
"^^AT\\ CURRENT-SYSTEM-TIME".
.B 1
^^DELAY T\\ WHEN ^T < 0 IS EQUIVALENT TO ^^DELAY 0\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 263;.PS 80,80;.PAGE;
.ENDIF FOA
^RELATIVE ACTIVATION
.BR
-------------------
.B 1
.LM 5
.NJ;.NF
^^
#**          **       **      **
#* ACTIVATE   *       * BEFORE *
**            **  X  **        **   Y
#* REACTIVATE *       * AFTER  *
#**          **       **      **
\\
.B 2;.LM 0;.F;.J
^IF ^Y IS A REFERENCE TO AN ACTIVE OR SUSPENDED ^^PROCESS\\ OBJECT,
THEN THE CLAUSE ^^BEFORE Y\\ OR ^^AFTER Y\\ IS USED TO INSERT AN EVENT
NOTICE FOR ^X BEFORE OR AFTER THAT OF ^Y AND AT THE SAME SYSTEM TIME.
.B 3
^DEFAULT ACTIONS
.BR
---------------
.B 1
^IF ^Y IS NEITHER ACTIVE NOR SUSPENDED, THEN THE ACTIVATION-STATEMENT
IS EQUIVALENT TO
.B 1;.I 5
^^CANCEL(X).\\
.B 1
^IF ^X == ^Y, THEN THE ACTIVATION-STATEMENT IS EQUIVALENT TO
.B 1;.I 5
^^CANCEL(X).\\
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 264;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE ACCUM\\
.index ^^Statistics collection\\
.index ^^Output statistics collection\\
.index ^^Data collection\\
.BR
---------------
.B 1
.LM 5;.TS 12;.NJ;.NF
^^PROCEDURE ACCUM(A,B,C,D); NAME A,B,C; REAL A,B,C,D;
BEGIN	A := A + C*(TIME-B);
	B := TIME;
	C := C + D
END ***ACCUM***\\
.B 1;.LM 0;.F;.J
^^ACCUM(P,Q,R,S)\\ IS USED TO ACCUMULATE THE "SYSTEM TIME INTEGRAL"
OF THE VARIABLE ^R.  ^THE ACCUMULATION TAKES PLACE IN ^P.  ^THE
INTEGRAL IS INTERPRETED AS A STEP FUNCTION OF THE SYSTEM TIME
WITH ^Q HOLDING THE SYSTEM TIME WHEN ^P WAS LAST UPDATED.  ^THE
VALUE OF ^S IS THE CURRENT INCREMENT OF THE STEP FUNCTION.
.IFNOT FOA;.PG
.ENDIF FOA;
^BEFORE
.BR
------
.B 2;.LM 0;.NJ;.NF
^^
         _^
         !
         !  
       --!--
   S     !
       --!--
         !
         !
         !
         !
         !
         !                     ------------  **
         !                     !//////////!   *
         !           ----------!//////////!   *
         !           !/////////!//////////!   **  R
         !-----------!/////////!//////////!   *
         !///////////!/////////!//////////!   *
         !///////////!/////////!//////////!  **
         ---------------------------------.--------------->
                                          _^
                                          !
                                          Q\\             TIME
                                        ^^TIME\\

.LM 0;.F.J
^AFTER A CALL ON ^^ACCUM(P,Q,R,S)\\ WE HAVE
.B 2;.LM 0;.NJ;.NF
^^
_^
_!
_!
_!
_!
_!
_!                                ------------  **
_!                                !//////////!   *
_!                     -----------!//////////!   *
_!                     !//////////!//////////!   *
_!          -----------!//////////!//////////!   **  R
_!          !//////////!//////////!//////////!   *
_!----------!//////////!//////////!//////////!   *
_!//////////!//////////!//////////!//////////!   *
_!//////////!//////////!//////////!//////////!  **
--------------------------------------------.------------>
                                            _^
                                            !
                                            Q
                                          TIME\\
.B 2;.LM 0;.F;.J
^P CONTAINS RESULT SO FAR (SHADED AREA).

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 265;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE ON THE USE OF ^^SIMULATION\\
.index ^^Simulation, example of\\
.BR
--------------------------------
.B 1
^THE PROGRAM IS A DESCRIPTION OF A SIMPLE EPIDEMIC MODEL.
^A CONTAGIOUS, NON-LETHAL DISEASE IS SPREADING THROUGH A
^^POPULATION\\ OF A FIXED SIZE.  ^CERTAIN COUNTERMEASURES ARE
TAKEN BY A PUBLIC HEALTH ORGANIZATION.  ^EACH INDIVIDUAL
INFECTION HAS A GIVEN ^^INCUBATION\\ PERIOD, DURING WHICH THE
SUBJECT IS NONCONTAGIOUS AND HAS NO ^^SYMPTOMS\\, FOLLOWED BY
A CONTAGIOUS PERIOD OF A GIVEN ^^LENGTH\\.
.B 1;.C
^^COURSE OF INFECTION IN DAYS\\
.B 1;.NJ;.NF;.LM 12
*                *            *            *
*   ^^INCUBATION   *   LENGTH\\   * THEREAFTER *
********************************************
  ^^NON-CONTAGIOUS   CONTAGIOUS     IMMUNE\\
.B 1;.LM 0;.F;.J
^EACH ^^DAY\\ OF THE CONTAGIOUS PERIOD THE SUBJECT MAY SEEK ^^TREATMENT\\
FROM THE PUBLIC HEALTH ORGANISATION AND GET CURED.  ^THE
PROBABILITY OF HIS SEEKING TREATMENT IS STORED IN ^^REAL ARRAY\\
^^PROBTREAT [1:LENGTH].\\  ^EACH PERSON HAS AN EXPECTED NUMBER OF
^^CONTACTS\\ PER DAY.  ^AT ONE SUCH CONTACT THE PROBABILITY OF INFECTING
A PREVIOUSLY UNINFECTED PERSON IS ^^PROBINFECT\\.
.B 1
^ONCE CURED A PERSON BECOMES IMMUNE.  ^IF UNTREATED, THE INFECTION
CEASES AFTER THE GIVEN PERIOD AND THE PERSON BECOMES IMMUNE.
.B 1
^^SICKP\\ (SICK PERSONS) APPEAR AS ^^PROCESS\\ES IN THE SYSTEM.  ^WHEN
^^CURED\\, OR WHEN THE DISEASE HAS RUN ITS COURSE, THEY LEAVE THE
SYSTEM.  ^THE VERY FIRST INFECTION IS GENERATED BY THE MAIN
PROGRAM (USER BLOCK).  ^A PERSON INFECTED BY ANOTHER PERSON
IS INCLUDED AS A MEMBER IN A SET BELONGING TO THE INFECTOR (HIS
ENVIRONMENT (^^ENV\\)).  ^A PERSON CAN BE A MEMBER OF AT MOST ONE SET.
.B 1
^AS PEOPLE ARE CURED, THEY ARE REMOVED FROM THESE SETS WHICH
GRADUALLY SPLIT UP INTO SMALLER SETS.  ^THE LATTER GROW INDEPENDENTLY,
DISINTEGRATE FURTHER, AND SO ON.  ^AS THE NUMBER OF
^^UNINFECTED\\ PEOPLE DECREASES, THE GROWTH OF THE CONTAGION SLOWS
DOWN UNTIL IT FINALLY DIES OUT.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^THE PUBLIC COUNTERMEASURES ARE REPRESENTED BY ^^TREATMENT\\S WHICH
ARE ALSO ^^PROCESS\\ES.  ^A PATIENT IS REMOVED FROM THE ENVIRONMENT
SET TO WHICH HE BELONGS, IF ANY.  ^IF HE HAS VISIBLE SYMPTOMS,
HE IS CURED.  ^IN ADDITION HIS ENVIRONMENT IS SEARCHED AND EACH
MEMBER IS SUBJECTED TO A FULL TREATMENT WHICH MAY CAUSE OTHER
ENVIRONMENTS TO BE SEARCHED ETC.  ^A PATIENT DISPLAYING NO SYMPTOMS
IS GIVEN A MASS TREATMENT WHICH HAS A PROBABILITY ^^PROBMASS\\
OF SUCCESS.  ^HIS ENVIRONMENT IS NOT SEARCHED.  ^IN THE PRESENT
MODEL, TREATMENTS ACT INSTANTANEOUSLY.  ^THE SIMULATION ENDS
AFTER ^^SIMPERIOD\\ UNITS OF TIME.
.B 1
^AN OUTLINE OF THE PROBLEM DESCRIPTION IS
.B 1;.LM 5;.TS 12,19,26
.NJ;.NF
^^SIMULATION
BEGIN	PROCESS CLASS SICKP;
	BEGIN	REF(HEAD)ENV;
		PROCEDURE INFECT;
		_......
	END ***SICK PERSON*** ;
	PROCESS CLASS TREATMENT(PATIENT);
.index ^^CLASS treatment\\
			REF(SICKP)PATIENT;
	BEGIN ...................... END;
	_..........
END ***SIMULATION BLOCK*** ;\\
.B 2;.LM 0
.IF FOA;.NUMBER 267;.PS 80,80;.PAGE;
.ENDIF FOA
^WE MAY NOW OUTLINE THE CLASS ACTIONS
.B 1;.LM 5;.TS 12
^^PROCESS CLASS SICKP;
BEGIN	PROCEDURE INFECT;......;
	INTEGER TODAY; BOOLEAN SYMPTOMS;
	REF(HEAD)ENV;
	COMMENT ***\\WAIT INCUBATION DAYS FOR SYMPTOMS TO
.TS 23
	APPEAR*** ;
.LM 12
^^HOLD\\(INCUBATION PERIOD);
^^COMMENT ***\\NOW THE SYMPTOMS ARE APPARENT.  ^IF
.LM 23
"TREATMENT TODAY" IS ^^TRUE\\ THEN A CURE
IS SOUGHT WHICH ALSO IMPLIES THAT THE
ENVIRONMENT OF THIS ^^SICK PERSON\\ IS
EXAMINED.  ^ALSO A NUMBER OF CONTACTS
ARE INFECTED*** ;
.LM 12
^^SYMPTOMS := TRUE;
FOR TODAY := 1\\ THROUGH ^^LENGTH DO
BEGIN
.LM 23
IF\\ TREATMENT TODAY ^^THEN ACTIVATE NEW TREATMENT;
INFECT\\(TODAYS CONTACTS);
^^HOLD(1);
.LM 12
END;
.LM 5
END ***SICK PERSON*** ;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0
.IF FOA;.NUMBER 268;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE INFECT(N); INTEGER N;
.B 1;.LM 5;.TS 12
BEGIN	INTEGER I;
	COMMENT ***N\\ GIVES THE NUMBER OF CONTACTS WHO CAN
.LM 23
BE INFECTED.  ^N RANDOM DRAWINGS ARE MADE
TO SEE IF THE ^N CONTACTS ARE TO BE INFECTED.
^IF SO A ^^NEW SICKP\\ IS GENERATED
AND INCLUDED IN THIS ^^SICKP\\S ^^ENV\\ AND
ACTIVATED*** ;
.LM 12
^^FOR I := 1\\ THROUGH ^^N DO\\
.LM 16
^^IF I\\TH CONTACT IS INFECTED ^^THEN
BEGIN  NEW SICKP.INTO(ENV);
.LM 23
ACTIVATE ENV.LAST;
.LM 16
END;
.LM 5
END ***INFECT***\\
.B 2;.LM 0;.TS 7
.IF FOA;.NUMBER 269;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCESS CLASS TREATMENT(PATIENT); REF(SICKP)PATIENT;
BEGIN	REF(SICKP)X;
	INSPECT PATIENT WHEN SICKP DO
.LM 7;.TS 14
BEGIN	OUT;
	IF SYMPTOMS THEN
	BEGIN  CANCEL(PATIENT);
.TS 21
	FOR X :- ENV.FIRST WHILE X =/= NONE DO
.TS 25
	ACTIVATE NEW TREATMENT(X);
.LM 14
END ELSE IF\\ MASS TREATMENT SUCCESSFUL
.TS 26
	^^THEN CANCEL(PATIENT)
.LM 0;.TS 7
	END;
END ***TREATMENT***\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
^EXPLANATION:
.BR
------------
.B 1
^A TREATMENT TESTS THE ^^SYMPTOMS\\ ATTRIBUTE OF ITS PARAMETER ^^PATIENT\\.
^IF ^^TRUE\\ THEN THE INSTANTANEOUS SUCCESSFUL TREATMENT IS GIVEN.
^THE PATIENT IS REMOVED FROM THE SET HE IS IN (^^OUT\\) AND BECOMES
PASSIVE FOR THE REST OF THE SIMULATION.  ^IN ADDITION HIS ENVIRONMENT
IS SEARCHED AND A NEW TREATMENT IS ACTIVATED FOR EACH MEMBER.
^IF THERE ARE NO SYMPTOMS, THE PATIENT IS GIVEN A CHEAP PILL WHICH
HAS A PROBABILITY OF BEING SUCCESSFUL.  ^IF SUCCESSFUL THE PATIENT
IS INSTANTANEOUSLY CURED AND TAKES NO FURTHER PART IN THE SIMULATION,
BUT HIS ENVIRONMENT IS NOT SEARCHED.
.B 1
.IF FOA;.NUMBER 270;.PS 80,80;.PAGE;
.ENDIF FOA
^A COMPLETE DESCRIPTION OF THE PROGRAM NOW FOLLOWS:
.B 1;.LM 0;.NJ;.NF;.TS 7
^^BEGIN   INTEGER POPULATION, LENGTH, CONTACTS, INCUBATION,
    UNINFECTED, U1, U2, U3, U4, I, NSICK;
    REAL PROBINFECT, PROBMASS, SIMPERIOD;
    COMMENT ***THE RANDOM STREAM BASES ARE READ IN*** ;
    U1 := ININT; U2 := ININT;
    U3 := ININT; U4 := ININT;
    UNINFECTED:= POPULATION := ININT;
    INCUBATION := ININT; LENGTH := ININT;
    CONTACTS := ININT;
    SIMPERIOD := INREAL;
    PROBINFECT := INREAL; PROBMASS := INREAL;
    SIMULATION BEGIN  REAL ARRAY PROBTREAT[1:LENGTH];
.B 1
        BOOLEAN PROCEDURE THISPERSONCAUGHTIT;
        THISPERSONCAUGHTIT:=
        DRAW(PROBINFECT*UNINFECTED/POPULATION,U3);
.B 1
        BOOLEAN PROCEDURE TREATED(DAY);
        INTEGER DAY;
        TREATED:= DRAW(PROBTREAT[DAY],U1);
.B 1
        BOOLEAN PROCEDURE
        MASSTREATMENTSUCCESSFULL;
        MASSTREATMENTSUCCESSFULL:=
        DRAW(PROBMASS,U4);
.B 1
        PROCESS CLASS SICKP;
        BEGIN  INTEGER TODAY;
            BOOLEAN SYMPTOMS;
            REF(HEAD)ENV;
            PROCEDURE INFECT(N); INTEGER N;
            BEGIN  INTEGER J;
                FOR J := 1 STEP 1 UNTIL N DO
                IF  THISPERSONCAUGHTIT
                THEN
                BEGIN  NEW SICKP.INTO(ENV);
                    ACTIVATE ENV.LAST;
                END;
            END ***INFECT*** ;
.B 1

            NSICK:= NSICK + 1;
            IF UNINFECTED > 0 THEN
            UNINFECTED := UNINFECTED-1;
            ENV :- NEW HEAD;
            COMMENT ***NO SYMPTOMS APPEAR UNTIL
            AFTER INCUBATION DAYS***
            ;
            HOLD(INCUBATION); SYMPTOMS := TRUE;
            COMMENT ***NOW SYMPTOMS APPEAR AND
            THIS SICK PERSON MAY SEEK A
            CURE AND INFECT OTHERS EACH
            DAY*** ;
            FOR TODAY := 1 STEP 1 UNTIL LENGTH DO
            BEGIN  IF TREATED(TODAY) THEN
                ACTIVATE NEW TREATMENT(CURRENT);
                INFECT(POISSON(CONTACTS,U2));
                HOLD(1)
            END;
            NSICK:= NSICK - 1;
        END ***SICK PERSON*** ;
.B 1
        PROCESS CLASS TREATMENT(PATIENT);
        REF(SICKP)PATIENT;
        BEGIN  REF(SICKP)X;
            INSPECT PATIENT WHEN SICKP DO
            BEGIN  OUT;
                IF SYMPTOMS THEN
                BEGIN  CANCEL(PATIENT);
                    NSICK:= NSICK - 1;
                    FOR X :- ENV.FIRST WHILE X =/= NONE DO
                    ACTIVATE NEW TREATMENT(X);
                END ELSE IF MASSTREATMENTSUCCESSFULL
                THEN
                BEGIN   NSICK:= NSICK - 1;
                    CANCEL(PATIENT);
                END;
            END;
        END ***TREATMENT*** ;
.b
        PROCESS CLASS SPY;
        BEGIN
            WHILE TRUE DO
            BEGIN
                OUTINT(TIME,4);   SETPOS(NSICK+6);
                OUTCHAR('*');   OUTIMAGE;
                HOLD(1);
            END LOOP;
        END ***SPY***;
.B 1
        ACTIVATE NEW SICKP;
        ACTIVATE NEW SPY DELAY 0;
        FOR I:= 1 STEP 1 UNTIL LENGTH DO
        PROBTREAT[I]:= INREAL;
        HOLD(SIMPERIOD);
    END ***SIMULATION BLOCK*** ;
END ***PROGRAM***
.B 2;.J;.F
^IF ^^SYSIN\\ CONTAINS:
.B 1;.NJ;.NF
1 3 5 7
100 3 7
40 30 0.20 0.1
0.75 0.6 0.5 0.45 0.4 0.4 0.35
.B 1
^THE RESULTING OUTPUT WILL BE:
.b 2
.test page 30
   0  *
   1  *
   2  *
   3         *
   4       *
   5       *
   6        *
   7                 *
   8               *
   9                                *
  10                                *
  11                                     *
  12                                        *
  13                               *
  14                              *
  15                          *
  16               *
  17         *
  18      *
  19        *
  20        *
  21       *
  22    *
  23  *
  24    *
  25    *
  26    *
  27 *
  28 *
  29 *
.SUBTITLE ^^CHAPTER\\ 3.4
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 272;.PS 80,80;.PAGE;
.ENDIF FOA
3.4##^^TEXT HANDLING FACILITIES\\
.BR
#####------------------------
.B 1
^THE CONCEPT OF ^^TEXT\\ IS THE KEY TO ^^SIMULA\\'S INPUT/OUTPUT FACILITIES.
^FOR EXAMPLE WHEN A CARD IS READ IN, THE INTERNAL REPRESENTATION
IS HELD AS A STRING OF 80 ^^CHARACTERS\\ WITH A ONE TO ONE
.index ^^TEXT handling\\
.index ^^TEXT\\
.index ^^CHARACTER string\\
.index ^^String processing\\
.index ^^Character string processing\\
CORRESPONDENCE BETWEEN THE NTH COLUMN OF THE CARD AND THE NTH
^^CHARACTER\\ IN THE STRING.  ^SUCH A STRING IS CALLED A ^^TEXT-\\VALUE
.index ^^TEXT value\\
AND IT IS HOUSED IN A REFERENCED ^^TEXT-\\OBJECT.
.index ^^TEXT object\\
.B 1;.LM 10
     -------------------------------------------
.I -5
.BR
^^T--->! THIS TEXT VALUE LIES IN A TEXT OBJECT.#!\\
.BR
     -------------------------------------------
.B 1;.LM 0
^WITH ^^TEXT\\S WE HAVE THUS A COMBINATION OF BOTH REFERENCE (TO THE
HOUSING OBJECT) AND VALUE (THE STRING OF ^^CHARACTERS) \\PROPERTIES.
^^TEXT\\S RESEMBLE OBJECTS (OF CLASSES) IN THAT THEY POSSES ATTRIBUTES
WHICH ARE ACCESSED BY THE NORMAL REMOTE ACCESSING (DOT
NOTATION) TECHNIQUE, BUT ^^TEXT\\S AND THEIR ATTRIBUTES ARE WHOLLY
SYSTEM DEFINED.
.B 1
^WHEREAS A ^^CHARACTER ARRAY\\ IS ORIENTED TOWARDS ACCESSING SINGLE
.index ^^CHARACTER ARRAY\\
CHARACTERS BY DIRECT MEANS (SUBSCRIPTS), THE ^^TEXT\\
CONCEPT IS ORIENTED TOWARDS GROUPINGS OF CHARACTERS AND SEQUENTIALLY
ACCESSING THESE GROUPS.
.B 1
^^TEXT\\ VARIABLES ARE DECLARED IN THE USUAL FASHION.
.index ^^TEXT variable\\
.B 1
E.G.#####^^TEXT#R,S,T\\
.B 1
AND THE INITIAL VALUE OF EACH OF THESE VARIABLES IS ^^NOTEXT\\,
THAT IS THE EMPTY STRING.
.index ^^NOTEXT\\
.B 1
.IF FOA;.NUMBER 273;.PS 80,80;.PAGE;
.ENDIF FOA
^^TEXT\\ VARIABLES ARE CAPABLE OF REFERENCING ^^TEXT\\ OBJECTS, WHICH
MAY BE CREATED BY TWO SYSTEM DEFINED ^^PROCEDURES - BLANKS\\ AND ^^COPY:\\
.index ^^COPY procedure for copying TEXTs\\
.B 1;.I 10
^^T#:-#BLANKS(N)\\
.B 1
CREATES A ^^TEXT\\ OBJECT OF LENGTH ^N CHARACTERS, EACH INITIALISED
.index ^^LENGTH of a TEXT\\
TO THE BLANK CHARACTER.  ^AFTER CREATION OF THE OBJECT, ITS REFERENCE
.index ^^Blank\\
VALUE IS ASSIGNED TO ^T.
.index ^^TEXT assignment\\
.B 1;.LM 10
^^S#:-#COPY("SIMULA");
.B 1
R#:-#COPY(S)\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0
^^COPY\\ WILL ACCEPT EITHER A ^^TEXT\\ VALUE OR A ^^TEXT\\ REFERENCE EXPRESSION
.index ^^TEXT reference assignment\\
AS PARAMETER, CREATES A ^^TEXT\\ OBJECT WITH VALUE IDENTICAL
TO THAT OF THE ACTUAL PARAMETER AND OF THE SAME LENGTH,
AND RETURNS A REFERENCE TO IT.  ^THE RESULT OF THE LAST TWO STATEMENTS
MAY BE PICTURED BY
.B 1;.LM 5;.NJ;.NF
^^
        -----------------    ----------
S .---->! 1 ! 1 ! 6 ! .-!--->! SIMULA !
        -----------------    ----------
.B 1
        -----------------    ----------
R .---->! 1 ! 1 ! 6 ! .-!--->! SIMULA !
        -----------------    ----------\\
.B 1
            MAGIC BOX
.B 2;.LM 0;.F;.J
^EACH ^^TEXT\\ VARIABLE HAS ITS OWN "MAGIC BOX" WHICH GIVES INFORMATION
ABOUT THE START POSITION (^^SP)\\, LENGTH (^^LG)\\ AND
CURRENT POSITION (^^CP)\\ OF THE OBJECT IT CURRENTLY REFERENCES.
^THE BOX ALSO CONTAINS THE REFERENCE VALUE OF THE OBJECT ITSELF.
^THE FORMAL PATTERN OF THESE MAGIC BOXES IS:
.B 1;.LM 5;.NJ;.NF
--------------------------
_! ^^SP ! CP ! LG\\ ! REF.VAL !
--------------------------
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 274;.PS 80,80;.PAGE;
.ENDIF FOA
^A ^^TEXT\\ OBJECT MAY BE REFERENCED IN SUBFIELDS BY USE OF THE PROCEDURE ^^SUB\\
.index ^^SUB\\
.B 1
.LM 0;.TS 15
^AFTER	^^T :- COPY("SIMULA")\\
.B 1
THEN	^^S :- T.SUB(5,2)\\
.B 1
RESULTS IN
.B 1;.LM 10;.NJ;.NF
^^
        -----------------    ----------
T .---->! 1 ! 1 ! 6 ! .-!--->! SIMULA !
        -----------------    ----------
                                   _^
        -----------------          !
S .---->! 5 ! 1 ! 2 ! .-!-----------\\
        -----------------
.B 2
.LM 0;.RM 70;.F;.J
^S REFERENCES THE SUBFIELD OF ^T BEGINNING FROM CHARACTER 5
AND OF LENGTH 2.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^THE CHARACTERS MAY BE ACCESSED ONE AT A TIME BY CALLS ON ^^GETCHAR\\
.index ^^CHARACTER access (to TEXTs)\\
WHICH RETURNS THE VALUE OF THE CURRENT CHARACTER AND INCREMENTS
THE ^^CP\\ BY ONE.
.B 1
.LM 0;.TS 20
^AFTER	^C := ^^T.GETCHAR;\\
.BR
	^D := ^^T.GETCHAR\\
.B 1
THE SNAPSHOT IS
.LM 5;.NJ;.NF
^^
        -----------------    ----------
T .---->! 1 ! 3 ! 6 ! .-!--->! SIMULA !
        -----------------    ----------
                                    _^
                                    !
        -----------------           !
S .---->! 5 ! 1 ! 2 ! .-!------------
        -----------------\\
.B 2;.LM 0;.F;.J
AND THE VALUES OF ^C AND ^D ARE '^S' AND '^I' RESPECTIVELY.
^AS ACCESS WAS MADE THROUGH ^T, ONLY ITS ^C^P HAS BEEN INCREMENTED
(TWICE). ^THE REVERSE PROCESS OF INSERTING A CHARACTER VALUE
INTO THE CURRENT POSITION IS ACHIEVED THROUGH USE OF ^^PUTCHAR\\,
.index ^^PUTCHAR\\
WHICH ALSO INCREMENTS THE ^^CP\\.
.B 1;.LM 0;.TS 20
.IF FOA;.NUMBER 275;.PS 80,80;.PAGE;
.ENDIF FOA
^AFTER	^^S.PUTCHAR('6);
.BR
	S.PUTCHAR('7)\\
.B 1
THE SNAPSHOT IS
.B 1;.LM 5;.NJ;.NF
^^        -----------------    ----------
T .---->! 1 ! 3 ! 6 ! .-!--->! SIMU67 !
        -----------------    ----------
                                   _^
                                   !
        -----------------          !
S .---->! 5 ! 3 ! 2 ! .-!-----------
        -----------------
\\
.B 2;.LM 0;.F;.J
^NOTE THAT THE VALUE OF ^T HAS BEEN CHANGED.  ^THE ^^CP\\ OF ^S IS
NOW OUT OF RANGE.  ^A FURTHER CALL
.B 1;.I 10
^^S.PUTCHAR\\
.BR
.TS 10
OR	^^S.GETCHAR\\
.B 1
WILL RESULT IN A RUN TIME ERROR.  ^TO PROVIDE A CHECK, A ^^BOOLEAN\\
^^PROCEDURE MORE\\ IS PROVIDED WHICH RETURNS ^^FALSE\\ IF THE ^^CP\\ IS OUT
.index ^^MORE\\
OF RANGE AND ^^TRUE\\ OTHERWISE.  ^CURRENTLY,
.B 1;.LM 0;.TS 10,30
	^^T.MORE = TRUE	S.MORE = FALSE\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^OTHER USEFUL SYSTEM DEFINED PROCEDURES ARE:
.B 1
.LM 10;.NJ;.NF;.TS 10;.I -10
^^LENGTH\\	WHICH RETURNS THE LENGTH OF THE CURRENTLY
REFERENCED VALUE
(^^T.LENGTH = 6
#S.LENGTH = 2)\\
.B 1;.I -10
^^POS\\	WHICH RETURNS THE VALUE OF THE ^^CP\\
.index ^^POS\\
(^^T.POS = 3
#S.POS = 3)\\
.B 1;.I -10
.IF FOA;.NUMBER 276;.PS 80,80;.PAGE;
.ENDIF FOA
^^SETPOS\\	WHICH RESETS THE ^^CP\\.  (^TO RESET THE ^^CP\\'S OF
.index ^^SETPOS on TEXTs\\
^T AND ^S BACK TO THEIR INITIAL CHARACTER, WE WRITE
^^T.SETPOS(1)
S.SETPOS(1)#)\\
.B 1;.LM 0
^TEXT VALUES MAY BE TRANSFERRED FROM ONE SUBJECT TO ANOTHER BY
.B 1;.I 10
^^S := T\\
.B 1
OR A VALUE INTO AN OBJECT BY
.B 1;.I 10
^^S := "TEXT VALUE"\\
.B 1
^BOTH ARE LEFT JUSTIFIED.
.B 1;.LM 0;.F;.J
^THE ONLY RESTRICTION IS THAT THE ^^TEXT\\ OBJECT RECEIVING THE
VALUE MUST BE LONG ENOUGH TO ACCEPT THE VALUE OR ELSE A RUN
TIME ERROR OCCURS.  ^ANY POSITIONS NOT DIRECTLY COPIED INTO ARE
FILLED WITH BLANKS.
.index ^^Blank\\
.B 1
^SEVERAL EDITING AND DE-EDITING PROCEDURES ARE DEFINED WITHIN
.index ^^TEXT editing and de-editing\\
.index ^^De-editing procedures\\
^^SIMULA\\.  ^THESE CONVERT NUMBERS TO EXTERNAL FORM AND VICE VERSA.
^THEY ARE DESIGNED TO OPERATE REPETITIVELY ACROSS A FIELD AND ARE
THUS ORIENTED TOWARDS FORMATTED OUTPUT AND INPUT.
.B 1
^THE FURTHER DETAILED DESCRIPTION OF THE ^^TEXT\\ HANDLING FACILITIES
IS GIVEN UNDER THE SUB-SECTIONS
.B 1;.LM 10
^^LENGTH\\ AND ^^MAIN\\
.BR
SUBTEXTS
.BR
CHARACTER ACCESS
.BR
TEXT GENERATION
.BR
^^TEXT\\ ASSIGNMENT
.BR
^^TEXT\\ EDITING
.B 1;.LM 0
^THROUGHOUT THESE SUBSECTIONS ^X, ^Y, ^Z DENOTE ^^TEXT\\ REFERENCES.
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 277;.PS 80,80;.PAGE;
.ENDIF FOA
^^LENGTH\\ AND ^^MAIN\\
.BR
---------------
.B 3
^^INTEGER PROCEDURE LENGTH;\\
.index ^^Length of a text value\\
.index ^^LENGTH\\
.BR
-------------------------
.B 1
^THE VALUE OF ^^X.LENGTH\\ IS THE NUMBER OF ^^CHARACTERS\\ IN THE ^^TEXT\\
OBJECT REFERENCED BY ^X.
.B 1
.TS 10
E.G.	AFTER ^X :- ^^BLANKS(10),\\      THEN ^^X.LENGTH\\ = 10
.BR
	IF  ^Y == ^^NOTEXT,######\\      THEN ^^Y.LENGTH\\ =  0
.B 3;.LM 0;.F;.J
^^TEXT PROCEDURE MAIN;\\
.index ^^MAIN of TEXTs\\
.BR
--------------------
.B 1
^^X.MAIN\\ IS A REFERENCE TO THE ^^TEXT\\ OBJECT WHICH IS OR CONTAINS
.index ^^MAIN of TEXTs\\
THE TEXT VALUE REFERENCED BY ^X.
.B 1;.LM 0;.TS 10,16
E.G.	AFTER ^^X :- BLANKS(20);
.BR
		^^Y :- X.SUB(1,10);
.BR
		Z :- NOTEXT;\\
.B 1
	THEN  ^^X.MAIN == X
.index ^^MAIN of TEXTs\\
.BR
		Y.MAIN == X
.BR
		Z.MAIN == NOTEXT\\
.B 1;.LM 0
^THE FOLLOWING RELATIONS HOLD FOR ANY ^^TEXT\\ REFERENCE ^X
.B 1;.LM 10
^^X.MAIN.LENGTH >= X.LENGTH
.BR
X.MAIN.MAIN == X.MAIN\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 278;.PS 80,80;.PAGE;
.ENDIF FOA
^^SUBTEXTS\\
.index ^^Equivalence of TEXTs, see Subtext\\
.index ^^Redefines on TEXTs, see Subtext\\
.index ^^Subtexts\\
.BR
--------
.B 3
^^TEXT PROCEDURE SUB(I,N); INTEGER I,N;\\
.index ^^SUB\\
.BR
--------------------------------------
.B 1
^THE CALL
.B 1;.I 10
^^X.SUB(J,M)\\
.B 1
DESIGNATES THAT PART OF THE ^^TEXT\\ OBJECT REFERNECED BY ^X STARTING
IN ^^CHARACTER\\ POSITION ^J AND OF LENGTH ^M CHARACTERS.
.B 1;.LM 0;.TS 10
E.G.	AFTER ^X :- ^^COPY("MAIN NOT SUB-TEXT");
.BR
	######T :- X.SUB(10,8);
.B 1
\\	THEN   ^^T = "SUB-TEXT"\\
.B 1;.LM 0;.F;.J
^FOR ^^X.SUB(J,M)\\ TO BE A LEGAL CALL, THE SUBTEXT MUST BE INCLUDED
IN ^X.  ^THUS
.B 1;.LM 10
^^J > 0
.BR
J + M-1 <= X.LENGTH\\
.B 1;.LM 0
^IF THESE CONDITIONS DO NOT HOLD A RUN TIME ERROR RESULTS.
.B 3
^^TEXT PROCEDURE STRIP\\;
.index ^^STRIP\\
.BR
---------------------
.B 1
^^STRIP\\ IS USED TO RETURN A REFERENCE TO A SUBFIELD OF A ^^TEXT\\
OBJECT WHICH DIFFERS FROM THE ORIGINAL IN THAT ALL BLANKS ON
THE RIGHT ARE IGNORED.  ^^X.STRIP\\ IS THUS EQUIVALENT TO ^^X.SUB(1,N)\\
WHERE THE REMAINING ^^CHARACTERS\\ OF ^X (FROM POSITION ^N+1 AND OF
LENGTH ^^X.LENGTH-N\\), IF ANY, ARE ALL BLANKS.
.IF FOA;.NUMBER 279;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^CHARACTER\\ ACCESS
.BR
----------------
.B 1
^THE ^^CHARACTERS\\, VALUES HOUSED IN A ^^TEXT\\ OBJECT, ARE ACCESSIBLE
ONE AT A TIME.  ^ANY ^^TEXT\\ REFERENCE CONTAINS A "POSITION INDICATOR"
WHICH IDENTIFIES THE CURRENTLY ACCESSIBLE ^^CHARACTER\\ OF THE REFERENCED ^^TEXT\\ OBJECT.
.B 1
^THE POSITION INDICATOR OF ^^NOTEXT\\ IS 1.  ^^A TEXT\\ REFERENCE OBTAINED
.index ^^NOTEXT, POS of\\
BY CALLING ANY SYSTEM DEFINED ^^TEXT\\ PROCEDURE HAS ITS POSITION
INDICATOR SET TO 1.  ^THE POSITION INDICATOR OF A GIVEN ^^TEXT\\ REFERENCE
MAY BE ALTERED BY THE ^^PROCEDURES SETPOS, GETCHAR, PUTCHAR,
.index ^^SETPOS on TEXTs\\
TEXT-\\REFERENCE-ASSIGNMENT AND ANY EDITING OR DE-EDITING ^^PROCEDURE.\\
.index ^^Conversion from TEXT to numerical value\\
.index ^^De-editing procedures\\
^POSITION INDICATORS ARE LEFT UNALTERED BY ^^TEXT\\ REFERENCE RELATIONS,
^^TEXT\\ VALUE RELATIONS AND ^^TEXT\\ VALUE ASSIGNMENTS.
.index ^^TEXT value assignment\\
.B 3
^^INTEGER PROCEDURE POS;\\
.index ^^POS\\
.BR
----------------------
.B 1
^^X.POS\\ IS THE CURRENT VALUE OF THE POSITION INDICATOR OF ^X.
^THE FOLLOWING RELATION IS ALWAYS ^^TRUE\\.
.B 1;.I 10
^^1 <= X.POS <= X.LENGTH + 1\\
.B 3
^^PROCEDURE SETPOS(I); INTEGER I;\\
.index ^^SETPOS on TEXTs\\
.BR
--------------------------------
.B 1
^THE EFFECT OF ^^X.SETPOS(M)\\ IS TO ASSIGN THE VALUE OF ^M TO THE
.index ^^SETPOS on TEXTs\\
POSITION INDICATOR OF ^X, IF 1 <= M <= ^^X.LENGTH +1.\\  ^IF ^M IS
OUT OF THIS RANGE, THEN THE VALUE ^^X.LENGTH + 1\\ IS ASSIGNED.
.B 3
^^BOOLEAN PROCEDURE MORE;\\
.index ^^MORE\\
.BR
-----------------------
.B 1
^^X.MORE\\ IS ^^TRUE\\ IF THE POSITION INDICATOR OF ^X IS IN THE RANGE
1 THROUGH ^^X.LENGTH\\, OTHERWISE THE VALUE IS ^^FALSE\\.
.B 3
.IF FOA;.NUMBER 280;.PS 80,80;.PAGE;
.ENDIF FOA
^^CHARACTER PROCEDURE GETCHAR;\\
.index ^^GETCHAR\\
.BR
----------------------------
.B 1
^THE VALUE OF ^^X.GETCHAR\\ IS A COPY OF THE CURRENTLY ACCESSIBLE
^^CHARACTER\\ OF ^X PROVIDED ^^X.MORE\\ IS ^^TRUE\\.  ^IN ADDITION, THE POSITION
INDICATOR OF ^X IS THEN INCREASED BY ONE.  ^A RUN TIME ERROR
RESULTS IF ^^X.MORE\\ WAS ^^FALSE.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^PROCEDURE PUTCHAR(C); CHARACTER C;\\
.BR
----------------------------------
.B 1
^THE EFFECT OF ^^X.PUTCHAR(C)\\ IS TO REPLACE THE CURRENTLY ACCESSIBLE
^^CHARACTER\\ OF ^X BY THE VALUE OF ^C PROVIDED THAT ^^X.MORE\\ IS ^^TRUE\\.
^IN ADDITION THE POSITION INDICATOR OF ^X IS THEN INCREASED BY
ONE.  ^IF ^^X.MORE\\ IS ^^FALSE\\, A RUN TIME ERROR RESULTS.
.B 2;.LM 0
^EXAMPLE:
.BR
--------
.B 1
^THE ^^PROCEDURE COMPRESS\\ REARRANGES THE ^^CHARACTERS\\ OF THE ^^TEXT\\
.index ^^PROCEDURE COMPRESS\\
OBJECT REFERENCED BY THE ACTUAL PARAMETER BY COLLECTING NON-BLANK
^^CHARACTERS\\ IN THE LEFTMOST PART OF THE ^^TEXT\\ OBJECT AND
FILLING IN THE REMAINDER, IF ANY, WITH BLANKS.  ^SINCE THE PARAMETER
IS CALLED BY REFERENCE (AND NOT BY NAME), ITS POSITION
INDICATOR IS UNALTERED.
.B 1;.LM 10;.NJ;.NF;.TS 17
^^PROCEDURE COMPRESS(T); TEXT T;
BEGIN	TEXT U; CHARACTER C;
	T.SETPOS(1); U :- T;
MOVELEFT:  WHILE U.MORE DO
.TS 21
	BEGIN  C := U.GETCHAR;
.TS 28
	IF C NE '#' THEN T.PUTCHAR(C);
.LM 21
END;
COMMENT ***WE NOW FILL IN THE RIGHT WITH
.TS 32
	BLANKS*** ;
.LM 21
T.SUB(T.POS,T.LENGTH-T.POS+1) := NOTEXT;
.LM 10
END ***COMPRESS***\\
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 281;.PS 80,80;.PAGE;
.ENDIF FOA
^NOTE THE USE OF A VALUE ASSIGNMENT TO ^^T.SUB\\, AND THE USE OF
^^NOTEXT\\ ON A RIGHT HAND SIDE AS A NEAT WAY OF FILLING A ^^TEXT\\
.index ^^NOTEXT, use of to make a TEXT wholly blank\\
VALUE TO BLANKS.
.B 1;.LM 0;.TS 15
^AFTER	^^X :- COPY("GET RID OF ALL BLANKS");
.BR
	COMPRESS(X);
.B 1
THEN	^^X = "GETRIDOFALLBLANKS####"
.BR
	X.STRIP = "GETRIDOFALLBLANKS"\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 282;.PS 80,80;.PAGE;
.ENDIF FOA
^^TEXT\\ GENERATION
.index ^^NEW TEXT generation\\
.index ^^TEXT generation\\
.index ^^Generation of TEXT character strings\\
.index ^^Allocation of TEXT character strings\\
.index ^^Memory allocation for TEXT character strings\\
.index ^^String of characters, memory allocation for\\
.index ^^Character string memory allocation\\
.BR
---------------
.B 1
^^N.B.\\##^PROCEDURES ^^BLANKS\\ AND ^^COPY\\ ARE NON-LOCAL.
.B 3
^^TEXT#PROCEDURE#BLANKS(N);#INTEGER#N;\\
.index ^^BLANKS, procedure for allocation of TEXTs\\
.BR
------------------------------------
.B 1
^THE REFERENCE VALUE IS A NEW ^^TEXT\\ OBJECT OF LENGTH ^N, FILLED
WITH BLANK ^^CHARACTERS\\.
.B 1
^THE VALUE OF THE ACTUAL PARAMETER, ^M, IS RESTRICTED TO
.B 1;.I 10
^^0 <= M <= 2_^18-1 = 262143\\
.B 1
OTHERWISE A RUN TIME ERROR RESULTS.
.B 3
^^TEXT#PROCEDURE#COPY(T);#VALUE#T;#TEXT#T;\\
.index ^^COPY procedure for copying TEXTs\\
.index ^^Copying of character strings (TEXTs)\\
.BR
----------------------------------------
.B 1
^THE REFERENCED VALUE IS A NEW ^^TEXT\\ OBJECT WHICH IS A COPY OF
THE ^^TEXT\\ VALUE WHICH IS (OR IS REFERENCED BY) THE ACTUAL PARAMETER.
.B 1
^EXAMPLE:
.BR
--------
.B 1;.I 10
^^T :- COPY("DEC10SIMULA");\\
.B 1
IS EQUIVALENT TO,
.B 1;.LM 10
^^T :- BLANKS(11);
.BR
T := "DEC10SIMULA"\\;
.B 1;.LM 0
^^There is no explicit statement in SIMULA to delete or destroy
.index ^^Delete of TEXTs\\
.index ^^Free on TEXTs\\
.index ^^Garbage collection of TEXTs\\
.index ^^Removal of TEXTs\\
.index ^^Destroy of TEXTs\\
.index ^^Kill of TEXTs\\
TEXTs. TEXTs are automatically removed by the garbage collector
when there is no way to refer to the TEXT any more from the
program. Note that as long as there is a way to refer from
the program to any subtext (except NOTEXT), the whole main TEXT
is kept in core (and available through the procedure MAIN).
\\
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0
.IF FOA;.NUMBER 283;.PS 80,80;.PAGE;
.ENDIF FOA
^^TEXT\\ ASSIGNMENT
.BR
---------------
.B 1;.LM 4;.I -4
A)##^^TEXT\\-REFERENCE-ASSIGNMENT
.BR
-------------------------
.B 1;.LM 0
^A ^^TEXT\\-REFERENCE-ASSIGNMENT CAUSES A COPY OF THE ^^TEXT\\-REFERENCE
(I.E. THE MAGIC BOX VALUES) OBTAINED BY EVALUATING THE RIGHT PART TO BE ASSIGNED TO THE LEFT
PART VARIABLE - THIS INCLUDES A COPY OF ITS POSITION INDICATOR.
.B 1;.LM 0;.TS 10,25
E.G.	AFTER	^^X :- COPY("ABCD");
.BR
		X.SETPOS(3);
.BR
		Y :- X;\\
.B 1
	THEN	^^X.POS = 3
.BR
		Y.POS = 3\\
.B 1
^IN GENERAL, AFTER	^^X :- P;####\\WHERE ^P IS A ^^TEXT\\ REFERENCE,
.B 1
	THEN	^^X == P
.BR
		X = P
.BR
		X.POS = P.POS\\
.B 1
ARE ALL ^^TRUE\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 4;.I -4
.IF FOA;.NUMBER 284;.PS 80,80;.PAGE;
.ENDIF FOA
B)##^^TEXT\\-VALUE-ASSIGNMENT
.BR
---------------------
.B 1
.LM 0
^CONSIDER THE VALUE ASSIGNMENT
.B 1;.I 10
^^T := P;\\
.B 1
LET THE LENGTH OF ^T BE ^LL, AND THE RIGHT PART BE A ^^TEXT\\ VALUE
OF LENGTH ^LR.  ^THERE ARE THREE CASES TO CONSIDER:
.B 2;.LM 20;.TS 20;.I -20
^LL#=#^LR:	THE CHARACTER CONTENTS OF THE RIGHT PART ^^TEXT\\ ARE COPIED TO THE LEFT PART ^^TEXT\\
.B 1;.I -20
^LL#>#^LR:	THE CHARACTER CONTENTS OF THE RIGHT PART ARE COPIED INTO THE LEFTMOST ^LR CHARACTERS
OF THE LEFT PART ^^TEXT,\\ WHOSE REMAINING ^LL-^LR ^^CHARACTERS\\ ARE FILLED WITH BLANKS.
.B 1;.I -20
^LL#<#^LR:	A RUN TIME ERROR RESULTS.
.B 2;.LM 0;.TS 10
^THE ^^POS\\ OF ^T (AND ^P) WILL NOT BE CHANGED.
.B 1
^AFTER	^^T :- COPY("EIGHT CHARS");
.BR
	T := "WRONG:11";\\
.B 1
THEN	^^T = "WRONG:11###"\\
.B 1
^NOTE THAT
.B 1
	^^T := NOTEXT;\\
.B 1
IS AN EFFICIENT WAY TO SET ALL THE CHARACTER POSITIONS OF ^T TO BLANKS.
.B 2
^IN A MULTIPLE ^^TEXT\\ VALUE ASSIGNMENT (^T^A IS A ^^TEXT ARRAY\\)
.B 1
	^^T[1] := T[2] := ..... T[N] := P;\\
.B 1
THEN
.B 1
	^^TA[J].LENGTH >= TA[J+1].LENGTH
.BR
\\FOR	^^J  =  1,2,...,N-1\\ MUST BE TRUE.
.if foa;.number 281;.nojustify;.paper size 80,63
.endif foa;
.PAGE;.LM 0;.FILL
.index ^^TEXTs with variable length\\
.index ^^Variable length character strings (TEXTs)\\
.index ^^VARYING declaration of character strings\\
^^Variable length TEXTs and TEXT concatenation.
.BR
--------------------------------------------
.B 1
There are two ways in which you can achieve variable length
TEXTs in SIMULA. You can either have variable length TEXTs with
a fixed upper length limit (like VARYING in PL/I), or with no
upper limit.
.B 1
In the first case, you allocate a main text with the upper length
limit as its length. You can then use subtexts when you want
shorter texts, and you can change length by
.B 1;.INDENT 10
T:- T.MAIN.SUB(1,NEWLENGTH)
.B 1
If you want no fixed upper limit (except the system limit 262143),
you can allocate new texts with the procedure BLANKS,
e.g. "t:- BLANKS(newlength)". A concatenation procedure would
.index ^^Concatenation of TEXTs\\
.index ^^TEXTs, concatenation of\\
.index ^^Character strings, concatenation of\\
.index ^^String of characters, concatenation of\\
.index ^^Catenation of TEXTs\\
.index ^^Linking of TEXTs\\
then for example copy the parts into subtexts of t by
.B 1;.left margin 10;.nofill
t.SUB(1,PART1.LENGTH):= PART1;
T.SUB(PART1.LENGTH+1,PART2.LENGTH):= PART2;
.B 1
.left margin 0;.fill
(A concatenation procedure will be available in the SIMULA
program library. See part III of the DECsystem-10 SIMULA Handbook.)
.B 1
If you want linking of character strings without copying, you
can easily implement this yourself in SIMULA using e.g_. SIMSET.
.index ^^Concatenation of TEXTs\\
.index ^^Catenation of TEXTs\\
.index ^^Linking of TEXTs\\
.index ^^TEXTs, concatenation of\\
.index ^^Character strings, concatenation of\\
.index ^^String of characters, concatenation of\\
\\
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 285;.PS 80,80;.PAGE;
.ENDIF FOA
^TEXT EDITING AND DE-EDITING
.index ^^Conversion from TEXT to numerical value\\
.index ^^Editing procedures\\
.index ^^De-editing procedures\\
.BR
---------------------------
.B 1
^^TEXT\\ EDITING AND DE-EDITING PROCEDURES ARE PROVIDED TO TRANSFORM
.index ^^De-editing procedures\\
BINARY VALUES INTO TEXT STRINGS AND VICE VERSA.  ^THE SYNTAX FOR
NUMERIC-TEXT-VALUES (EXTERNAL DATA) FOLLOWS:
.B 2
NUMERIC-TEXT-VALUE
.BR
------------------
.B 1;.LM 5;.NJ;.NF
#**            **
#* GROUPED-ITEM *
** REAL-ITEM    **
#* INTEGER-ITEM *
#**            **
.B 2;.I -5
GROUPED-ITEM
.BR;.I -5
------------
.B 1
SIGN-PART[[GROUPS].]GROUPS
.B 2;.I -5
GROUPS
.I -5
------
.B 1
[DIGITS BLANK]... DIGITS
.index ^^Digit\\
.B 2;.I -5
REAL-ITEM
.I -5
---------
.B 1
.NJ;.NF
           **                                     **
           * [[DIGITS].]DIGITS[^E SIGN-PART DIGITS] *
SIGN-PART **                                      #**
           * ^E SIGN-PART DIGITS                    *
           **                                     **
.B 2;.LM 0;.F;.J
INTEGER-ITEM
.BR
------------
.B 1;.I 10
SIGN-PART DIGITS

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.F;.J
SIGN-PART
.BR
---------
.B 1;.I 5
[BLANK]... [+-] [BLANK]...
.index ^^Sign part\\
.B 1
WHERE '^E' REPRESENTS AN EXPONENT SIGN.  ^THIS ^^CHARACTER\\ MAY BE
ALTERED BY THE USER BY USE OF THE ^^PROCEDURE LOWTEN\\ (SEE ^APPENDIX ^B).
.index ^^LOWTEN\\
.B 1
^A NUMERIC-TEXT-VALUE IS A CHARACTER SEQUENCE SUBJECT TO THE ABOVE RULES.
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 286;.PS 80,80;.PAGE;
.ENDIF FOA
^DE-EDITING PROCEDURES
.index ^^FORMAT statement of FORTRAN\\
.index ^^Conversion from TEXT to numerical value\\
.index ^^De-editing procedures\\
.BR
---------------------
.B 1
^A DE-EDITING PROCEDURE OPERATING ON A GIVEN ^^TEXT\\ REFERENCE ^X
.index ^^TEXT to numerical value conversion\\
.index ^^PICTURE statement of COBOL\\
.index ^^Numerical value, conversion from TEXT\\
.index ^^De-editing procedures\\
OPERATES IN THE FOLLOWING WAY:
.B 1;.LM 4;.I -4
1)##^THE LONGEST NUMERIC ITEM OF THE GIVEN FORM IS LOCATED,
.index ^^Numeric item\\
.index ^^Numeric text values\\
CONTAINED WITHIN ^X AND CONTAINING THE FIRST CHARACTER OF ^X.
^IF NO SUCH ITEM CAN BE FOUND, A RUN TIME ERROR RESULTS.
^NOTE THAT - UNLIKE ^^GETCHAR\\ - ^^GETINT, GETREAL\\ AND ^^GETFRAC\\
ALWAYS STARTS FROM THE BEGINNING OF THE TEXT_!
.B 1;.I -4
2)##^THE NUMERIC ITEM IS INTERPRETED AS A NUMBER.  ^IF IT IS
.index ^^Numeric item\\
.index ^^Numeric text values\\
OUTSIDE THE ACCEPTED RANGE (SEE ^^CHAPTER\\ 2, SECTION 2.5.1)
A RUN TIME ERROR RESULTS.
.B 1;.I -4
3)##^THE POSITION INDICATOR OF ^X IS MADE ONE GREATER THAN THE
LAST CHARACTER OF THE NUMERIC ITEM.
.B 2;.LM 0;.NJ;.NF
****************************************************************
* ^^N.B.  U\\NLESS OTHERWISE STATED, THE DE-EDITING PROCEDURES ARE *
.index ^^De-editing procedures\\
*       ILLUSTRATED IN THE CONTEXT:                            *
*                                                              *
*           ^^T :- COPY("1234.5+7.3E4AB");                       *
*           S :- T.SUB(7,6);                                   *
*           R :- T.SUB(5,2);                                   *
****************************************************************

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
^^INTEGER PROCEDURE GETINT;\\
.index ^^GETINT\\
.BR
-------------------------
.B 1
^LOCATES AN INTEGER-ITEM.
.B 1;.LM 10
^^T.GETINT = 1234
.BR
S.GETINT = 7
.BR
R.GETINT###\\CAUSES A RUN TIME ERROR
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 287;.PS 80,80;.PAGE;
.ENDIF FOA
^^LONG REAL PROCEDURE GETREAL;\\
.index ^^Conversion from numerical value to TEXT\\
.index ^^GETREAL\\
.BR
----------------------------
.B 1
LOCATES A REAL-ITEM
.B 1;.LM 10
^^T.GETREAL#=#1234.5\\
.BR
^^S.GETREAL#=#73000.0
.BR
R.GETREAL#=#0.5\\
.B 3;.LM 0
^^INTEGER PROCEDURE GETFRAC;\\
.index ^^Group markers\\
.index ^^GETFRAC\\
.BR
--------------------------
.B 1
^LOCATES A GROUPED ITEM.  ^IN ITS INTERPRETATION, ANY NUMBER OF SINGLE
.index ^^Grouped item\\
BLANKS AND ONE DECIMAL POINT ARE IGNORED AND THE RESULTING
VALUE IS AN ^^INTEGER.\\
.B 1;.LM 0;.TS 10
^AFTER	^^T := COPY(1 013.42");\\
.B 1
THEN	^^T.GETFRAC#=#101342\\
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 288;.PS 80,80;.PAGE;
.ENDIF FOA
^EDITING PROCEDURES
.index ^^TEXT value, conversion from numerical\\
.index ^^Numerical value to TEXT conversion\\
.index ^^FORMAT statement of FORTRAN\\
.index ^^Editing procedures\\
.BR
------------------
.B 1
^EDITING PROCEDURES IN A GIVEN TEXT REFERENCE ^X CONVERT ARITHMETIC
.index ^^FORMAT statement of FORTRAN\\
VALUES TO NUMERIC ITEMS.  ^AFTER AN EDITING OPERATION,
.index ^^Numeric item\\
.index ^^Numeric text values\\
.index ^^Editing procedures\\
THE NUMERIC ITEM OBTAINED IS RIGHT ADJUSTED IN THE ^^TEXT X\\ PRECEDED BY
.index ^^Numeric item\\
.index ^^Numeric text values\\
PADDING BLANKS.  ^THE FINAL VALUE OF THE POSITION INDICATOR IS ^^X.LENGTH+1.\\
.B 1
^A POSITIVE NUMBER IS EDITED WITH NO SIGN.  ^IF ^^X == NOTEXT\\ THEN
A RUN TIME ERROR RESULTS, OTHERWISE IF ^X IS TOO SHORT TO CONTAIN
THE NUMERIC ITEM, AN EDIT OVERFLOW IS CAUSED (^X IS FILLED
.index ^^Numeric item\\
.index ^^Numeric text values\\
WITH ASTERISKS) AND A WARNING MESSAGE IS GIVEN AT THE END OF
PROGRAM EXECUTION.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^PROCEDURE#PUTINT(I);#INTEGER#I;\\
.index ^^PUTINT\\
.index ^^Fixed field text editing\\
.BR
-------------------------------
.B 1
^^T.PUTINT(VAL)\\ CONVERTS THE VALUE OF THE PARAMETER TO AN INTEGER ITEM
.index ^^INTEGER item\\
OF THE DESIGNATED VALUE.
.B 1
^FOR ^^T.LENGTH#=#10:\\
.B 1
.LM 5;.TS 27
.BR
^^T.PUTINT(-37)	-37
.BR
T.PUTINT(118.8)	119\\
.B 3;.LM 0
^^PROCEDURE#PUTFIX(R,N);#[LONG] REAL#R;#INTEGER#N;\\
.index ^^PUTFIX\\
.BR
------------------------------------------------
.B 1
^^T.PUTFIX(VAL,M)\\ RESULTS IN AN INTEGER-ITEM IF ^M=0, OR A REAL-ITEM
(WITH NO EXPONENT) IF ^M>1 WITH ^M DIGITS AFTER THE DECIMAL
POINT.  ^IT DESIGNATES A NUMBER EQUAL IN VALUE TO ^^VAL\\ ROUNDED TO ^M DECIMAL
PLACES.  ^A RUN TIME ERROR RESULTS IF ^M<0.
.B 1;.LM 5;.TS 27
^^T.PUTFIX(18,0)	#######18
.BR
T.PUTFIX(-1375.4,3)	-1375.400\\
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 289;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE#PUTREAL(R,N);#[LONG] REAL#R;#INTEGER#N;\\
.index ^^PUTREAL\\
.BR
-------------------------------------------------
.B 1
^^T.PUTREAL(VAL,M)\\ RESULTS IN A REAL-ITEM TO ^M SIGNIFICANT PLACES WITH AN EXPONENT
.B 1;.LM 10
^^X.XXXXXXXXE+-XX\\
.index ^^REAL item\\
.index ^^E, exponent sign\\
.BR
^M FIGURES
.B 1;.LM 0
^IF ^M<0, A RUN TIME ERROR RESULTS
.BR
^IF ^M=0, THE EXPONENT IS PRECEDED BY A SIGN-PART
.BR
^IF ^M=1, THE EXPONENT IS PRECEDED BY AN INTEGER-ITEM OF ONE DIGIT.
.B 1;.LM 5
^FOR ^^T.LENGTH\\ = 10:
.B 1;.TS 30
^^T.PUTREAL(16,0)	#####E+01
.BR
T.PUTREAL(-25.32,1)	###-3E+01
.BR
T.PUTREAL(-0.001472,3)	-1.47E-03\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0
^^PROCEDURE PUTFRAC(I,N); INTEGER I,N;
.BR
-------------------------------------
.B 1
^^T.PUTFRAC(VAL,M)\\ RESULTS IN A GROUPED-ITEM
.B 1;.I 10
^^XXX#XXX.XXX#XXX\\
.B 1;.LM 0
^IF ^M=0, THERE IS NO DECIMAL POINT.  ^IF ^M>0, THERE ARE ^M DIGITS
AFTER THE DECIMAL POINT.  ^EACH DIGIT GROUP CONSISTS OF 3 DIGITS
EXCEPT POSSIBLY THE FIRST AND THE LAST.  ^THE NUMERIC ITEM IS AN
EXACT REPRESENTATION OF ^^VAL\\*10(-^M).
.B 1;.I 10;.TS 40
^^T.PUTFRAC(10012416,3)	10#012.416\\
.B 1;.LM 0
^THE EDITING AND DE-EDITING PROCEDURES ARE ORIENTED TOWARDS
.index ^^De-editing procedures\\
"FIXED FIELD" TEXT MANIPULATION.
.B 2
.IF FOA;.NUMBER 290;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE:
.BR
--------
.B 1;.LM 5;.TS 11
.NJ;.NF
^^TEXT TR,TYPE,AMOUNT,PRICE,PAYMENT;
INTEGER PAY,TOTAL;
TR :- BLANKS(80);
	TYPE :- TR.SUB(1,5);
	AMOUNT :- TR.SUB(20,5);
	PRICE :- TR.SUB(30,6);
	PAYMENT :- TR.SUB(60,10);
_..........
IF TYPE = "ORDER" THEN
BEGIN  PAY := AMOUNT.GETINT*PRICE.GETFRAC;
.TS 12
	TOTAL := TOTAL + PAY;
	PAYMENT.PUTFRAC(PAY,2);
END;
_..........\\
.SUBTITLE ^^CHAPTER\\ 3.5
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 291;.PS 80,80;.PAGE;
.ENDIF FOA
3.5##^^THE SYSTEM CLASS BASICIO\\
.index ^^CLASS BASICIO\\
.index ^^Input-output\\
.index ^^File handling\\
.index ^^i/o, see Input-output\\
.index ^^Data set handling\\
.BR
#####------------------------
.B 1
^FILES OR DATA SETS ARE COLLECTIONS OF DATA EXTERNAL TO A PROGRAM.
^THEY MAY BE ORGANISED IN A SEQUENTIAL MANNER (A BATCH
OF CARDS) OR DIRECT ACCESS MANNER (COLLECTION OF ITEMS ON A
.index ^^Sequential file organisation\\
.index ^^File\\
.index ^^External file\\
.index ^^External record\\
.index ^^External data\\
.index ^^BASICIO\\
.index ^^Transput\\
.index ^^File handling\\
DISC WHERE EACH ITEM IS SPECIFIED DIRECTLY).
.B 1
^A FILE IS COMPOSED OF SEVERAL RECORDS EACH OF WHICH IS AN
ORDERED SEQUENCE OF ^^CHARACTERS\\.
.FG 5
^THE INTERNAL REPRESENTATION OF A RECORD IS NATURALLY HELD IN
A ^^TEXT\\ OBJECT, BUT ^^TEXT\\ HANDLING FACILITIES ALONE ARE NOT
.index ^^TEXT\\
ENOUGH FOR TREATING INPUT AND OUTPUT TO SECONDARY STORAGE.
^WE NEED IN ADDITION
.B 1;.LM 4;.I -4
A)##MEANS FOR TYING THE EXTERNAL MEDIUM TO THE INTERNAL REPRESENTATION,
.B 1;.I -4
B)##FOR TRANSFERRING INFORMATION (RECORD-BY-RECORD) EITHER
FROM THE EXTERNAL FILE OR TO THE EXTERNAL FILE, AND
.B 1;.I -4
C)##EITHER INTERPRETING THE INFORMATION IN THE INTERNAL
^^TEXT\\ OBJECT IN A SEQUENTIAL MANNER, OR ELSE FILLING THE
^^TEXT\\ OBJECT IN A SEQUENTIAL MANNER.
.B 1;.LM 0
.IF FOA;.NUMBER 292;.PS 80,80;.PAGE;
.ENDIF FOA
^A ^^SIMULA\\ SYSTEM PROVIDES SYSTEM CLASSES FOR THESE PURPOSES.
^THE SYSTEM CLASSES HAVE THE HIERARCHY
.B 2;.NJ;.NF;.LM 10
   -------FILE---------
.index ^^CLASS FILE\\
.index ^^CLASS FILE\\
^^
   !       !          !
INFILE  OUTFILE   DIRECTFILE
.index ^^OUTFILE\\
.index ^^INFILE\\
.index ^^CLASS OUTFILE\\
.index ^^CLASS INFILE\\
.index ^^CLASS DIRECTFILE\\
           !
       PRINTFILE\\
.index ^^PRINTFILE\\
.index ^^CLASS PRINTFILE\\
.B 2;.LM 0;.F;.J
^THE IDENTIFIER "FILE" IS NOT ACCESSIBLE BY THE USER - IT
DEFINES THE PARTS COMMON TO THE SUBCLASSES.

.IFNOT FOA;.PG
.ENDIF FOA;
^THE FOUR TYPES OF DEFINED FILE ARE:
.B 2;.LM 15;.TS 15;.I -15
^^INFILE\\	A SEQUENTIAL INPUT FILE WHICH TRANSFERS DATA
.index ^^CLASS INFILE\\
FROM AN EXTERNAL FILE TO THE PROGRAM
.B 1;.I -15
^^OUTFILE\\	A SEQUENTIAL OUTPUT FILE WHICH TRANSFERS
DATA FROM THE PROGRAM TO AN EXTERNAL FILE
.B 1;.I -15
^^PRINTFILE\\	(A SUBCLASS OF ^^OUTFILE)\\ A SEQUENTIAL FILE WITH
SPECIAL EXTRA FACILITIES FOR TRANSMITTING INFORMATION TO A LINE
PRINTER OR CONVERSATIONAL TERMINAL
.index ^^Conversational terminal, output to\\
.index ^^TTY terminal, output to\\
.index ^^TTY\\
.B 1;.I -15
^^DIRECTFILE\\	A DIRECT FILE WITH FACILITIES FOR INPUT AND OUTPUT
.index ^^External data\\
.index ^^CLASS DIRECTFILE\\
.B 2;.LM 0;.F;.J
^EACH FILE OBJECT HAS A ^^TEXT\\ PARAMETER CALLED "NAME", WHICH IS NOT
.index ^^File name\\
ACCESSIBLE BY THE USER AFTER CREATION OF THE FILE OBJECT.  ^WHEN THE
FILE OBJECT IS CREATED, THIS PARAMETER SPECIFIES (POSSIBLY TOGETHER
WITH A SPECIFICATION FILE) THE DEVICE, FILENAME ETC. ^EXAMPLE:
.index ^^File name\\
^^"IN#DTA0:#X.Y\\"#OR#"^^OUT#DSK:#X.Q"\\. ^FOR FURTHER INFORMATION SEE
THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ ^LANGUAGE ^HANDBOOK PART ^^II\\.
.B 1
.IF FOA;.NUMBER 293;.PS 80,80;.PAGE;
.ENDIF FOA
^THE ^^CLASS\\ FILE HAS THE DECLARATION:
.B 1;.I 5
^^CLASS\\#FILE(NAME);#^^VALUE\\#NAME;#^^TEXT\\#NAME;
.index ^^File name\\
.BR
.I 5
##################^^VIRTUAL#:#PROCEDURE#OPEN,#CLOSE;\\
.index ^^VIRTUAL attributes of files\\
.index ^^CLOSE\\
.B 1;.LM 5;.NJ;.NF;.TS 12
^^BEGIN	TEXT IMAGE; BOOLEAN\\ OPENED;
.index ^^IMAGE\\
.index ^^Record\\
.index ^^Line\\
.B 1
^^	PROCEDURE SETPOS(I); INTEGER I;
.index ^^SETPOS on file objects\\
.TS 17
	IMAGE.SETPOS(I);
.B 1;.LM 12;.TS 17
INTEGER PROCEDURE POS;
.index ^^Column of input-output line = image.pos\\
	POS := IMAGE.POS;
.B 1
BOOLEAN PROCEDURE MORE;
	MORE := IMAGE.MORE;
.B 1
INTEGER PROCEDURE LENGTH;
.index ^^Linelength\\
	LENGTH := IMAGE.LENGTH;
.index ^^LENGTH of a file image\\
.LM 5;.B 1
END ***\\FILE***

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
^THE VARIABLE ^^IMAGE\\ REFERENCES A ^^TEXT\\ OBJECT VALUE WHICH ACTS
.index ^^IMAGE\\
.index ^^Record\\
.index ^^Line\\
AS A BUFFER CONTAINING THE INFORMATION CURRENTLY BEING PROCESSED.
.index ^^Buffer\\
.B 1
^THE ^^PROCEDURES SETPOS, POS, MORE\\ AND ^^LENGTH\\ DEFINED LOCAL TO
.index ^^Column of input-output line = image.pos\\
.index ^^SETPOS on file objects\\
.index ^^Linelength\\
FILE OPERATE ON THE BUFFER ^^IMAGE.\\  ^GIVEN A REFERENCE ^X TO AN
OBJECT BELONGING TO A SUBCLASS OF FILE, THEN IT IS NOW POSSIBLE
TO WRITE THE MORE CONVENIENT
.B 1;.LM 0;.TS 10,26,44
	^^X.MORE	X.LENGTH	..........\\
.B 1
^INSTEAD OF (THE STILL VALID)
.B 1
	^^X.IMAGE.MORE	X.IMAGE.LENGTH	..........\\
.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 294;.PS 80,80;.PAGE;
.ENDIF FOA
^THE ^^PROCEDURES OPEN\\ AND ^^CLOSE,\\ WHICH ARE SPECIFIED AS ^^VIRTUAL\\
.index ^^VIRTUAL attributes of files\\
.index ^^CLOSE\\
BUT HAVE NO MATCHING DECLARATION AT THE "FILE" LEVEL, COMPLETE
THE DEFINITION OF ^^CLASS\\ FILE.  ^THE MATCHING ^^PROCEDURES\\ DECLARED
IN THE SUBCLASSES OF "FILE" CONFORM TO THE PATTERNS BELOW WITH
POSSIBLE MINOR VARIATIONS DEPENDING UPON THE SUBCLASS.  ^THE VARIATIONS
ARE LISTED IN THE APPROPRIATE FOLLOWING SUB-SECTIONS.
.B 1
^THE ^^PROCEDURE\\ OUTLINES ARE:
.B 1;.LM 5;.TS 12;.NJ;.NF
^^PROCEDURE OPEN(BUF); TEXT BUF;\\
^^BEGIN	IF\\ OPENED ^^THEN\\ ERROR;
^^	IMAGE :- BUF; \\OPENED := ^^TRUE;
END;
.B 1
PROCEDURE CLOSE;
.index ^^CLOSE\\
BEGIN	..........
	IMAGE :- NOTEXT; \\OPENED := ^^FALSE;
END\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
^NO INFORMATION CAN BE PROCESSED THROUGH A "FILE" OBJECT UNTIL
IT HAS NOT ONLY BEEN GENERATED BUT ALSO OPENED.  ^THIS CAN ONLY
BE ACHIEVED BY A CALL ON THE ^^PROCEDURE OPEN\\ WHOSE ACTUAL PARAMETER
IS ASSIGNED TO ^^IMAGE\\ AND ACTS AS THE BUFFER.  ^A CALL ON 
.index ^^IMAGE\\
.index ^^Record\\
.index ^^Line\\
^^OPEN\\ WHEN A "FILE" IS ALREADY OPEN GIVES A RUN TIME ERROR.
.index ^^Run time error\\
.index ^^Open\\
.B 1
^THE ^^PROCEDURE CLOSE\\ CLOSES A FILE AND RELEASES THE BUFFER (BY
.index ^^CLOSE\\
THE ASSIGNMENT ^^IMAGE :- NOTEXT)\\.  ^NO INFORMATION MAY BE TRANSMITTED
.index ^^IMAGE\\
.index ^^Record\\
.index ^^Line in input or output\\
THROUGH A CLOSED "FILE" OBJECT, BUT IT MAY BE OPENED
.index ^^CLOSE\\
AGAIN BY A FURTHER CALL ON ^^OPEN\\.
.B 3;.LM 0;.F;.J
.IF FOA;.NUMBER 295;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS INFILE\\
.index ^^INFILE\\
.index ^^CLASS INFILE\\
.BR
------------
.B 1
FILE ^^CLASS INFILE; VIRTUAL : PROCEDURE INIMAGE;
.index ^^Record oriented input\\
.index ^^VIRTUAL attributes of files\\
.index ^^INIMAGE\\
.index ^^INFILE\\
.index ^^IMAGE\\
.index ^^Record\\
.index ^^Line in input or output\\
.index ^^CLASS INFILE\\
.BR
#####################BOOLEAN PROCEDURE ENDFILE;
.index ^^ENDFILE\\
.index ^^End of file\\
.B 1
.LM 0;.NJ;.NF;.TS 7
BEGIN	PROCEDURE OPEN(BUF); TEXT BUF;.....;
.LM 7
PROCEDURE CLOSE;......;
.index ^^CLOSE\\
BOOLEAN PROCEDURE ENDFILE;.........;
.index ^^ENDFILE\\
.index ^^End of file\\
CHARACTER PROCEDURE INCHAR;........;
.index ^^EDITed input\\
.index ^^Element oriented input\\
.index ^^FORMATted input\\
.index ^^Input, formatted\\
.index ^^INCHAR\\
BOOLEAN PROCEDURE LASTITEM;........;
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
INTEGER PROCEDURE ININT;...........;
.index ^^ININT\\
REAL PROCEDURE INREAL;.............;
.index ^^INREAL\\
INTEGER PROCEDURE INFRAC;..........;
.index ^^INFRAC\\
TEXT PROCEDURE INTEXT(W); INTEGER W;......;
.index ^^TEXT\\
.index ^^INTEXT\\
.LM 0
END ***INFILE***\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.F;.J
^^PROCEDURE OPEN\\
.BR
--------------
.B 1
CONFORMS TO THE PATTERN LISTED WITH ^^CLASS\\ FILE BUT IN ADDITION
POSITIONS THE CURRENT POSITION INDICATOR TO "^^LENGTH+1".\\
.B 3
^^PROCEDURE CLOSE\\
.index ^^CLOSE\\
.BR
---------------
.B 1
CONFORMS TO THE PATTERN LISTED WITH ^^CLASS\\ FILE.
.B 3
^^PROCEDURE ENDFILE\\
.index ^^ENDFILE\\
.index ^^End of file\\
.BR
-----------------
.B 1
RETURNS ^^TRUE\\ BEFORE THE ^^INFILE\\ IS OPENED (BY ^^OPEN\\), IF THE END
OF EXTERNAL FILE MARKER HAS BEEN MET, AND IF THE ^^INFILE\\ HAS
BEEN CLOSED (BY A CALL ON ^^CLOSE\\).
.B 3
^^PROCEDURE INIMAGE\\
.index ^^Record oriented input\\
.index ^^INIMAGE\\
.BR
-----------------
.B 1
TRANSFERS AN EXTERNAL FILE RECORD INTO THE ^^TEXT IMAGE\\.  ^A RUN
.index ^^TEXT\\
.index ^^IMAGE\\
.index ^^input-output, record oriented\\
.index ^^Line in input or output\\
TIME ERROR WILL OCCUR IF THE ^^TEXT\\ OBJECT REFERENCED BY ^^IMAGE\\
.index ^^IMAGE\\
.index ^^Line in input or output\\
IS TOO SHORT TO CONTAIN THE RECORD.  ^IF THE RECORD IS SHORTER
.IF FOA;.NUMBER 296;.PS 80,80;.PAGE;
.ENDIF FOA
THAN ^^IMAGE,\\ IS IS LEFT ADJUSTED AND THE REMAINDER OF ^^IMAGE\\ IS
.index ^^IMAGE\\
.index ^^Line in input or output\\
FILLED WITH BLANKS.  ^FINALLY THE POSITION INDICATOR OF ^^IMAGE\\
.index ^^IMAGE\\
.index ^^Line in input or output\\
IS SET TO 1.  ^WHEN THE LAST RECORD HAS BEEN READ IN, AND ^^INIMAGE\\
IS CALLED AGAIN, A CALL OF ^^ENDFILE\\ WILL RETURN ^^TRUE\\.  ^ANY FURTHER
.index ^^End of file\\
.index ^^ENDFILE\\
CALL ON ^^INIMAGE, INCHAR, INTEXT, ININT, INREAL\\ OR ^^INFRAC\\
.index ^^INTEXT\\
.index ^^INREAL\\
.index ^^INFRAC\\
.index ^^INCHAR\\
WILL RESULT IN A RUN TIME ERROR.
.index ^^Run time error\\
.B 3
^^BOOLEAN PROCEDURE LASTITEM;\\
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
.BR
---------------------------
.B 1
RETURNS ^^FALSE\\ ONLY IF THE EXTERNAL FILE CONTAINS MORE INFORMATION
(NON-BLANK ^^CHARACTERS)\\.  ^IT SCANS PAST ALL BLANK ^^CHARACTERS\\
AND HORIZONTAL TABS
(CALLING ^^INIMAGE\\ IF NEED BE).  ^IF ^^LASTITEM\\ RETURNS ^^FALSE\\ THEN
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
THE CURRENTLY ACCESSIBLE ^^CHARACTER\\ OF ^^IMAGE\\ IS THE FIRST NON-BLANK
.index ^^IMAGE\\
.index ^^Line in input or output\\
^^CHARACTER\\.  ^IF ^^ENDFILE\\ RETURNS ^^TRUE\\, A CALL ON ^^LASTITEM\\
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
.index ^^End of file\\
ALSO RETURNS ^^TRUE\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^CHARACTER PROCEDURE INCHAR\\;
.index ^^INCHAR\\
.BR
---------------------------
.B 1
GIVES ACCESS TO THE NEXT AVAILABLE ^^CHARACTER\\ AND SCANS PAST IT.
^IF ^^IMAGE.MORE\\ IS ^^FALSE\\, THEN ^^INIMAGE\\ IS CALLED ONCE AND THE VALUE
OF THE CALL IS THE FIRST ^^CHARACTER\\ OF THE NEW IMAGE.  ^^INCHAR\\
.index ^^INCHAR\\
.index ^^IMAGE\\
.index ^^Line in input or output\\
GIVES A RUN TIME ERROR IF AN ATTEMPT IS MADE TO READ PAST THE
.index ^^Run time error\\
LAST RECORD IN THE FILE.
.B 3
^^TEXT PROCEDURE INTEXT(W); INTEGER W;\\
.index ^^TEXT\\
.index ^^INTEXT\\
.BR
------------------------------------
.B 1
^^INTEXT(M)\\ CREATES A COPY OF THE NEXT ^^M CHARACTERS \\(WHICH MAY BE
.index ^^INTEXT\\
SPREAD OVER SEVERAL RECORDS) AND RETURNS A REFERENCE TO THIS COPY.
^IF ^M < 0 OR ^M > 2_^18-1 THEN A RUN TIME ERROR RESULTS.  ^A RUN
.index ^^Run time error\\
TIME ERROR WILL ALSO RESULT IF THE FILE DOES NOT CONTAIN ^M MORE
^^CHARACTERS,\\ I.E. AN ATTEMPT IS MADE TO READ PAST THE LAST RECORD.
.B 1
^THE REMAINING ^^PROCEDURES\\ TREAT THE FILE AS A CONTINUOUS STREAM
OF RECORDS.  ^THEY SCAN PAST ANY NUMBER OF BLANKS AND HORIZONTAL TABS (CALLING ^^INIMAGE\\
IF NEED BE) AND THEN DE-EDIT A NUMERIC ITEM LYING IN ONE IMAGE.
^THIS IS DONE BY CALLING ^^LASTITEM\\ (WHICH SCANS PAST THE BLANKS AND TABS)
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
.IF FOA;.NUMBER 297;.PS 80,80;.PAGE;
.ENDIF FOA
AND THEN REFERENCING THE REMAINDER OF THE CURRENT ^^IMAGE\\ BY A
TEMPORARY ^^TEXT\\ VARIABLE, SAY ^T.  ^THE VALUE OF THE "^^IN***"-PROCEDURE\\
.index ^^TEXT\\
CALL IS THE VALUE OF THE CORRESPONDING CALL ON ^^T."GET***".\\
^ON EXIT, THE CURRENT POSITION INDICATOR IS UPDATED TO REFERENCE
PAST THE DE-EDITED FIELD, I.E. TO REFERENCE THE FIRST ^^CHARACTER\\
.index ^^Field\\
WHICH IS NOT A PART OF THE DE-EDITED NUMERIC ITEM.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
E.G.
.B 1;.LM 0;.NJ;.NF
^^
                            T
                           /#_\
        !<-----------------   ----------------->!
\\-------------------------------------------------#########INTERMEDIATE^^
_! ..... !   !   ! 1 ! 2 ! 3 ! . ! 5 ! A ! ..... ! <---IMAGE
.index ^^IMAGE\\
.index ^^Line in input or output\\
\\-------------------------------------------------#############STEP
          _^
          !
       CURRENT
      POSITION
      INDICATOR
.B 2;.LM 0;.RM 70;.F;.J;.C
^^T.GETINT#=#123\\
.B 3
.LM 5;.NJ;.NF
^^
--------------------------------------------------
_! ...... !   !   ! 1 ! 2 ! 3 ! . ! 5 ! A ! ..... !
--------------------------------------------------
                               _^
                               !
\\                            CURRENT
                           POSITION
                           INDICATOR
.B 2;.F;.J;.LM 0;.C
^^ININT#=#123\\
.B 2;.LM 0;.F;.J
^RUN TIME ERRORS WILL RESULT IF THE REMAINING ^^CHARACTERS\\ IN
.index ^^Run time error\\
THE FILE ARE BLANKS (^^LASTITEM#=#TRUE\\) OR IF THE ITEM IS NOT
NUMERIC.
.B 1
^AN OUTLINE OF ^^ININT\\ IS:
.B 1;.LM 5;.NJ;.NF;.TS 13
^^
INTEGER PROCEDURE ININT;
.index ^^Element oriented i/o\\
.index ^^Input-output, element oriented\\
BEGIN TEXT T; IF LASTITEM THEN ERROR;
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
	T :- IMAGE.SUB(POS,LENGTH-POS+1);
	ININT := T.GETINT;
	SETPOS(POS+T.POS-1);
END ***ININT***\\
.B 1;.LM 0;.F;.J
^^INREAL\\ AND ^^INFRAC\\ FOLLOW THE SAME PATTERN.
.index ^^INREAL\\
.index ^^INFRAC\\

.IFNOT FOA;.PG
.ENDIF FOA;
.IF FOA;.NUMBER 298;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS OUTFILE\\
.index ^^OUTFILE\\
.index ^^CLASS OUTFILE\\
.BR
-------------
.B 1;.NJ;.NF
FILE ^^CLASS OUTFILE; VIRTUAL : PROCEDURE OUTIMAGE;
.index ^^Record oriented output\\
.index ^^VIRTUAL attributes of files\\
.index ^^OUTFILE\\
.LM 0;.TS 7
BEGIN	PROCEDURE OPEN(BUF); TEXT BUF;....;
.LM 7
PROCEDURE CLOSE;..................;
.index ^^CLOSE\\
PROCEDURE OUTIMAGE;...............;
PROCEDURE OUTINT(I,W); INTEGER I,W;.....................;
.index ^^EDITed output\\
.index ^^Element oriented output\\
.index ^^FORMATted output\\
.index ^^Output, formatted\\
.index ^^OUTINT\\
PROCEDURE OUTFIX(R,N,W); [LONG] REAL R; INTEGER N,W;....;
.index ^^OUTFIX\\
PROCEDURE OUTREAL(R,N,W); [LONG] REAL R; INTEGER N,W;...;
PROCEDURE OUTFRAC(I,N,W); INTEGER I,N,W;................;
.index ^^OUTFRAC\\
PROCEDURE OUTTEXT(T); VALUE T; TEXT T;..................;
.index ^^TEXT\\
PROCEDURE OUTCHAR(C); CHARACTER C;......................;
.index ^^OUTCHAR\\
.LM 0
END ***OUTFILE***\\
.B 3
.LM 0;.F;.J
^^PROCEDURE#OPEN(BUF);#TEXT#BUF;\\
.F;.J
.BR
------------------------------
.B 1
^FOLLOWS THE PATTERN SET BY THE ^^PROCEDURE OPEN\\ LISTED WITH ^^CLASS\\ FILE.
.B 3
^^PROCEDURE CLOSE;\\
.index ^^CLOSE\\
.BR
----------------
.B 1
^CONFORMS TO THE PATTERN SET BY THE ^^PROCEDURE CLOSE\\ LISTED
WITH ^^CLASS\\ FILE BUT IN ADDITION CHECKS THE VALUE OF ^^POS\\.
.index ^^POS of a file image\\
^IF ^^POS > 1\\ THEN PRESUMABLY EXTRA INFORMATION HAS BEEN COPIED
.index ^^POS of a file image\\
INTO ^^IMAGE \\SINCE THE LAST CALL ON ^^OUTIMAGE\\.
.index ^^IMAGE\\
.index ^^Line in input or output\\
.B 1
^ACCORDINGLY, IF ^^POS > 1, OUTIMAGE\\ WILL BE CALLED ONCE BEFORE
.index ^^POS of a file image\\
THE ^^OUTFILE\\ IS CLOSED.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^PROCEDURE OUTIMAGE;\\
.BR
-------------------
.B 1
^^OUTIMAGE\\ TRANSFERS THE CONTENTS OF ^^IMAGE\\ TO THE EXTERNAL FILE
.index ^^IMAGE\\
.index ^^Line in input or output\\
CREATING A COPY AS A NEW RECORD.  ^^IMAGE\\ IS THEN CLEARED TO
BLANKS AND ITS CURRENT POSITION INDICATOR SET TO ONE.
.B 3
^^PROCEDURE BREAKOUTIMAGE;\\
.index ^^BREAKOUTIMAGE\\
.BR
------------------------
.B 1
^^BREAKOUTIMAGE\\ WORKS EXACTLY AS ^^OUTIMAGE\\ WITH THE ONLY DIFFERENCE
.index ^^BREAKOUTIMAGE\\
THAT NO CARRIAGE RETURN-LINEFEED IS OUTPUT AT THE END OF THE LINE.  ^THUS, THE ^^IMAGE\\
IS CLEARED IN THE SAME WAY AS FOR ^^OUTIMAGE.  BREAKOUTIMAGE\\ IS USEFUL WHEN
WRITING CONVERSATIONAL PROGRAMS, TO ASK A QUESTION AND GET THE ANSWER ON THE SAME LINE.
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
^NOTE THAT ^^BREAKOUTIMAGE\\ WILL OUTPUT ANY TRAILING BLANKS OF THE
IMAGE UP TO ^^POS\\, WHILE ^^OUTIMAGE\\ WILL ALWAYS STRIP OFF THESE BLANKS.
.B 3
.IF FOA;.NUMBER 299;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE OUTTEXT(T); VALUE T; TEXT T;\\
.index ^^TEXT, output of\\
.BR
----------------------------------------
.B 1
^A COPY OF THE ^^CHARACTER\\ SEQUENCE REPRESENTED BY THE ACTUAL
PARAMETER IS EDITED INTO ^^IMAGE\\ FROM THE CURRENT POSITION.
^IF THE REMAINING LENGTH OF ^^IMAGE\\ IS INSUFFICIENT, ^^OUTIMAGE\\ IS
CALLED AND OUTPUT WILL START AT THE
FIRST POSITION OF A FRESH IMAGE. IF ^^T.LENGTH\\ IS GREATER THAN
^^IMAGE.LENGTH\\ THEN A RUN TIME ERROR WILL OCCUR.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^PROCEDURE OUTCHAR(C); CHARACTER C;\\
.index ^^OUTCHAR\\
.BR
----------------------------------
.B 1
^OUTPUTS THE VALUE OF ^C INTO THE CURRENT POSITION OF ^^IMAGE\\
(IF ^^MORE#=#FALSE,\\ THEN ^^OUTIMAGE\\ IS CALLED FIRST).  ^IN EITHER
.index ^^MORE\\
CASE, THE CURRENT POSITION INDICATOR IS THEN INCREMENTED.
.B 1
^THE REMAINING ^^PROCEDURES\\ ARE ALL BASED UPON THE ^^PUT-PROCEDURES\\
LOCAL TO ^^TEXT\\S.  ^THE CORRESPONDING ^^OUT-PROCEDURES\\ ARE AUGMENTED
BY AN EXTRA PARAMETER ^W WHICH SPECIFIES THE FIELD WIDTH.
.index ^^Field\\
.B 2;.LM 0;.NJ;.NF
^^
             -------------------------------------
             !/////////!         !     !         !
IMAGE .----->!/////////!         !     !         !
             !/////////!         !  _^  !         !
             -----------------------!-------------
                                    !
              !       ! !       !   !
              --------- ---------   !
                                    !
                                     F\\INAL POSITION OF CURRENT
               PORTION    ^^FIELD\\      POSITION INDICATOR
.index ^^Field\\
              OF ^^IMAGE\\
               ALREADY
                FILLED
.B 2;.LM 0;.F;.J
^THE EDITING ^^PROCEDURE\\ COMMENCES BY ESTABLISHING A TEMPORARY
^^TEXT\\ REFERENCE (^^FIELD\\) TO THE NEXT SEQUENCE OF ^^W CHARACTERS\\
.index ^^Field\\
LYING IN ONE ^^IMAGE\\.  ^IF THE CURRENT ^^IMAGE\\ HAS NOT ENOUGH SPACE LEFT,
^^OUTIMAGE\\ IS CALLED.  ^THEN THE VALUE IS EDITED BY CALLING
^^FIELD."PUT***"\\ WHERE "^^PUT***\\" IS THE ^^PUT-PROCEDURE\\ CORRESPONDING
.index ^^Field\\
TO THE ^^OUT-PROCEDURE\\.  ^FINALLY THE CURRENT POSITION
INDICATOR IS INCREASED BY ^W TO REFERENCE - PAST THE
.index ^^Field\\
JUST-EDITED FIELD.
.index ^^Field\\
.B 2;.LM 5;.TS 10
.NJ;.NF
.IF FOA;.NUMBER 300;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE OUTINT(I,W); INTEGER I,W;
.index ^^OUTINT\\
	FIELD(W).PUTINT(I);
.B 1
PROCEDURE OUTFRAC(I,N,W); INTEGER I,N,W;
.index ^^OUTFRAC\\
	FIELD(W).PUTFRAC(I,N);
.B 1
PROCEDURE OUTREAL(P,N,W); [LONG] REAL P; INTEGER N,W;
.index ^^PUTREAL\\
.index ^^OUTREAL\\
	FIELD(W).PUTREAL(P,N);
.B 1
PROCEDURE OUTFIX(P,M,W); [LONG] REAL P; INTEGER M,W;
.index ^^OUTFIX\\
	FIELD(W).PUTFIX(P,M);\\
.index ^^PUTFIX\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 301;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS PRINTFILE\\
.index ^^PRINTFILE\\
.index ^^CLASS PRINTFILE\\
.index ^^PRINTFILE\\
.BR
---------------
.B 1
.LM 5;.TS 12
.NJ;.NF
^^OUTFILE CLASS PRINTFILE;
.index ^^PRINTFILE\\
BEGIN	PROCEDURE OPEN(BUF); TEXT BUF;...............;
.LM 12
PROCEDURE CLOSE;.....;
.index ^^CLOSE\\
PROCEDURE LINESPERPAGE(N); INTEGER N;........;
.index ^^LINESPERPAGE\\
INTEGER PROCEDURE LINE(N); INTEGER N;........;
PROCEDURE SPACING(N); INTEGER N;.............;
.index ^^SPACING\\
PROCEDURE EJECT(N); INTEGER N;...............;
.index ^^EJECT\\
PROCEDURE OUTIMAGE;..........................;
.LM 5
END ***PRINTFILE\\***
.B 2;.LM 0;.F;.J
^^CLASS PRINTFILE\\ FURTHER ORIENTS THE PREFIXING ^^CLASS OUTFILE\\
.index ^^PRINTFILE\\
TOWARDS CONVERSATIONAL TERMINAL (^^TTY:)\\ OR LINE PRINTER OUTPUT.  ^THE ^^PROCEDURES OPEN\\ AND ^^CLOSE\\
.index ^^Video terminal, output to\\
.index ^^Display terminal, output to\\
.index ^^CRT terminal, output to\\
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
.index ^^Line printer\\
TAKE THE PATTERN OF THOSE LOCAL TO ^^OUTFILE\\ BUT IN ADDITION
^^OPEN\\ POSITIONS TO THE TOP OF THE NEXT PAGE.
.B 3
^^PROCEDURE LINESPERPAGE(N); INTEGER N;\\
.index ^^LINESPERPAGE\\
.BR
-------------------------------------
.B 1
^INITIALLY THE NUMBER OF PRINTABLE LINES PER PAGE IS FIXED AT
SOME VALUE (^V) DEPENDENT UPON THE INSTALLATION.  ^A CALL
^^LINESPERPAGE(M)\\ WILL ALTER THIS FIGURE TO ALLOW ONLY ^M PRINTABLE
.index ^^LINESPERPAGE\\
LINES PER PAGE.  ^IF ^M = -1 THEN NO AUTOMATIC PAGE SKIPS WILL OCCUR.
^THIS IS RECOMMENDED FOR DISPLAY TERMINAL OUTPUT.
.B 3
^^PROCEDURE SPACING(N); INTEGER N;\\
.index ^^SPACING\\
.BR
--------------------------------
.B 1
^INITIALLY THE SPACING IS 1 AND SUCCESSIVE IMAGES ARE PRINTED
.index ^^SPACING\\
ON SUCCESSIVE LINES.  ^A CALL ^^SPACING(M)\\ WILL ALTER THIS TO
SEPARATE SUCCESSIVE LINES BY ^M-1 BLANK LINES.  ^THIS BECOMES
EFFECTIVE AFTER THE NEXT CALL ON ^^OUTIMAGE\\.  ^IF ^M > "CURRENT
VALUE OF LINES PER PAGE", OR ^M < 0, THEN A RUN TIME ERROR
.index ^^Run time error\\
RESULTS.  ^IF ^M = 0, OVERPRINTING WILL OCCUR - SUCCESSIVE IMAGES
BEING PRINTED ON THE SAME PHYSICAL LINE.
.B 3
.IF FOA;.NUMBER 302;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROCEDURE EJECT(N); INTEGER N;\\
.index ^^EJECT\\
.index ^^SKIP PAGE, see EJECT\\
.BR
------------------------------
.B 1
^THIS ^^PROCEDURE\\ SKIPS TO A CERTAIN LINE ON THE PAGE - (IT AVOIDS
CALLING ^^OUTIMAGE\\ SEVERAL TIMES).  ^^EJECT(L)\\ WILL POSITION TO LINE
.index ^^EJECT\\
 \ ON THIS PAGE IF THIS IS FURTHER DOWN THE CURRENT PAGE (IF
^^L > LINE\\), OR ELSE SKIP TO ^^LINE L\\ OF THE NEXT PAGE IF ^^L <= LINE\\.
.B 1
^A RUN TIME ERROR OCCURS IF ^L <= 0.  ^IF ^L > ^^LINESPERPAGE, EJECT(L)\\
.index ^^Run time error\\
.index ^^LINESPERPAGE\\
IS EQUIVALENT TO ^^EJECT(1).\\
.index ^^EJECT\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^INTEGER PROCEDURE LINE;\\
.BR
-----------------------
.B 1
^THIS ^^PROCEDURE\\ RETURNS THE ^^INTEGER\\ VALUE OF THE LINE NUMBER
WHICH INDICATES THE NEXT LINE TO BE PRINTED.  ^THUS ^^EJECT(LINE+3)\\
.index ^^EJECT\\
WILL SKIP THREE LINES AND NOT ALTER SPACING.  ^AFTER EACH CALL ON
^^OUTIMAGE\\, THE LINE NUMBER IS INCREMENTED BY THE CURRENT SPACING.
.index ^^SPACING\\
.B 3
^^PROCEDURE OUTIMAGE\\;
.BR
-------------------
.B 1
^THIS ^^PROCEDURE\\ ACTS LIKE THE ^^OUTIMAGE\\ OF ^^OUTFILE\\ BUT IN
ADDITION INCREMENTS THE LINE NUMBER BY SPACING, AND WILL
POSITION TO THE TOP OF THE NEXT PAGE IF THE CURRENT PAGE IS FILLED.
.B 2
.IF FOA;.NUMBER 303;.PS 80,80;.PAGE;
.ENDIF FOA
^EXAMPLE:
.BR
--------
.B 1
^THIS EXAMPLE SHOWS THE USE OF THREE TYPES OF FILE AND HOW TO
OPEN AND CLOSE THEM.  ^THE EXAMPLE WAS CHOSEN TO DEMONSTRATE
THESE FEATURES AND HOW FORMATTING IS AVAILABLE BY USE OF THE
SUB-TEXT CONCEPT.  ^THE LOGIC OF THE EXAMPLE IS PARTICULARLY
SIMPLE.  ^A FILE OF TRANSACTIONS HAS BEEN PUNCHED ON CARDS IN
THE FORMAT
.B 2
.LM 0;.TS 5,15,45;.NJ;.NF
COL	1-5	CUSTOMER NUMBER	^^CNO\\
COL	7-16	SUM OF DEBIT TRANSACTIONS	^^DB\\
COL 19-28	SUM OF CREDIT TRANSACTIONS	^^CR\\
.B 2;.LM 0;.F;.J
^EACH TRANSACTION IS ON A FRESH CARD.  ^THE INFORMATION IS TO
BE COMPRESSED AND RECORDED ON A NEW SEQUENTIAL FILE ON TAPE.
^THE LENGTH OF EACH TAPE RECORD IS ^^15 CHARACTERS,\\ AND ITS FORMAT IS:
.B 2;.LM 10;.NJ;.NF
     5           10
*************************
*   ^^CNR   *   CR - DB   *\\
*************************
.B 1
CUSTOMER   TOTAL SUM OF
 NUMBER    TRANSACTIONS
.B 2;.LM 0;.F;.J
^CHECKS ARE MADE THAT THE CUSTOMER NUMBER IS VALID (1-3-7 DIGIT CHECK)
AND THAT THE CARD IS VALIDLY PUNCHED.  ^IF NOT, A COPY OF THE CARD
IS PRINTED ON A LINE PRINTER, AND THE SCAN CONTINUES.
.index ^^Line printer\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^NOTE THAT THE ^^INFILE\\ AND ^^PRINTFILE\\ SHARE THE SAME BUFFER.
.B 2;.LM 0;.NJ;.NF
.IF FOA;.NUMBER 304;.PS 80,80;.PAGE;
.ENDIF FOA
^^
                                     *******
                                    *      *
                              -----* CARDS *
                              !    *       *
                              !    *********
                              !
                              !
       ***********************************************
       *       *                                     *
BUFFER *       *               CUSTOMER              *
       *       *                                     *
       ***********************************************
                         !            !
                         !            !
                  --------            --------
                  !                          !
                  !                          !
             ***********                 ***********
             *         *                 *         *
NCUSTOMER.   *         *                 * PRINTER *
   IMAGE     *         *                 *        *
             ***********                 * * * * *
                  !                       * * * *

                  !
             ------
             !
             !
          ****** 
         *      *
        *  TAPE  *
         *      *
          ****** \\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.F;.J
.LM 0;.NJ;.NF;.TS 7,12
.IF FOA;.NUMBER 305;.PS 80,80;.PAGE;
.ENDIF FOA
.nofill;.uc
BEGIN
    EXTERNAL INTEGER PROCEDURE checkint;
    TEXT cnr, db, cr, nr, t1, t2, t3, t4, kt, tsum,
    ts, buffer, err;
    INTEGER sum, balance;
    REF(Infile) customercards;
    REF(Printfile) print;
    REF(Outfile) ncustomer;
.skip
    BOOLEAN PROCEDURE nonnumeric(t); TEXT t;
    COMMENT ***THIS PROCEDURE RETURNS TRUE IF THE TEXT
    PARAMETER CAN NOT BE NUMERICALLY INTER-
    PRETED FROM THE LEFT*** ;
    BEGIN
        t.Setpos(1);
        nonnumeric:= checkint(t) NE 1;
    END;
.skip
    buffer :- Blanks(132);
    COMMENT ***CONSTRUCT THE CARDFILE*** ;
    customercards :- NEW Infile("CCARD DSK: CCARD.CDR");
    customercards.Open(buffer.Sub(10,80));
    cnr :- buffer.Sub(10,5);
    nr :- cnr.Sub(1,4);
    t1 :- nr.Sub(1,1);
    t2 :- nr.Sub(2,1);
    t3 :- nr.Sub(3,1);
    t4 :- nr.Sub(4,1);
    kt :- cnr.Sub(5,1);
    db :- buffer.Sub(16,10);
    cr :- buffer.Sub(28,10);
.skip
    COMMENT ***CONSTRUCT PRINTFILE*** ;
    print :- NEW Printfile("PRINT LPT:");
    print.Open(buffer);
    err:- buffer.Sub(1,6);
.skip
    COMMENT ***CONSTRUCT TAPEFILE*** ;
    ncustomer :- NEW Outfile("NCUSTOMER MTA:");
    ncustomer.Open(Blanks(15));
.skip
    COMMENT ***CONSTRUCT WORKING TEXT TSUM*** ;
    tsum :- Blanks(3);
    ts :- tsum.Sub(3,1);
.page
    INSPECT ncustomer DO
    BEGIN
        customercards.Inimage;
        WHILE NOT customercards.Endfile DO
        BEGIN IF nonnumeric(cnr) OR
            nonnumeric(db) OR
            nonnumeric(cr)
            THEN error:
            BEGIN err:= "ERROR"; print.Outimage
            END ELSE
            BEGIN COMMENT ***137 DIGIT CHECK*** ;
                sum := 7*(t1.Getint + t4.Getint) +
                3*t3.Getint + t2.Getint;
                tsum.Putint(sum);
                IF ts NE kt THEN GOTO error;
.skip
                COMMENT ***OUTPUT TO TAPE*** ;
                balance := cr.Getint - db.Getint;
                Outtext(cnr);
                Outint(balance,10);
                Outimage;
            END;
            customercards.Inimage;
        END;
    END ***INSPECT NCUSTOMER*** ;
.skip
    slutt: customercards.Close;
    ncustomer.Close;
    print.Close
END
.IFNOT FOA;.PG;
.ENDIF FOA;.B 2
.IF FOA;.NUMBER 308;.PS 80,80;.PAGE;
.ENDIF FOA
^^CLASS DIRECTFILE
.index ^^Direct access file\\
.index ^^DIRECTFILE\\
.index ^^CLASS DIRECTFILE\\
----------------
.B 1
\\FILE ^^CLASS DIRECTFILE;
#####VIRTUAL: PROCEDURE LOCATE, ENDFILE, INIMAGE, OUTIMAGE;
.index ^^VIRTUAL attributes of files\\
.index ^^Random access to disk file records\\
.index ^^File handling, direct random access\\
.index ^^LOCATE\\
.TS 7
BEGIN	PROCEDURE OPEN(BUF); TEXT BUF;  . . . . . . . . . . . . ;
.LM 7
PROCEDURE CLOSE;  . . . . . . . . . . . . . . . . . . . ;
.index ^^CLOSE\\
INTEGER PROCEDURE LOCATION; . . . . . . . . . . . . . . ;
.index ^^Location\\
PROCEDURE LOCATE(I); INTEGER I; . . . . . . . . . . . . ;
.index ^^LOCATE\\
.index ^^Direct access file\\
BOOLEAN PROCEDURE ENDFILE;  . . . . . . . . . . . . . . ;
PROCEDURE INIMAGE; . . . . . . . . . . . . . . . . . . .;
.index ^^INIMAGE\\
CHARACTER PROCEDURE INCHAR; . . . . . . . . . . . . . . ;
.index ^^INCHAR\\
BOOLEAN PROCEDURE LASTITEM; . . . . . . . . . . . . . . ;
.index ^^End of file condition: procedure LASTITEM\\
.index ^^LASTITEM\\
INTEGER PROCEDURE ININT; . . . . . . . . . . . . . . . .;
REAL PROCEDURE INREAL; . . . . . . . . . . . . . . . . .;
.index ^^INREAL\\
INTEGER PROCEDURE INFRAC; . . . . . . . . . . . . . . . ;
.index ^^INFRAC\\
TEXT PROCEDURE INTEXT(W); INTEGER W; . . . . . . . . . .;
.index ^^INTEXT\\
PROCEDURE OUTIMAGE; . . . . . . . . . . . . . . . . . . ;
PROCEDURE OUTCHAR(C); CHARACTER C; . . . . . . . . . . .;
.index ^^OUTCHAR\\
PROCEDURE OUTINT(I,W); INTEGER I,W; . . . . . . . . . . ;
.index ^^OUTINT\\
PROCEDURE OUTFIX(R,N,W); [LONG] REAL R; INTEGER N,W;. . ;
.index ^^OUTFIX\\
PROCEDURE OUTREAL(R,N,W); [LONG] REAL R; INTEGER M,W;. .;
.index ^^OUTREAL\\
PROCEDURE OUTFRAC(I,N,W); INTEGER I,N,W; . . . . . . . .;
.index ^^OUTFRAC\\
.index ^^OUTFRAC\\
PROCEDURE OUTTEXT(T); VALUE T; TEXT T; . . . . . . . . .;
.LM 0
END ***DIRECTFILE***\\
.LM 0;.F;.J;.B 2
.IF FOA;.NUMBER 309;.PS 80,80;.PAGE;
.ENDIF FOA
^A DIRECTFILE REPRESENTS AN EXTERNAL FILE IN WHICH INDIVIDUAL
.index ^^Direct access file\\
.index ^^DIRECTFILE\\
RECORDS ARE ADDRESSED BY INDICES (ORDINAL NUMBERS).  ^THE INDEX
OF THE CURRENT RECORD IS RETURNED BY A CALL ON ^^LOCATION\\.  ^THE
.index ^^Location\\
CURRENT RECORD MAY BE COPIED INTO THE PROGRAM BY A CALL ON ^^INIMAGE\\,
OR OVERWRITTEN BY A CALL ON ^^OUTIMAGE\\.  ^IN EITHER CASE, THE SEQUENTIALLY
NEXT RECORD IS THEN TAKEN AS THE CURRENT RECORD.  ^THIS
SEQUENTIAL ACCESSING MAY BE ALTERED AT ANY TIME A CALL ^^LOCATE(M)\\
.index ^^LOCATE\\
WHICH WILL LOCATE THE ^MTH EXTERNAL RECORD AND MAKE IT THE NEW CURRENT RECORD.
.B 1
^IF ^M <= 0 AND ^^OUTIMAGE\\ IS CALLED, THEN A RUN TIME ERROR WILL OCCUR.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
^^PROCEDURE OPEN\\
.BR
--------------
.B 1
CONFORMS TO THE PATTERN OF ^^OPEN\\ IN ^^CLASS\\ FILE BUT IN ADDITION
LOCATES THE FIRST RECORD.
.index ^^LOCATE\\
.B 3
^^PROCEDURE CLOSE\\
.index ^^CLOSE\\
.BR
---------------
.B 1
CONFORMS TO THE PATTERN OF ^^CLOSE\\ IN ^^CLASS\\ FILE.
.B 3
^^PROCEDURE ENDFILE\\
.BR
-----------------
.B 1
IS ^^FALSE\\ IF THE CURRENT INDEX LOCATES A RECORD IN THE FILE.
.index ^^LOCATE\\
.B 1
^CALLS ON THE ^^PROCEDURE INIMAGE\\ WILL CAUSE RUN
A TIME ERROR IF ^^ENDFILE\\ IS ^^TRUE\\. ^OTHERWISE ^^INIMAGE (\\AND ^^OUTIMAGE)\\
CONFORM TO THESE
OF THE SAME IDENTIFIERS IN ^^INFILE\\ AND ^^OUTFILE\\ BUT IN ADDITION
INCREMENT THE INDEX OF THE CURRENT RECORD BY ONE.
.B 1
^THE REMAINING ^^PROCEDURES\\ ARE ANALOGOUS TO THE CORRESPONDING
^^PROCEDURES\\ OF ^^INFILE\\ AND ^^OUTFILE\\.
.B 1
^A MORE COMPLETE DESCRIPTION OF ^^DIRECTFILE\\ IS GIVEN IN  ^^DEC\\SYSTEM-10 ^^SIMULA L\\ANGUAGE ^HANDBOOK ^PART ^I^I.
.B 3
.IF FOA;.NUMBER 310;.PS 80,80;.PAGE;
.ENDIF FOA
.PAGE
^^CLASS BASICIO\\
.BR
-------------
.B 1
^THE SYSTEM DEFINED FILE FACILITIES ARE GROUPED TOGETHER IN
THE ^^CLASS BASICIO\\ WHOSE SKELETON READS:
.B 1;.LM 0;.NJ;.NF;.TS 7
^^CLASS BASICIO(\\SYSINLENGTH,SYSOUTLENGTH^^);
INTEGER \\SYSINLENGTH,SYSOUTLENGTH^^;
BEGIN	CLASS \\FILE. .  .  .  .  .  .  ;
.LM 7
FILE ^^CLASS INFILE. .  .  .  . ;
.index ^^INFILE\\
\\FILE^^ CLASS OUTFILE. .  .  .  .;
\\FILE ^^CLASS DIRECTFILE. .  .  .;
OUTFILE CLASS PRINTFILE. .  . ;
.index ^^PRINTFILE\\
REF(INFILE)\\SYSIN;
.index ^^SYSIN\\
^^REF(PRINTFILE)\\SYSOUT;^^
.index ^^SYSOUT\\
REF(INFILE) PROCEDURE SYSIN; SYSIN :-\\ SYSIN;
.index ^^SYSIN\\
^^REF(PRINTFILE) PROCEDURE SYSOUT; SYSOUT :- \\SYSOUT;
SYSIN :- ^^NEW INFILE("SYSIN");
.index ^^SYSIN\\
\\SYSIN.^^OPEN(BLANKS(\\SYSINLENGTH));###^SEE NOTE 1)
.index ^^SYSIN\\
\\SYSOUT :- ^^NEW PRINTFILE("SYSOUT");
\\SYSOUT.^^OPEN(BLANKS\\(SYSOUTLENGTH));###^SEE NOTE 1)
^^INNER;
.index ^^INNER, use in BASICIO\\
\\SYSIN.^^CLOSE;\\ SYSOUT.^^CLOSE;
.index ^^SYSOUT\\
.LM 0
END ***BASICIO\\***
.FOOTNOTE 15
1) ^THE IMAGE SIZES OF ^^SYSIN \\AND ^^SYSOUT\\ DEPEND ON THE DEVICE.  ^IF THE
.index ^^SYSIN, IMAGE size\\
.index ^^Input from TTY, IMAGE size (Line length)\\
.index ^^IMAGE size for SYSIN and SYSOUT\\
.index ^^Linelength, default value for SYSIN and SYSOUT\\
.index ^^Length of input lines, SYSIN from TTY\\
.index ^^Length of output lines, SYSOUT to TTY\\
.index ^^TTY WIDTH\\
.index ^^WIDTH of TTY\\
.index ^^SYSIN\\
DEVICE IS A CONVERSATIONAL TERMINAL WITH A KNOWN LINELINGTH, THEN
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
THE IMAGE SIZE IS THE LINELENGTH OF THE DEVICE.  ^IF THE DEVICE IS
NOT A CONVERSATIONAL TERMINAL OR HAS NO KNOWN LINELENGTH, THEN
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
THE IMAGE SIZE IS 80 FOR ^^SYSIN\\ AND 132 FOR ^^SYSOUT\\.  ^NOTE HOWEVER
.index ^^SYSOUT\\
.index ^^SYSIN\\
THAT IS IS VERY EASY FOR A PROGRAMMER TO CHANGE THIS BY WRITING
E.G. "SYSIN.IMAGE:-BLANKS(200);" OR "SYSOUT.IMAGE:-BLANKS(600);"
IN HIS SOURCE PROGRAM.  ^^A SIMULA\\ PROGRAM WILL NOT BE ABLE TO
ACCEPT LONGER INPUT OR PRODUCE LONGER OUTPUT LINES ON ^^SYSIN\\ AND
.index ^^SYSIN\\
^^SYSOUT\\.  ^A LARGE IMAGESIZE WILL THUS ALLOW LONGER LINES BUT
WILL GIVE MORE EXPENSIVE CALLS TO INIMAGE AND OUTIMAGE.
.END FOOTNOTE
.skip
.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.F;.J
.IF FOA;.NUMBER 312;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1
^^BASICIO\\ CONTAINS ACTIONS TO GENERATE AN ^^INFILE, SYSIN\\, AND A ^^PRINTFILE,\\
^^SYSOUT\\.  ^FOR A CONVERSATIONAL JOB, THE DEFAULT IS THAT ^^SYSIN\\ AND ^^SYSOUT\\
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
.index ^^SYSOUT\\
.index ^^SYSIN\\
BOTH REFER TO THE CONVERSATIONAL TERMINAL.  ^FOR A BATCH JOB, THE DEFAULT
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
IS THAT ^^SYSIN\\ REFERS TO THE CONTROL FILE, ^^SYSOUT\\ TO THE BATCH JOB LOG.
.index ^^SYSIN\\
^THIS CAN BE CHANGED BY THE PROGRAMMER, E.G. TO MAKE ^^SYSIN\\ REFER TO A
DISK FILE, A CARD READER OR A MAGNETIC TAPE AND TO MAKE ^^SYSOUT\\ REFER
.index ^^Card reader\\
TO A DISK FILE OR THE LINE PRINTER.  ^FOR MORE INFORMATION ABOUT THIS,
.index ^^Line printer\\
SEE THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ ^LANGUAGE ^HANDBOOK PART ^^II.\\
.B 1
^^SYSIN\\ AND ^^SYSOUT\\ ARE ACCESSIBLE ONLY THROUGH ^^PROCEDURES\\ WHICH COPY
.index ^^SYSOUT\\
THE VALUES OF CERTAIN IDENTIFIERS (SYSIN, SYSOUT) WHICH ARE
OTHERWISE NOT ACCESSIBLE BY THE USER.
.B 1
^A USER'S PROGRAM BEHAVES AS THOUGH IT IS ENCLOSED AS FOLLOWS:
.B 1
.LM 0;.NJ;.NF
.TS 14,21
^^BASICIO(80,80)
.BR
	BEGIN	INSPECT SYSIN DO
.index ^^SYSIN\\
		INSPECT SYSOUT DO
.index ^^SYSOUT\\
		####\\<PROGRAM>
	^^END\\;
.B 1;.LM 0;.F;.J
^WHEN A USER PROGRAM BEGINS THE SYSTEM AUTOMATICALLY GENERATES
TWO FILES - ONE ^^INFILE\\ FOR INPUT REFERENCED BY ^^SYSIN\\, AND
.index ^^SYSIN\\
ONE FOR OUTPUT REFERENCED BY ^^SYSOUT\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.NJ;.NF
^^
SYSIN .---                    ----------INIMAGE-----
.index ^^SYSIN\\
         !                    !                    !
         V                    V                    !
    -----------        ------------                !
    ! IMAGE .-!------->!          !                !
    ! ININT   !        ------------                !
    ! INREAL  !                                    !
.index ^^INREAL\\
    ! INTEXT  !                                    !
.index ^^INTEXT\\
    ! INIMAGE !                                    !
    -----------                              -------------
                                             !           !
                                             !  -------  !
                                             ! !       ! !
                             \\CONVERSATIONAL  ! !       ! !
.index ^^TTY terminal\\
.index ^^Conversational terminal, output to\\
.index ^^TTY\\
                                   TERMINAL^^  ! !       ! !
.index ^^Conversational terminal\\
                                             ! !       ! !
                                             !  -------  !
                                             !           !
                                             -------------
                                                   _^
                                                   !
                                                   !
SYSOUT .---                                        !
.index ^^SYSOUT\\
          !                                        !
          V                                        !
    -------------            ---------------
    ! IMAGE .---!----------->!             !       !
    ! OUTINT    !            ---------------       !
.index ^^OUTINT\\
    ! OUTREAL   !                  !               !
.index ^^OUTREAL\\
    ! OUTTEXT   !                  !               !
    ! OUTIMAGE  !                  ----OUTIMAGE-----
    ! EJECT     !
    ! . .. .. . !
    -------------\\
.B 2;.LM 0;.F;.J
.IF FOA;.NUMBER 311;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
.IF FOA;.NUMBER 313;.PS 80,80;.PAGE;
.ENDIF FOA
^WHEN THE ACTIONS OF THE USER DEFINED PROGRAM ARE EXHAUSTED,
CONTROL RETURNS TO THE PREFIX LEVEL OF THE ^^BASICIO\\ OBJECT AND
CONTINUES AFTER THE ^^INNER\\.  ^THE FOLLOWING TWO STATEMENTS
.index ^^INNER, use in BASICIO\\
CLOSE THE TWO SYSTEM GENERATED FILES.
.index ^^CLOSE\\
.B 1
^THE INSPECT STATEMENTS ENCLOSING THE PROGRAM ALLOW THE USER TO
WRITE ^^ININT, INIMAGE,.....\\ INSTEAD OF ^^SYSIN.ININT,\\
^^SYSIN.INIMAGE\\ AND ^^OUTREAL, OUTIMAGE,....\\ INSTEAD OF ^^SYSOUT.OUTREAL\\,
.index ^^SYSOUT\\
^^SYSOUT.OUTIMAGE.\\  ^THERE ARE ATTRIBUTE NAME CLASHES
.B 1;.LM 10;.TS 20
^^OPEN\\	WHICH SHOULD NEVER BE USED FOR
.BR
^^CLOSE\\	^^SYSIN\\ OR ^^SYSOUT\\
.B 1
^^IMAGE
.BR
SETPOS
.index ^^SETPOS on file objects\\
.BR
POS
.BR
MORE
.BR
LENGTH\\
.B 2;.LM 0;.F;.J
^WHEN THESE OCCUR THEY ARE NATURALLY BOUND TO ^^SYSOUT\\ AND THE CORRESPONDING ATTRIBUTES
.index ^^SYSOUT\\
OF ^^SYSIN\\ MAY BE OBTAINED BY WRITING ^^SYSIN.SETPOS, SYSIN.IMAGE\\ ET.  ^ALTERNATIVELY,
.index ^^SETPOS on file objects\\
AN INPUT SECTION MAY BE WRITTEN AS
.B 1;.LM 1;.TS 10
^^INSPECT SYSIN DO
.BR
BEGIN\\
.B 1
	INPUT - IN THIS BLOCK OCCURRENCES ^^IMAGE,\\
.BR
	^^SETPOS, POS, MORE\\ AND LENGTH\\ ARE BOUND TO ^^SYSIN\\
.index ^^SETPOS on file objects\\
.BR
^^END\\;


.ST ^^CHAPTER#4\\

.IFNOT FOA;.PG
.ENDIF FOA;
.LM 0;.F;.J
.C
^^CHAPTER 4: SEPARATE COMPILATION\\
.BR;.C
-------------------------------
.SUBTITLE ^^CHAPTER\\ 4.1
.B 3
.IF FOA;.NUMBER 314;.PS 80,80;.PAGE;
.ENDIF FOA
4.1##^WHY SEPARATE COMPILATION?
.BR
#####-------------------------
.B 1
^THERE ARE BASICALLY TWO REASONS FOR SEPARATE COMPILATION:
.B 1;.LM 4;.I -4
1)##^WHEN SEVERAL PROGRAMMERS ARE WORKING ON A LARGE PROGRAM PRODUCT,
THEN THERE IS A NEED FOR DIVIDING THAT LARGE PROGRAM PRODUCT INTO MODULES SO THAT:
.index ^^Separate compilation\\
.index ^^Segmentation into separately compiled modules\\
.index ^^Part-compilation\\
.B 1;.LM 8;.I -4
A)##^THESE MODULES CAN BE COMPILED AND TESTED SEPARATELY.
.B 1;.I -4
B)##^THERE IS A DEFINED INTERFACE BETWEEN THE MODULES AND
AUTOMATIC CHECKING THAT THE MODULES DO NOT COMMUNICATE
OUTSIDE THIS DEFINED INTERFACE.
.B 1;.LM4;.I -4
2)##^FOR A LARGE COMPUTER PROGRAM, THE COMPILATION TIME CAN BE
SHORTENED WITH SEPARATE COMPILATION.  ^THIS WILL LOWER COSTS
AND ALSO LOWER TURN-AROUND TIMES.  ^THE LATTER IS ESPECIFALLY
IMPORTANT ON CONVERSATIONAL TIME-SHARING COMPUTERS, WHERE
FAST TURN-AROUND IS NATURAL AND EXPECTED.
.B 3;.LM 0
.SUBTITLE ^^CHAPTER\\ 4.2
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J;.SP 1;.PS 58,70
.IF FOA;.NUMBER 315;.PS 80,80;.PAGE;
.ENDIF FOA
4.2##^G\\OOD AND BAD SEPARATE COMPILATION
.BR
#####---------------------------------
.B 1
^THE TWO MAIN REQUIREMENTS OF A GOOD SYSTEM FOR SEPARATE COMPILATION
ARE SECURITY AND EFFICIENCY.
.index ^^Security although separate compilation\\
.B 1
^BY SECURITY IS MEANT THAT THE COMPILER SHOULD PROVIDE ERROR CHECKING
AS THOROUGH AS IF THE MODULES HAD BEEN COMPILED AS ONE LARGE PROGRAM.
^ESPECIALLY IMPORTANT IS CHECKING THE TYPE AND STRUCTURE OF DATA
WHICH IS TRANSFERRED BETWEEN SEPARATELY COMPILED MODULES.  ^THIS
INTERFACE BETWEEN MODULES MUST BE DEFINABLE AND CHECKABLE.  ^THIS
CHECKING MAKES IT EASIER TO DESIGN A PROGRAM IN SUCH A WAY THAT
YOU CAN FEEL SURE AND EVEN PROVE THAT THE PROGRAM IS CORRECT.
.B 1
^AS A WARNING, LOOK AT MOST ^^FORTRAN\\ SYSTEMS,  WHERE THE COMPILER
USUALLY DOES NOT CHECK THE DATA WHICH IS TRANSFERRED BETWEEN SUBROUTINES
(AS PARAMETERS OR AS ^^COMMON\\ BLOCKS), AND WHERE THIS IS
.index ^^COMMON statement of FORTRAN\\
ONE OF THE MOST COMMON REASONS FOR DIFFICULT-TO-FIND ERRORS IN
LARGE ^^FORTRAN\\ PROGRAMS.
.B 1
^EFFICIENCY REQUIRES THAT COMPILATION SHOULD REALLY BE DONE SEPARATELY.
^WE DO NOT WANT TO ACHIEVE "SEPARATE COMPILATION" BY RECOMPILING MOST
OF THE PROGRAM EVERY TIME, OR BY DEFERRING A LOT OF THE COMPILATION
WORK TO THE ^LINKING ^LOADER (WHICH HANDLES THE WHOLE PROGRAM) OR TO
THE RUN TIME SYSTEM (MAKING EXECUTION TIME SLOWER BECAUSE OF ERROR
CHECKS AT RUN TIME).
.B 1
^BOTH THESE REQUIREMENTS CANNOT BE COMPLETELY FULFILLED, SINCE SECURITY
REQUIRES THAT THE COMPILER DOES SOME SCANNING OF OTHER MODULES WHEN
ONE MODULE IS COMPILED SEPARATELY.  ^HOWEVER, THE ^^SIMULA\\ SYSTEM FOR
SEPARATE COMPILATION REDUCES THIS UNAVOIDABLE DOUBLE-SCANNING TO
A MINIMUM WHILE STILL RETAINING COMPLETE SECURITY.
.B 1
^^Separate compilation in SIMULA can also be combined with the
HIDDEN PROTECTED concept (See Chapter 2.5.7) to provide further
control of the module interface.\\
.SUBTITLE ^^CHAPTER\\ 4.3
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 316;.PS 80,80;.PAGE;
.ENDIF FOA
4.3##^WHAT ^^SIMULA\\ CONCEPTS CAN BE SEPARATELY COMPILED?
.BR
#####-----------------------------------------------
.B 1
^IN ^^SIMULA\\, PROCEDURES AND CLASSES CAN BE SEPARATELY COMPILED.  ^THIS
GIVES LARGE FREEDOM TO THE PROGRAMMER TO STRUCTURE HIS PROGRAM AS
HE WANTS.  ^HE CAN, IF HE SO WISHES, COMPILE SEPARATELY
.B 1;.LM 9;.I -4
1.##^COROUTINES#-#THAT IS E.G. ROUTINES WORKING ON A COMMON DATA
BUFFER, ONE FILLS THE BUFFER, BUT ONLY WHEN IT IS EMPTY, THE
OTHER EMPTIES THE BUFFER, BUT ONLY WHEN IT IS FULL.
.B 1;.I -4
2.##^PASSIVE DATA BLOCKS#-#A CLASS CAN BE A SEPARATELY COMPILED
DATA BLOCK CORRESPONDING TO THE ^^COMMON\\ STATEMENT IN ^^FORTRAN\\.
.index ^^COMMON statement of FORTRAN\\
^THE PASSIVE DATA STRUCTURE CAN ALSO BE SOME MORE COMPLEX
STRUCTURE, SUCH AS AN ORDERED OR UNORDERED SET OF DATA BLOCKS,
A TREE STRUCTURE OR ANY OTHER KIND OF DATA STRUCTURE.
.B 1;.I -4
3.##^PROGRAM LEVELS#-#BY USING THE SUBCLASS CONCEPT OF ^^SIMULA\\, A
PROGRAM CAN BE WRITTEN AT SEVERAL LEVELS.  ^EACH LEVEL INTRODUCES
MORE ADVANCED CONCEPTS BASED ON THE CONCEPTS INTRODUCED IN THE
PREVIOUS LEVELS, AND EACH LEVEL IS A SUBCLASS OF A SEPARATELY
COMPILED CLASS.  ^THE MAIN PROGRAM IS A "HIGH-LEVEL" PROGRAM
UTILIZING THE "LOWER-LEVEL" CONCEPTS INTRODUCED BY THE PREVIOUS
SEPARATELY COMPILED CLASSES.
.B 1;.LM 0
^THESE EXAMPLES SHOW THAT THE ^^SIMULA\\ SYSTEM FOR SEPARATE COMPILATION
IS FLEXIBLE AND ALLOWS THE PROGRAMMER TO PARTITION HIS
PROGRAM IN MANY CONCEPTUALLY DIFFERENT WAYS INTO SEPARATELY COMPILED
MODULES.
.B 1
^EXAMPLES WILL BE PROVIDED IN SECTION 4.5 OF THIS HANDBOOK.
.SUBTITLE ^^CHAPTER\\ 4.4
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 317;.PS 80,80;.PAGE;
.ENDIF FOA
4.4##^HOW IS SEPARATE COMPILATION SPECIFIED?
.BR
#####--------------------------------------
.B 1
^THE USE OF A SEPARATELY COMPILED MODULE IS SPECIFIED BY THE
^^EXTERNAL\\ DECLARATION IN ^^SIMULA\\.  ^YOU WRITE "^^EXTERNAL CLASS X, Y, Z;\\"
.index ^^EXTERNAL CLASS\\
OR ^^"EXTERNAL PROCEDURE A, B, C;\\" TO TELL THE SYSTEM THAT YOU
.index ^^EXTERNAL PROCEDURE\\
ARE GOING TO USE THESE SEPARATELY COMPILED CLASSES AND PROCEDURES.
.B 1
^^The  syntax of the EXTERNAL declaration is given in chapter 2.5.6
of this handbook. For information about EXTERNAL modules in other
languages than SIMULA, see part II of the DECsystem-10 SIMULA
Language Handbook.\\
.B 1
^IN THE MAIN PROGRAM, YOU CAN PUT THESE DECLARATIONS ANYWHERE
A PROCEDURE OR CLASS DECLARATION IS ALLOWED.  ^THE SEPARATELY
COMPILED MODULES WILL THEN BE AVAILABLE THROUGHOUT THE BLOCK
IN WHICH THEY ARE DECLARED, JUST AS ORDINARY NON-SEPARATE PROCEDURES
AND CLASSES.
.B 1
^IF YOU WANT TO USE A SEPARATELY COMPILED MODULE INSIDE ANOTHER
SEPARATELY COMPILED MODULE, THEN YOU PUT THE ^^EXTERNAL\\
STATEMENT BEFORE THE BEGINNING OF THE OTHER SEPARATELY COMPILED
MODULE IN THE MAIN PROGRAM.
.B 1
^THIS IS EASIEST TO UNDERSTAND BY EXAMPLES, AND SEVERAL EXAMPLES
ARE GIVEN IN THE REST OF THIS CHAPTER.
.SUBTITLE ^^CHAPTER\\ 4.5
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 318;.PS 80,80;.PAGE;
.ENDIF FOA
4.5##^EXAMPLES OF PARTITIONING OF ^^SIMULA\\ PROGRAMS.
.BR
#####-------------------------------------------
.SUBTITLE ^^CHAPTER\\ 4.5.1
.B 3
4.5.1##^A NUMBER OF SEPARATELY COMPILED PROCEDURES
.BR
#######------------------------------------------
.BR
#######WITH A COMMON DATA AREA.
.BR
#######-----------------------
.B 1
^THE ^^FORTRAN COMMON\\ STATEMENT DEFINES A COLLECTION OF
GLOBAL VARIABLES WHICH ARE AVAILABLE IN SOME OR ALL ^^FORTRAN\\
^^SUBROUTINES\\.
.B 1
^YOU CAN ACHIEVE A VERY SIMILAR EFFECT IN ^^SIMULA\\ BY
USING A PASSIVE SEPARATELY COMPILED CLASS.
.B 1;.NF;.NJ
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^CLASS\\ COMMON;
^^BEGIN REAL \X; INTEGER ARRAY \Y(1:10,1:100);
   COMMENT\\ ETCETERA.;
^^END\\;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ COMMON;
.index ^^EXTERNAL CLASS\\
^^PROCEDURE\\ PROCL(TOCOMMON);
^^REF\\ (COMMON) TOCOMMON;
^^INSPECT\\ TOCOMMON ^D^O
^^BEGIN COMMENT\\ ^BODY OF THE ^^PROCEDURE\\ PROC1;
^^COMMENT\\ HERE ALL THE VARIABLES IN THE COMMON DATA AREA ARE
DIRECTLY AVAILABLE JUST AS IN A ^^FORTRAN\\ SUBROUTINE WITH A
^^COMMON\\ STATEMENT IN IT;
^^END\\ OF PROC1;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ COMMON;
.index ^^EXTERNAL CLASS\\
^^PROCEDURE\\ PROC2(TOCOMMON);
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
^^BEGIN COMMENT\\ ^MAIN PROGRAM;
   ^^EXTERNAL CLASS\\ COMMON;
.index ^^EXTERNAL CLASS\\
   ^^EXTERNAL PROCEDURE\\ PROC1, PROC2, ... ETC ...;
.index ^^EXTERNAL PROCEDURE\\
   ^^INSPECT NEW\\ COMMON ^DO
   ^^BEGIN COMMENT\\ ^BODY OF THE MAIN PROGRAM, WHERE ALL THE
      VARIABLES IN COMMON ARE DIRECTLY AVAILABLE JUST AS IN
      A ^^FORTRAN\\ MAIN PROGRAM WITH A ^^COMMON\\ STATEMENT;
      ...
      PROC1(^^THIS\\ COMMON);
      ...
      PROC2(^^THIS\\ COMMON);
.IF FOA;.NUMBER 319;.PS 80,80;.PAGE;
.ENDIF FOA
      ...
   ^^END;
^^END\\ OF THE MAIN PROGRAM;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1;.LM 0;.RM 70;.F;.J
^IN ^^FORTRAN\\ YOU CAN HAVE SEVERAL DIFFERENT LABELLED
^^COMMON\\ BLOCKS WITH DIFFERENT NAMES.  ^IN THE SAME WAY, YOU
CAN IN ^^SIMULA\\ HAVE SEVERAL SEPARATELY COMPILED ^^CLASS\\ES AND
BEGIN EACH PROCEDURE BY
.B 1
"^^INSPECT\\ TOCOMMON1 ^^DO INSPECT\\ TOCOMMON2 ^^DO INSPECT\\ TOCOMMON3
.BR
^D^O ...  ETC ..."
.B 1
^THE ^^SIMULA CLASS\\ IS OF COURSE MUCH MORE GENERAL-PURPOSE
THAN THE ^^FORTRAN COMMON\\.  ^THE ^^CLASS\\ CAN FOR EXAMPLE CONTAIN
INITIALIZATION OF THE DATA VARIABLES IN THE ^^CLASS\\ AND
STANDARD PROCEDURES FOR HANDLING THE DATA IN THE ^^CLASS\\.  ^ALL
THIS IS WELLKNOWN TO SOMEONE WITH ^^SIMULA\\ EXPERIENCE.
.B 1
^ALSO, YOU CAN IN ^^SIMULA\\ HAVE MORE THAN ONE COPY OF THE
SAME ^^CLASS\\, WITH DIFFERENT VALUES FOR THE DATA VARIABLES IN
THEM.  ^IN ^^FORTRAN\\ YOU CAN ONLY HAVE ONE COPY OF THE DATA IN
EACH ^^COMMON \\BLOCK.
.SUBTITLE ^^CHAPTER\\ 4.5.2
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 320;.PS 80,80;.PAGE;
.ENDIF FOA
4.5.2##^EACH SEPARATELY COMPILED MODULE EXTENDS
.BR
#######---------------------------------------
.BR
#######THE PREVIOUS ONE.
.BR
#######----------------
.B 1
^IN ^^SIMULA\\ YOU CAN WRITE A BASIC ^^CLASS\\ DEFINING SOME NEW
CONCEPTS.  ^THEN YOU CAN IN A SERIES OF ^^SUBCLASSES\\ REFINE THE
BASIC CLASS.  ^YOUR PROGRAM WILL BE WRITTEN AT DIFFERENT
LEVELS, WHERE EACH LEVEL USES THE NEW CONCEPTS DEFINED AT
THE PREVIOUS LEVEL.
.B 1
^FOR EXAMPLE, YOU MAY HAVE THE FOLLOWING LEVELS:
.B 1;.LM 15;.TS 13,15;.I -15
^DATABASE	-	INTRODUCE THE DATA STRUCTURES OF A RELATIONAL DATA BASE.
.B 1;.I -15
^DATAMAKE	-	INTRODUCE PROCEDURES TO ENTER DATA INTO THE
RELATIONAL DATA BASE.
.B 1;.I -15
^DATAUSE	-	INTRODUCE PROCEDURES TO GET DATA FROM THE
RELATIONAL DATA BASE.
.B 1;.I -15
^FAMILY	-	INTRODUCE THE SPECIAL CASE OF FAMILY RELATIONSHIPS.
.B 1;.I -15
^MAIN PROGRAM	-	UTILIZE THE CONCEPTS TO WRITE A PROGRAM
USING RELATIONAL DATA BASES WITH FAMILY RELATIONSHIPS IN THEM.
.B 1;.LM 0;.RM 70;.F;.J
^IN ^^SIMULA\\ YOU CAN WRITE SUCH A PROGRAM STRUCTURE LIKE THIS:

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.LM 0;.RM 70;.NF;.NJ
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^CLASS\\ DATABASE;
^^BEGIN ... END\\;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ DATABASE;
DATABASE ^^CLASS\\ DATAMAKE;
^^BEGIN ... END\\;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ DATABASE, DATAMAKE;
DATAMAKE ^^CLASS\\ DATAUSE;
^^BEGIN ... END\\;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ DATABASE, DATAMAKE, DATAUSE;
DATAUSE ^^CLASS\\ FAMILY;
^^BEGIN ... END\\;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
.IF FOA;.NUMBER 321;.PS 80,80;.PAGE;
.ENDIF FOA
^^BEGIN COMMENT\\ MAIN PROGRAM;
   ^^EXTERNAL CLASS\\ DATABASE, DATAMAKE, DATAUSE, FAMILY;
   FAMILY ^^BEGIN\\
      ... HERE THE NEW CONCEPTS CAN BE USED FREELY ...
   ^^END\\;
^^END;\\
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.IF FOA;.NUMBER 322;.PS 80,80;.PAGE;
.ENDIF FOA
.SUBTITLE ^^CHAPTER\\ 4.5.3
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
4.5.3##^A LIST OF ITEMS IS TRANSFERRED TO
.index ^^REF parameters to separately compiled PROCEDURES\\
.index ^^REF parameters to separately compiled PROCEDURES\\
.BR
#######---------------------------------
.BR
#######SEPARATELY COMPILED PROCEDURES.
.BR
#######------------------------------
.B 1
^YOU MAY WANT TO WRITE A PROGRAM TO PROCESS SETS OF
ITEMS.  ^USUALLY, WHEN YOU CALL A SEPARATELY COMPILED
PROCEDURE, YOU WANT TO TRANSFER A SET OF ITEMS TO IT.  ^THE
SETS ARE STORED IN A LINEAR LIST WITH A REFERENCE VARIABLE
"NEXT" REFERRING TO THE NEXT ITEM IN THE LIST.
.B 1;.LM 0;.RM 70;.NF;.NJ
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^CLASS\\ ITEM(NEXT, NUMBER, SIZE, LABEL);
^^REF\\ (ITEM) NEXT;
^^INTEGER\\ NUMBER, SIZE; ^^TEXT\\ LABEL;;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ ITEM;
^^PROCEDURE\\ ITEMSCAN(ITEMLIST);
^^REF\\ (ITEM) ITEMLIST;
^^BEGIN\\
   ^R^E^F (ITEM) SCANNEDITEM;
   SCANNEDITEM:- ITEMLIST;
   ^^WHILE\\ SCANNEDITEM =/= ^^NONE DO\\
   ^^INSPECT\\ SCANNEDITEM ^D^O
   ^^BEGIN COMMENT\\ TREATMENT OF ONE ITEM IN THE LIST;
      ...
      SCANNEDITEM:- NEXT;
   ^E^N^D;
^E^N^D;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^BEGIN COMMENT\\ MAIN PROGRAM;
   ^^EXTERNAL CLASS\\ ITEM;
   ^^EXTERNAL PROCEDURE\\ ITEMSCAN;
   ^R^E^F (ITEM) ITEMLIST;
   ...
   ITEMLIST:- ^N^E^W ITEM(ITEMLIST,N,S,"^^TO OFFICE"\\);
   ...
   ITEMSCAN(ITEMLIST);
   ...
^E^N^D;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1;.LM 0;.RM 70;.F;.J
^INSTEAD OF A LINEAR LIST, YOU COULD IN THIS WAY
TRANSFER AN ARBITRARY DATA STRUCTURE SUCH AS A TREE, A RING,
A RELATIONAL DATA BASE OF WHATEVER YOU WANT TO TRANSFER AS
DATA TO THE SEPARATELY COMPILED PROCEDURES AND CLASSES.
.SUBTITLE ^^CHAPTER\\ 4.5.4
.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 323;.PS 80,80;.PAGE;
.ENDIF FOA
4.5.4##^SEPARATE COMPILATION WITH SIMSET AND SIMULATION.
.BR
#######------------------------------------------------
.B 1
^THE STANDARD SYSTEM CLASSES "SIMSET" AND "SIMULATION"
CAN THEMSELVES BE REGARDED AS A SPECIAL KIND OF SEPARATELY
COMPILED CLASSES.  ^YOU DO NOT HAVE TO DECLARE THEM IN ANY
"^^EXTERNAL\\" DECLARATION.
.B 1
^THERE ARE CLASSES DECLARED INSIDE "SIMSET" AND
.index ^^SIMSET and separately compiled CLASS-es\\
"SIMULATION", E.G. "LINK" AND "PROCESS".  ^THEY ARE NOT
.index ^^SIMULATION and separately compiled CLASS-es\\
THEMSELVES SEPARATELY COMPILED CLASSES.
.B 1
^THIS MEANS THAT A SEPARATELY COMPILED CLASS CAN BE A
SUBCLASS OF "SIMSET" OR OF "SIMULATION", BUT NOT A SUBCLASS
.index ^^SIMULATION and separately compiled CLASS-es\\
OF "LINK" OR "PROCESS".
.B 1
^^It is not possible to write a separately compiled CLASS
or PROCEDURE using SIMSET or SIMULATION except as separately
compiled subclasses to SIMSET or to SIMULATION.\\
.B 1
^IF YOU WANT TO COMPILE SEPARATELY A SUBCLASS OF E.G.
"PROCESS" THEN YOU CAN STILL DO IT.  ^YOU THEN COMPILE
SEPARATELY A SUBCLASS OF "SIMULATION" WHICH CONTAINS WITHIN
.index ^^SIMULATION and separately compiled CLASS-es\\
IT A SUBCLASS OF "PROCESS".  ^THE FOLLOWING EXAMPLE WILL SHOW
HOW TO DO IT:
.B 1;.NF;.NJ
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
SIMULATION ^^CLASS\\ CRANEANDTRUCK;
.index ^^SIMULATION and separately compiled CLASS-es\\
^^BEGIN\\
   PROCESS ^^CLASS\\ CRANE;
   ^^BEGIN ... END\\;
   PROCESS ^^CLASS\\ TRUCK;
   ^^BEGIN ... END\\;
^E^N^D;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^EXTERNAL CLASS\\ CRANEANDTRUCK;
CRANEANDTRUCK ^^CLASS\\ HARBOUR;
^^BEGIN\\
   PROCESS ^^CLASS\\ SHIP;
   ^^BEGIN ... END\\;
^E^N^D;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.B 1
^^BEGIN COMMENT\\ MAIN PROGRAM;
   ^^EXTERNAL CLASS\\ CRANEANDTRUCK, HARBOUR;
   HARBOUR ^^BEGIN COMMENT\\ HERE YOU CAN USE THE NEW PROCESSES
      CRANE, TRUCK AND SHIP;
      ...
   ^E^N^D;
^E^N^D;
.B 1
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

.IFNOT FOA;.PG;
.ENDIF FOA;.F;.J
.IF FOA;.NUMBER 324;.PS 80,80;.PAGE;
.ENDIF FOA
^IN THE ABOVE EXAMPLE, WE FIRST COMPILE TWO SUBCLASSES
OF "PROCESS", "CRANE" AND "TRUCK" IN ONE SEPARATELY COMPILED
MODULE, THE CLASS "CRANEANDTRUCK".  ^WE THEN COMPILE THE THIRD
SUBCLASS OF "PROCESS", "SHIP" IN A SECOND SEPARATELY
COMPILED MODULE, THE CLASS "HARBOUR".  ^FINALLY, IN THE MAIN
PROGRAM, A SIMULATION IS PROGRAMMED USING THE THREE NEW
.index ^^SIMULATION and separately compiled CLASS-es\\
PROCESSES CRANE, TRUCK AND SHIP.
.SUBTITLE ^^CHAPTER\\ 4.6
.B 3
.IF FOA;.NUMBER 325;.PS 80,80;.PAGE;
.ENDIF FOA
4.6##^A WAY OF UNDERSTANDING PART-COMPILATION IN ^^SIMULA\\\
.BR
#####-------------------------------------------------
.B 1
^A WAY TO UNDERSTAND INTUITIVELY HOW PART-COMPILATION WORKS IS
TO DESCRIBE IT IN THE FOLLOWING WAY.  ^BY THIS IS NOT MEANT THAT
A ^^SIMULA\\ COMPILER NECESSARILY WILL IMPLEMENT PART-COMPILATION
IN THE WAY DESCRIBED BELOW.
.B 1
^WHEN AN ^^EXTERNAL\\ DECLARATION OCCURS INSIDE THE MAIN PROGRAM,
THE EFFECT IS THE SAME AS IF THE WHOLE TEXT OF THE SEPARATELY COMPILED
CLASS OR PROCEDURE WAS COPIED INTO THE MAIN PROGRAM AT THAT POINT.
.B 1
^WHEN AN ^^EXTERNAL\\ DECLARATION OCCURS IN FRONT OF ANOTHER SEPARATELY
COMPILED CLASS OF PROCEDURE, THIS DOES NOT IMPLY ANY SUCH COPYING.
^INSTEAD, THIS SERVES TO INFORM THE COMPILER THAT WHEN THIS OTHER
MODULE IS LATER ON COPIED INTO THE MAIN PROGRAM, THEN THE
^^EXTERNAL\\-DECLARED MODULE IS ALREADY AVAILABLE AT THAT POINT
IN THE MAIN PROGRAM.
.SUBTITLE ^^CHAPTER\\ 4.7
.B 3
4.7##^HOW IS PART-COMPILATION IMPLEMENTED IN THE ^^DEC\\-SYSTEM-10
.BR
#####--------------------------------------------------------
.BR
#####^^SIMULA\\ SYSTEM?
.BR
#####--------------
.B 1
^THE DIFFICULTY IN IMPLEMENTING PART-COMPILATION IN A ^^SIMULA\\
SYSTEM IS TO ENSURE FULL ERROR-CHECKING SECURITY.  ^TO DO THIS,
THE COMPILER MUST KNOW ABOUT OTHER SEPARATELY COMPILED MODULES
WHEN ONE MODULE IS COMPILED, SINCE SOME ERRORS CAN ONLY BE FOUND
BY COMPARING INFORMATION IN SEVERAL SEPARATELY COMPILED MODULES.
.B 1
^THE SOLUTION IN THE ^D^E^C-SYSTEM-10 IS THAT EACH MODULE,
WHEN IT IS COMPILED, OUTPUTS NOT ONLY A FILE WITH THE OBJECT
PROGRAM, BUT ALSO ANOTHER FILE WITH THE DESCRIPTION OF EXTERNALLY
ACCESSIBLE ATTRIBUTES OF THAT MODULE.  (^THAT IS; ^ATTRIBUTES
.IF FOA;.NUMBER 326;.PS 80,80;.PAGE;
.ENDIF FOA
OF A SEPARATELY COMPILED CLASS, PARAMETERS OF A SEPARATELY COMPILED PROCEDURE.)
^THIS OTHER FILE HAS THE EXTENSION ".^A^T^R".

.IFNOT FOA;.PG
.ENDIF FOA;
^WHEN AN ^^EXTERNAL\\ STATEMENT IS ENCOUNTERED, THE ATTRIBUTE FILE
FOR THAT MODULE IS READ IN BY THE COMPILER.  ^THIS MEANS THAT
THE ERROR-CHECKING CAN WHOLLY BE DONE AT COMPILE-TIME.  ^THERE IS NO
NEED TO CHECK THE PARAMETER TYPES OF PROCEDURE PARAMETERS AT RUN
TIME.  ^MOST OTHER ^ALGOL-LIKE LANGUAGES DO THIS PARAMETER TYPE
CHECKING AT RUN TIME, OR ELSE THEY DO NOT CHECK THE PARAMETER TYPES
AT ALL.
.SUBTITLE ^^CHAPTER\\ 4.8
.B 3
4.8##^IMPLEMENTATION-DEPENDENT RESTRICTIONS ON SEPARATE COMPILATION
.BR
#####-------------------------------------------------------------
.B 1
^SOME PROGRAM CHANGES IN ONE MODULE FORCES RE-COMPILATION OF
OTHER MODULES.  ^THIS IS JUST LIKE IN ^^FORTRAN\\; WHEN THE NUMBER
OF PARAMETERS TO A ^^FORTRAN SUBROUTINE\\ IS CHANGED, ALL OTHER
^^SUBROUTINES\\ WHICH CALL THE CHANGED ^^SUBROUTINE\\ MUST BE 
MODIFIED AND RE-COMPILED, AND WHEN A ^^COMMON\\ STATEMENT IS MODIFIED,
ALL ^^SUBROUTINES\\ CONTAINING THE MODIFIED ^^COMMON\\ MUST BE
RE-COMPILED.
.B 1
^THE DIFFERENCE IN ^^SIMULA\\ IS THAT THE COMPILER WILL TELL YOU
IF YOU FORGOT TO RE-COMPILE SOME MODULE WHICH HAD TO BE
RE-COMPILED.  ^IN ^^FORTRAN\\, YOU ARE USUALLY NOT TOLD, AND THE
RESULTS MAY BE DISASTROUS WHEN YOU TRY TO RUN THE PROGRAM.
.B 1
^THE BASIC RULE IS:##^IF A ^^SIMULA\\ PART-COMPILED MODULE IS MODIFIED
SO THAT ITS ATTRIBUTES ARE MODIFIED, THEN ALL OTHER MODULES
REFERRING TO IT BY ^^EXTERNAL\\ STATEMENTS MUST ALSO BE MODIFIED.
.B 1
^NOTE HOWEVER, THAT IF YOU ONLY MAKE INTERNAL CHANGES IN A MODULE,
WHICH DO NOT ALTER THE ATTRIBUTES, THEN IN MOST CASES NO OTHER MODULE NEED BE
RE-COMPILED.
.B 1
.IF FOA;.NUMBER 327;.PS 80,80;.PAGE;
.ENDIF FOA
^THE ^D^E^C-SYSTEM-10 ^^SIMULA\\ SYSTEM ALSO REQUIRES THAT WHEN
YOU COMPILE A SEPARATELY COMPILED CLASS, YOU MUST GIVE AS A PARAMETER TO THE
COMPILER THE BLOCK LEVEL OF THE PLACE WHERE IT IS COPIED INTO
THE MAIN PROGRAM.  ^THIS RESTRICTION IS NOT AS SEVERE AS YOU MAY
FEEL INITIALLY, SINCE:
.B 1;.LM 9;.I -4
1.##^DEFAULT IS THE OUTERMOST BLOCK, WHERE YOU USUALLY PUT
^^EXTERNAL\\ DECLARATIONS.
.B 1;.I -4
2.##^IF YOU DO NOT FOLLOW THIS RULE, THE COMPILER TELLS YOU
EXACTLY WHICH MODULES YOU HAVE TO RE-COMPILE AT WHICH BLOCK LEVEL.
.index !!! 5.0 ^^Conversational terminals, use of more than one\\
.index !!! 5.0 ^^HIBERNATE UUO of DECsystem-10\\
.index !!! 5.0 ^^Multi-terminal system\\
.index !!! 5.0 ^^Real time computer applications\\
.index !!! 5.0 ^^Terminals, more than one used by the same program\\
.index !!! 5.0 ^^TTY-s, more than one used by the same program\\

.index !!! 5.3 ^^FORK statement\\
.index !!! 5.3 ^^JOIN statement\\
.index !!! 5.3 ^^Semaphore variables\\

.index !!! 5.3.5 ^^Industrial robot control\\
.index !!! 5.3.5 ^^Process control applications\\
.index !!! 5.3.5 ^^Robot control\\

.ST ^^CHAPTER#5\\
.PG;.C
^^CHAPTER 5###REAL TIME\\
.BR;.C
---------------------
.B 1;.LM 0;.RM 70;.C
******************************^^IMPORTANT\\*******************************
.B 1
^THIS CHAPTER DESCRIBES AN ADDITIONAL FACILITY WHICH WILL NOT
BE INCLUDED IN RELEASE 1 OF THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ SYSTEM.
^WE HAVE NOT YET DECIDED WHETHER TO IMPLEMENT THIS FACILITY
AT ALL, THE DECISION DEPENDS ON WHETHER USERS OF THE
^D^E^CSYSTEM-10 ^^SIMULA\\ SYSTEM REQUIRE THIS FACILITY.
.B 1
**********************************************************************
.B 1;.LM 0;.RM 70;.F;.J
^THE SIMPLEST KIND OF REAL TIME APPLICATION IS THE EXECUTION
OF A CONVERSATIONAL PROGRAM RUNNING UNDER A TIME-SHARING
SYSTEM WITH ONE EXTERNAL USER TALKING TO THE PROGRAM THROUGH
A TERMINAL SUCH AS A DISPLAY UNIT OR A TYPEWRITER TERMINAL.
.B 1
^THIS SIMPLE KIND OF CONVERSATION CAN ALREADY EASILY BE
PROGRAMMED USING THE CONCEPTS DESCRIBED IN CHAPTER 1-4 IN
THIS MANUAL.  ^THE TIME-SHARING OPERATING SYSTEM WILL HANDLE
ALL THE REAL TIME PROBLEMS FOR THE ^^SIMULA\\ PROGRAM.
.B 1
^BUT AS SOON AS WE WANT MORE THAN ONE REAL PROCESS TO
COMMUNICATE SIMULTANEOUSLY WITH THE ^^SIMULA\\ PROGRAM, THEN WE
NEED MORE ADVANCED REAL TIME CAPABILITIES.
.B 1
^EXAMPLES:
.B 1;.LM 9;.I -3
-##^DURING A SIMULATION, WE MAY WANT TO PROGRAM PART OF THE
SIMULATION IN ^^SIMULA\\ BUT LET REAL COMPONENTS, FOR EXAMPLE
REAL HUMAN PARTICIPANTS, PLAY CERTAIN PARTS IN THE
SIMULATION.
.B 1;.I -3
-##^WE WANT TO LET MORE THAN ONE USER AT HIS TERMINAL
SIMULTANEOUSLY ACCESS A DATA BASE, BOTH FETCHING AND STORING
INFORMATION IN IT.  ^ONE MASTER PROGRAM HAS TO COORDINATE THE
DATA BASE ACCESSES TO THAT TWO USERS DO NOT SIMULTANEOUSLY
TRY TO UPDATE THE SAME RECORD.  ^WE MIGHT WANT TO WRITE THIS
PROGRAM IN ^^SIMULA\\.
.B 1;.LM 0
^TO PROGRAM SUCH APPLICATIONS, SOME ADDITIONAL FACILITIES ARE
NECESSARY IN THE ^^SIMULA\\ PROGRAMMING LANGUAGE.
.PG;.B 3
5.1##^PROCEDURES ^^WAIT(TERMINALQUEUE), DATAREADY\\ AND ^^HOLD\\(0).
.BR
#####-----------------------------------------------------
.B 1
^THE EXECUTION OF A ^^SIMULA\\ PROCESS IS ONLY INTERRUPTED WHERE
EXPLICIT STATEMENTS LIKE ^^"HOLD"\\ OR "^^PASSIVATE\\" CAUSE CONTROL
TO TRANSFER FROM THE PROCESS TO THE SCHEDULER.  ^A COMMON
ERROR WHEN PROGRAMMING REAL TIME PROGRAMS IS THAT ONE
PARALLEL PROCESS USES HALF-READY DATA, PROCUCED BY ANOTHER
PARALLEL PROCESS.  ^FOR SMALL IN-CORE UPDATES, A PROGRAMMER
IN ^^SIMULA\\ CAN AVOID THIS ERROR BY ONLY PUTTING STATEMENTS
LIKE "^^HOLD\\" AND "^^PASSIVATE\\" AT PLACES IN THE SOURCE PROGRAM
WHERE DATA UPDATES ARE COMPLETE.
.B 1
^FOR MORE COMPLEX UPDATES, A SPECIAL PROCESS CAN BE WRITTEN
TO ACCESS THE CRITICAL DATA, AND OTHER PROCESSES REQUESTING
UPDATES CAN BE QUEUED TO THE SPECIAL PROCESS.  ^WHEN A ^^SIMULA\\
PROCESS EXECUTES A STATEMENT LIKE "^^HOLD\\" OR "^^PASSIVATE\\",
THEN CONTROL GOES TO THE ^^SIMULA\\ SCHEDULER, WHICH THEN
TRANSFERS CONTROL TO ANOTHER PROCESS.
.B 1
"^^HOLD(A)\\" STOPS EXECUTION OF THE CURRENT PROCESS BUT ASKS
THE ^^SIMULA\\ SCHEDULER TO RESTART IT AFTER ^A TIME UNITS.  ^IF ^A
IS ZERO, THEN THE CURRENT PROCESS IS STOPPED AND PLACED AT
THE END OF A QUEUE OF CURRENTLY ACTIVE PROCESSES.  ^IF A
NUMBER OF PROCESSES SUCCESSIVELY MAKE "^^HOLD(0.0)\\" THEN THEY
WILL THUS GET ^C^P^U POWER IN A ROUND ROBIN FASHION.
.B 1
^A ^^SIMULA\\ PROGRAMMER CAN THUS ENSURE FAST RESPONSE TO
EXTERNAL INTERRUPTS BY NOT MAKING TOO MUCH COMPUTATIONS
BETWEEN SUCCESSIVE "^^HOLDS\\".
.PG;.B 1
"^^PASSIVATE\\" STOPS THE CURRENT PROCESS INDEFINITELY, IT MUST
BE ACTIVATED AGAIN FROM SOME OTHER PROCESS.
.B 1
^PROCESSES WAITING FOR EXTERNAL INTERRUPTS ARE PUT INTO A
SPECIAL QUEUE CALLED ^^TERMINALQUEUE\\.  ^AS SOON AS CONTROL IS
TRANSFERRED TO THE ^^SIMULA\\ SCHEDULER (E.G. BY CALLS TO
"^^HOLD\\" OR "^^PASSIVATE\\") THEN THE SCHEDULER FIRST SCANS THIS
QUEUE TO SEE IF DATA HAS ARRIVED FROM THE INPUT DEVICE
ASSOCIATED WITH THE TERMINAL PROCESS.
.B 1
^IF A PROCESS IS FOUND IN THE ^^TERMINALQUEUE\\ FOR WHICH DATA
HAS ARRIVED ON THE ASSOCIATED INPUT DEVICE, THEN THE ^^SIMULA\\
SCHEDULER ACTIVATES THIS PROCESS IMMEDIATELY.
.B 1
^THE EVENT CREATED BY THE FIRST EXTERNAL INTERRUPT FOUND IS
THUS PLACED IN FRONT OF OTHER CURRENTLY ACTIVE PROCESSES IN
THE SEQUENCING SET.  ^THIS, HOWEVER, IS NOT DONE AT THE TIME
OF THE INTERRUPT, THE PLACING IS DONE AT THE TIME OF THE
NEXT ACTIVATION OF THE SCHEDULER AFTER THE INTERRUPT.
.B 1
^INSIDE A PROCESS, A CALL "^^WAIT(TERMINALQUEUE\\)" WILL THUS
TELL THE SYSTEM TO MAKE THIS PROCESS PASSIVE, BUT TO
REACTIVATE IT AS SOON AS NEW DATA HAS ARRIVED ON THE INPUT
DEVICE ASSOCIATED WITH THE PROCESS.
.B 1
^A NEW "^^BOOLEAN\\" STANDARD PROCEDURE "^^DATAREADY\\" IS ALSO
INTRODUCED.  ^DATAREADY\\ IS AN ATTRIBUTE TO ^^INFILE\\ AND IS ^^TRUE\\
IF AND ONLY IF DATA IS AVAILABLE (I.E. HAS ARRIVED FROM THE
TERMINAL DEVICE) FOR READING WITH ^^INIMAGE.\\
.PG;.B 3
5.2##^PROCEDURES ^^TIMEOFDAY, SYNCHRONIZE \A\N\D DESYNCHRONIZE\\
.BR
#####--------------------------------------------------
.B 1
^FOR REAL TIME APPLICATIONS, WE MAY ALSO WANT TO SYNCHRONIZE
SIMULATED TIME WITH REAL TIME.  ^FOR THIS THERE ARE THREE NEW
STANDARD PROCEDURES:
.B 1
^^REAL PROCEDURE\\ TIMEOFDAY;##^^COMMENT\\ GIVES TIME IN SECONDS
SINCE THE BEGINNING OF THE CURRENT DAY;
.B 1
^^PROCEDURE\\ SYNCHRONIZE(TIMEUNIT);##^^REAL\\ TIMEUNIT;##^^COMMENT\\ THIS
PROCEDURE STARTS SYNCHRONIZATION OF REAL AND SIMULATED TIME;
.B 1
^^PROCEDURE\\ DESYNCHRONIZE;##^^COMMENT\\ AND THIS STOPS
SYNCHRONIZATION;
.B 1
^OF COURSE PERFECT SYNCHRONIZATION OF REAL AND SIMULATED TIME
IS NOT POSSIBLE SINCE THE SPEED OF THE COMPUTER ITSELF IS
NOT INFINITE.  ^BY SYNCHRONIZATION IS MEANT THAT THE
SIMULATED TIME SINCE THE BEGINNING OF THE CURRENT
SYNCHRONIZATION PERIOD MUST NEVER BE LARGER THAN THE REAL
TIME SINCE THE SAME BEGINNING.
.B 1
^IF THE ^^SIMULA\\ SCHEDULER FINDS THAT THE NEXT PROCESS TO BE
SCHEDULED HAS A TOO LARGE SIMULATED TIME, THEN THE ^^SIMULA\\
SCHEDULER LETS THE ^^SIMULA\\ PROGRAM GO TO SLEEP FOR THE
NECESSARY TIME INTERVAL.  ^ANY INTERRUPTS CAUSED BY INPUT
WILL HOWEVER START THE ^^SIMULA\\ PROGRAM AGAIN.  (^ON A ^D^E^C
SYSTEM-10 COMPUTER, THE ^^HIBERNATE UUO\\ CAN BE USED TO PROGRAM
THIS.)
.B 1
^THE PARAMETER "TIMEUNIT" TO THE PROCEDURE "SYNCHRONIZE" IS
THERE SINCE THE TIME UNIT MAY NOT BE THE SAME IN THE
SIMULATION AND IN THE REAL WORLD.  "TIMEUNIT" IS THE SIZE OF
THE SIMULATION TIME UNIT IN SECONDS.  ^THUS, IF SIMULATED
TIME IS MEASURED IN SECONDS, "TIMEUNIT" SHOULD BE 1.0, IF
SIMULATED TIME IS MEASURED IN HOURS, "TIMEUNIT" SHOULD BE
60*60.
.PG;.B 3
5.3##^APPLICATION EXAMPLES
.BR
#####--------------------
.B 1
^IN THIS SECTION YOU CAN SEE HOW THE NEW CONCEPTS CAN BE
USED.  ^SOME EXAMPLES WILL BE GIVEN OF REAL TIME PROGRAMS
WRITTEN IN ^^SIMULA\\ USING THE NEW CONCEPTS.
.B 1
^THE PROGRAMS ARE NOT ALWAYS COMPLETE.  ^THREE DOTS INDICATE
PLACES WHERE SOMETHING HAS BEEN LEFT OUT.
.B 3
5.3.1##^SIMULTANEOUS, UNINTERFERED DIALOGUE BETWEEN
.BR
#######-------------------------------------------
.BR
#######THE COMPUTER AND SEVERAL REAL TERMINALS
.BR
#######---------------------------------------
.B 1
^ONE MASTER TERMINAL READS FILE SPECIFICATIONS FOR THE OTHER
TERMINALS AND STARTS UP ONE COPY OF THE ^^SIMULA CLASS\\
"TERMINAL" FOR EACH OF THE OTHER TERMINALS.  ^EACH OF THESE
"TERMINAL PROCESSES" WILL OPEN THE CONNECTION TO ITS REAL
TERMINAL, AND THEN GO INTO A LOOP OF (A) WAITING FOR INPUT
AND (B) PRODUCING ANSWERS.
.B 1
^EACH OF THESE TERMINAL LOOPS WILL GO ON INDEPENDENTLY OF THE
OTHER, AND THE ^^SIMULA\\ SCHEDULER WILL DISTRIBUTE CONTROL
BETWEEN THE "TERMINAL PROCESSES".
.B 1;.LM 0;.RM 70;.NF;.NJ
TERMINALPROCESS ^^CLASS\\ TERMINAL(FILE SPECIFICATIONS);
^^TEXT\\ FILE SPECIFICATIONS;
^^INSPECT\\ FROMTERMINAL ^D^O
^^INSPECT NEW\\ OUTFILE(FILE SPECIFICATIONS) ^D^O
^^BEGIN\\
   ^^PROCEDURE\\ OPEN TERMINAL CONNECTIONS; ...
   ^^PROCEDURE\\ READ THE INPUT AND PRODUCE AN ANSWER; ...
.B 1
   OPEN TERMINAL CONNECTIONS;
^^   WHILE TRUE DO\\
   ^^BEGIN\\
      WAIT(TERMINALQUEUE);
      READ THE INPUT AND PRODUCE AN ANSWER;
   ^E^N^D;
^E^N^D;
.B 1
^^WHILE TRUE DO
BEGIN
   PROCEDURE\\
   READ FILE SPECIFICATIONS FOR A CONVERSATIONAL TERMINAL;
   ...
   ^^TEXT\\ FILE SPECIFICATIONS;
.B 1
   WAIT(TERMINALQUEUE);
   READ FILE SPECIFICATIONS FOR A CONVERSATIONAL TERMINAL;
   ^^ACTIVATE NEW\\ TERMINAL(^N^E^W INFILE(FILE SPECIFICATIONS),
^E^N^D;
.PG;.B 1;.LM 0;.RM 70;.F;.J
5.3.2##^DATA BASE SYSTEM, SEVERAL TERMINALS
.BR
#######-----------------------------------
.BR
#######USE THE SAME DATA BASE
.BR
#######----------------------
.B 1
^THIS IS A VERY SIMPLE EXAMPLE OF A DATA BASE SYSTEM WITH
SEVERAL CONVERSATIONAL TERMINALS WHICH INDEPENDENTLY PUT
REQUESTS (QUESTIONS OR UPDATES) TO A DATA BASE.  ^THE ACTUAL
DATA BASE ACCESSES MUST BE DONE FOR ONLY ONE REQUEST AT A
TIME TO AVOID ERRORS WHEN ONE TERMINAL TRIES TO READ WHAT
ANOTHER TERMINAL IS UPDATING.
.B 1
^THE ^^SIMULA\\ PROGRAM CONTAINS ONE PROCESS FOR EACH TERMINAL
AND ONE PROCESS FOR THE DATA BASE.
.B 1
^THE TERMINAL PROCESSES WAIT FOR INPUT FROM THEIR RESPECTIVE
TERMINALS.  ^WHEN A DATA BASE REQUEST HAS BEEN RECEIVED, THE
TERMINAL PROCESS IS PUT INTO A QUEUE OF DATA BASE REQUESTS.
.B 1
^THE DATA BASE PROCESS TAKES ONE TERMINAL PROCESS AT A TIME
FROM THIS QUEUE AND PROCESSES THE DATA BASE REQUEST.
^THEREAFTER, THE DATA BASE PROCESS ^^ACTIVATE\\S THE TERMINAL
PROCESS AGAIN.  ^WHEN ^^ACTIVATE\\D, THIS TERMINAL PROCESS WRITES
THE ANSWER TO ITS TERMINAL AND WAITS FOR NEW REQUESTS FROM IT.
.PG;.B 1;.NF;.NJ
^^REF\\ (HEAD) REQUEST QUEUE; ^R^E^F (DATA BASE) THE DATA BASE;
.B 1
TERMINALPROCESS ^^CLASS\\ TERMINAL(FILE SPECIFICATIONS);
^^TEXT\\ FILE SPECIFICATIONS;
^^INSPECT\\ FROMTERMINAL ^D^O
^^INSPECT NEW\\ OUTFILE(FILE SPECIFICATIONS) ^D^O
^^BEGIN\\
   ^^PROCEDURE\\ OPEN TERMINAL LINE; ...
   ^^PROCEDURE\\ READ AND PREPARE DATA BASE REQUEST; ...
   ^^PROCEDURE\\ WRITE THE ANSWER TO THE REQUEST; ...
.B 1
   ^^WHILE TRUE DO\\
   ^^BEGIN\\
      WAIT(TERMINALQUEUE);
      READ AND PREPARE DATA BASE REQUEST;
      ^^ACTIVATE\\ THE DATA BASE;
      WAIT(REQUEST QUEUE);
      WRITE THE ANSWER TO THE REQUEST;
   ^^END\\;
^^END\\;
.B 1
PROCESS ^^CLASS\\ DATA BASE;
^^INSPECT NEW\\ DIRECTFILE(DATA BASE FILE SPECIFICATIONS) ^D^O
^^BEGIN
   PROCEDURE\\ OPEN DATA BASE FILE; ...
   ^^PROCEDURE\\
   PUT THE REQUEST TO THE DATA BASE AND FIND THE ANSWER;
   ...
.B 1
   OPEN DATA BASE FILE;
   ^^WHILE TRUE DO\\
   ^^INSPECT\\ REQUEST QUEUE.FIRST ^^WHEN\\ TERMINAL ^D^O
   ^^BEGIN\\
      OUT; ^^COMMENT\\ TO REMOVE THE TERMINAL FROM THE REQUEST
      QUEUE;
      PUT THE REQUEST TO THE DATA BASE AND FIND THE ANSWER;
      ^^ACTIVATE THIS\\ TERMINAL;
   ^^END OTHERWISE\\ PASSIVATE;
^^END\\;
.PG;.B 3;.LM 0;.RM 70;.F;.J
5.3.3##^LIMITED RESPONSE TIME FOR THE TERMINAL OPERATOR
.BR
#######-----------------------------------------------
.B 1
^THIS IS A VERY SIMPLE EXAMPLE OF A PROGRAM WHICH IS
COORDINATED WITH THE TIME IN THE REAL WORLD.  ^A QUESTION IS
GIVEN TO A TERMINAL OPERATOR AND THE PROGRAM WAITS FOR AN
ANSWER.  ^THE PROGRAM SHOULD TAKE DIFFERENT ACTION DEPENDING
ON WHETHER THE ANSWER IS RECEIVED WITHIN 60 SECONDS OR NOT.
.B 1
^TO DO THIS, THE NEW STANDARD PROCEDURE ^^SYNCHRONIZE\\ IS USED
TO SYNCHRONIZE REAL TIME WITH THE SIMULATED TIME IN ^^SIMULA\\.
.B 1;.NF;.NJ
TERMINALPROCESS ^^CLASS\\ TERMINAL(FILE SPECIFICATIONS);
^^TEXT\\ FILE SPECIFICATIONS;
^^INSPECT\\ FROMTERMINAL ^D^O
^^INSPECT NEW\\ OUTFILE(FILE SPECIFICATIONS) ^D^O
^^BEGIN\\
   ^^REAL\\ QUESTIONTIME;
   ^^PROCEDURE\\ OPEN TERMINAL CONNECTION; ...
   ^^PROCEDURE\\ WRITE QUESTION TO THE TERMINAL; ...
   ^^PROCEDURE\\ PROCESS FAST ANSWER; ...
   ^^PROCEDURE\\ PROCESS SLOW ANSWER; ...
.B 1
   OPEN TERMINAL CONNECTION;
   SYNCHRONIZE(1.0);
   WRITE QUESTION TO THE TERMINAL;
   QUESTIONTIME:= TIME;
   WAIT(TERMINALQUEUE);
   ^I^F TIME - QUESTIONTIME < 60.0 ^^THEN\\
   PROCESS FAST ANSWER ^^ELSE\\
   PROCESS SLOW ANSWER;
^^END\\;
.PG;.B 3;.F;.J
5.3.4##^A CONVERSATIONAL TIME-SHARING SYSTEM
.BR
#######------------------------------------
.B 1
^THE CONVERSATIONAL TIME-SHARING SYSTEM IN THIS EXAMPLE COULD
BE AN INTERPRETER FOR A LANGUAGE LIKE ^^APL\\ OR ^^FOCAL\\ OR ^^AID\\.
.B 1
^HIGHEST PRIORITY IS GIVEN TO THOSE INPUT COMMANDS WHICH ARE TO
BE PERFORMED DIRECTLY.  ^LOWER PRIORITY IS GIVEN TO INPUT
COMMANDS REQUESTING THE EXECUTION OF A STORED PROGRAM.  ^WHEN
SEVERAL STORED PROGRAMS ARE IN EXECUTION AT THE SAME TIME,
^C^P^U POWER IS DISTRIBUTED BETWEEN THEM IN A ROUND ROBIN
FASHION LETTING EACH PROGRAM PERFORM ONE STATEMENT IN THE
STORED PROGRAM BEFORE CONTINUING TO THE NEXT PROGRAM.
.B 1;.NF;.NJ
TERMINALPROCESS ^^CLASS\\ TERMINAL(FILE SPECIFICATIONS);
^^TEXT\\ FILE SPECIFICATIONS;
^^INSPECT\\ FROMTERMINAL ^D^O
^^INSPECT NEW\\ OUTFILE(FILE SPECIFICATIONS) ^D^O
^^BEGIN\\
   ^^PROCEDURE \\OPEN TERMINAL CONNECTIONS; ...
   ^^PROCEDURE\\ READ THE INPUT AND PRODUCE AN ANSWER;
   ^^BEGIN\\
      ^^BOOLEAN\\ MORE STATEMENTS, EXECUTE COMMAND;
      ^^PROCEDURE\\ READ AND INTERPRET AN INPUT LINE; ...
      ^^PROCEDURE\\ EXECUTE THE NEXT STORED PROGRAM STATEMENT;
      ...
      ^^PROCEDURE\\ PERFORM THE COMMAND FROM THE INPUT LINE; ...
      READ AND INTERPRET AN INPUT LINE;
      ^^IF NOT\\ EXECUTE COMMAND ^^THEN\\
      PERFORM THE COMMAND FROM THE INPUT LINE ^^ELSE\\
      ^^WHILE\\ MORE STATEMENTS ^D^O
      ^^BEGIN\\
         ^^HOLD(0); COMMENT\\ TO TRANSFER CONTROL TO ANOTHER
         PROCESS;
         EXECUTE THE NEXT STORED PROGRAM STATEMENT;
      ^^END\\;
   ^^END\\;
.B 1
   OPEN TERMINAL CONNECTIONS;
   ^^WHILE TRUE DO
   BEGIN\\
      WAIT(TERMINALQUEUE);
      READ THE INPUT AND PRODUCE AN ANSWER;
   ^^END\\;
^^END\\;
.PG;.B 3;.F;.J
5.3.5##^COORDINATED CONTROL OF SIMULTANEOUS REAL PROCESSES
.BR
#######--------------------------------------------------
.B 1
^WHEN A REAL TIME COMPUTER PROGRAM COMMUNICATES WITH SEVERAL
SIMULTANEOUS PROCESSES IN THE REAL WORLD, THE COMPUTER
PROGRAM MAY WANT TO CONTROL ITSELF OR THE REAL-WORLD
PROCESSES DEPENDING ON THE RESULTS IN THE VARIOUS PROCESSES.
.B 1
^EXAMPLE 1:##^A SIMULATION PROGRAM MAY WANT TO CONTINUE THE
SIMULATION WHEN ALL THE TERMINALS HAVE ANSWERED CERTAIN
QUESTIONS.
.B 1
^EXAMPLE 2:##^A PROCESS CONTROL PROGRAM MAY MONITOR SEVERAL
REAL-WORLD PROCESSES, AND INITIATE OTHER REAL-WORLD ACTIONS
WHEN PREVIOUS PROCESSES ARE READY.
.B 1
^THIS IS SIMILAR TO ^^PERT\\-NETWORKS IN PLANNING, WHERE CERTAIN
ACTIONS MUST WAIT FOR OTHER ACTIONS TO FINISH.
.B 1
^TO ILLUSTRATE THIS, A SIMPLE EXAMPLE ASSUMES A ROBOT WITH
THREE ARMS.  ^A PROCESS "PUT NAIL IN BOARD" IN INITIATED.
^THIS PROCESS INITIATES THREE SIMULTANEOUS PROCESSES, THE
FIRST ARM GETS A HAMMER, THE SECOND ARM GETS A NAIL, AND THE
THIRD ARM GETS A BOARD.  ^WHEN ALL THESE THREE PRECESSES ARE
FINISHED, THE HAMMER IS USED TO PUSH THE NAIL INTO THE
BOARD.
.B 1
^IN OTHER LANGUAGES, SPECIAL CONSTRUCTS LIKE "FORK" AND
"JOIN" ARE USED TO CREATE PARALLEL PROCESSES AND THEN
CONTINUE WHEN ALL THE PROCESSES ARE READY.  ^BUT THE SAME
THING IS VERY SIMPLE TO PROGRAM IN ^^SIMULA\\, AND IN ^^SIMULA\\ WE
DO NOT HAVE TO WTIN UNTIL A PROCESS IS FULLY FINISHED, WE
CAN ALSO EASILY START A LATER PROCESS WHEN STILL RUNNNING
.ST ^^APPENDIX A\\
.PG;.LM 0;.RM 70;.F;.J;.C
^^APPENDIX A\\
.IF FOA;.NUMBER 328;.PS 80,80;.PAGE;
.ENDIF FOA
.BR;.C
----------
.B 1
^^ISO-R 646 (=ASCII\\) ^CHARACTERS AS USED IN ^^SIMULA\\ SOURCE
PROGRAMS OUTSIDE COMMENTS.
.index ^^ISO 7 bit character set\\
.index ^^EBCDIC character set\\
.index ^^Character set\\
.index ^^ASCII 7 bit character set\\
.B 2;.TS 15,23,30,45
^CHARACTER	^MANUAL	^OCTAL	^DECIMAL	^COMMENT
.BR
---------	------	-----	-------	-------
.B 1;.LM 40;.TS 17,24,33,40;.p -40,0,5
^NULL	_^^@	000	0	^IGNORED ON SOURCE PROGRAM INPUT.
.B 1;.p -40,0,5
^CONTROL-^A	_^^A	001	1	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^B	_^^B	002	2	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^C	_^^C	003	3	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^D	_^^D	004	4	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^E	_^^E	005	5	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS
.B 1;.p -40,0,5
^CONTROL-^F	_^^F	006	6	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS
.B 1;.p -40,0,5
^BELL	_^^G	007	7	^ILLEGAL IN ^^SIMULA \\SOURCE PROGRAMS.
.B 1;.p -40,0,5
^BACKSPACE	_^^H	010	8	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^TAB	_^^I ^H^T	011	9	^ILLEGAL, BUT REPLACED BY SPACE IN
.index ^^TAB character\\
CHARACTER AND TEXT CONSTANTS, OTHERWISE A SEPARATOR.
.B 1;.p -40,0,5
^LINE ^FEED	_^^J ^L^F	012	10	^INCREMENTS LINE NUMBER#(1),
.index ^^Line number generation\\
.index ^^LINE FEED character\\
.FN 5
.B 1
---------------------------------------------------
.BR
(1)##^CERTAIN SUCCESSIONS OF THESE CHARACTERS INDICATE ONLY ONE
LINE NUMBER INCREMENTATION FOR THE WHOLE GROUP OF CHARACTERS.
.index ^^Line number generation\\
!
OTHERWISE REPLACED BY A SPACE IN CHARACTER CONSTANTS, IGNORED IN TEXT
CONSTANTS AND INTERPRETED AS A SEPARATOR OUTSIDE.
.LM 40
.TS 17,24,33,40;.p -40,0,5
^VERTICAL ^TAB	^V^T	013	11	^SEE "^LINE ^FEED"  ABOVE.
.index ^^VERTICAL TAB character\\
.index ^^Listing of program, division into pages\\
.B 1;.p -40,0,5
^FORM ^FEED	^F^F	014	12	^GIVES NEW PAGE IN PROGRAM LISTING.
.index ^^Pages, division of program listing into\\
.index ^^Listing of program, division into pages\\
.index ^^FORM FEED character\\
.B 1;.p -40,0,5
.IF FOA;.NUMBER 329;.PS 80,80;.PAGE;
.ENDIF FOA
^CARRIAGE RETURN	^C^R	015	13	^IGNORED IN TEXT CONSTANTS, TREATED AS A
.index ^^CARRIAGE RETURN character\\
.index ^^Line number generation\\
SEPARATOR OUTSIDE TEXT CONSTANTS.
.B 1;.p -40,0,5
^CONTROL-^N	_^^N	016	14	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^O	_^^O	017	15	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^P	_^^P	020	16	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^Q	_^^Q	021	17	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^R	_^^R	022	18	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^S	_^^S	023	19	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^T	_^^T	024	20	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^U	_^^U	025	21	^MONITOR COMMAND.  ^ILLEGAL
IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^V	_^^V	026	22	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^W	_^^W	027	23	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
.IF FOA;.NUMBER 330;.PS 80,80;.PAGE;
.ENDIF FOA
^CONTROL-^X	_^^X	030	24	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^Y	_^^Y	031	25	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^Z	_^^Z	032	26	^SIGNIFIES END-OF-FILE IN
INPUT DATA TO A ^^SIMULA\\ PROGRAM.  ^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^ALTMODE	_^_[	033	27	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.index ^^ALTMODE character\\

.p -40,0,5
^CONTROL-^SHIFT-^L	_^_\	034	28	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^SHIFT-^M	_^]	035	29	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^SHIFT-^N	_^_^	036	30	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.p -40,0,5
^CONTROL-^SHIFT-^O	_^__	037	31	^ILLEGAL IN ^^SIMULA\\ SOURCE PROGRAMS.
.B 1;.TS 24,33,40;.LM 40;.p -40,0,5
.IF FOA;.NUMBER 331;.PS 80,80;.PAGE;
.ENDIF FOA
^SPACE	040	32	^IGNORED IN ARITHMETIC CONSTANTS,
ACCEPTED IN TEXT AND CHARACTER CONSTANTS, OTHERWISE A SEPARATOR(2).
.FN 4
.B 1
---------------------------------------------
.BR
(2)##^THIS APPENDIX DOES NOT TREAT THE USE OF CHARACTERS IN COMMENTS.
!
.B 1;.p -40,0,5
_!	041	33	^VALID IN TEXT AND CHARACTER CONSTANTS,
ALSO AN ALTERNATIVE TO THE ^^SIMULA\\ WORD ^^COMMENT\\.
.B 1;.p -40,0,5
"	042	34	^START AND END OF TEXT CONSTANTS, DOUBLED
.index ^^Double quote (")\\
.index ^^Quote, double (")\\
INSIDE TEXT CONSTANTS, VALID INSIDE CHARACTER CONSTANTS.
.B 1;.p -40,0,5
_#	043	35	^TREATED AS A LETTER IN SOURCE
.index ^^Letter\\
PROGRAMS, ^SWEDISH LETTER "^A^E".
^EQUIVALENT TO "_{" IN IDENTIFIERS.
.index ^^Swedish letter\\
.index ^^National character\\
.B 1;.p -40,0,5
_$	044	36	^TREATED AS A LETTER IN SOURCE PROGRAMS,
^SWEDISH LETTER "^A^A".
^EQUIVALENT TO "_}" IN IDENTIFIERS.
.index ^^Swedish letter\\
.index ^^National character\\
.B 1;.p -40,0,5
%	045	37	^ONLY ALLOWED IN TEXT AND CHARACTER CONSTANTS(2).
.B 1;.p -40,0,5
_&	046	38	^USED TO INDICATE EXPONENT PART OF
.index ^^Ampersand character (_&)\\
^^[LONG]REAL\\ CONSTANTS, OTHERWISE ONLY ALLOWED IN ^^TEXT\\
AND ^^CHARACTER CONSTANTS\\(2).
.B 1;.p -40,0,5
'	047	39	^VALID INSIDE TEXT AND CHARACTER CONSTANTS,
.index ^^Single quote (')\\
.index ^^Quote, single (')\\
OTHERWISE START OF A CHARACTER CONSTANT.
.B 1;.p -40,0,5
(	050	40	^VALID INSIDE TEXT AND CHARACTER CONSTANTS.
.index ^^Parenthesises (( and ))\\
^USED IN EXPRESSIONS, FOR PROCEDURE PARAMETERS AND INDICES
AND ARRAY BOUNDS.

.p -40,0,5
)	051	41	^SEE (.
.index ^^Parenthesises (( and ))\\
.B 1;.p -40,0,5
*	052	42	^VALID INSIDE TEXT AND CHARACTER
CONSTANTS, OTHERWISE MULTIPLICATION (*) OR EXPONENTIATION OPERATOR (**).
.B 1;.p -40,0,5
.IF FOA;.NUMBER 332;.PS 80,80;.PAGE;
.ENDIF FOA
+	053	43	^VALID INSIDE TEXT AND CHARACTER
CONSTANTS, OTHERWISE ADDITION OPERATOR.
.B 1;.p -40,0,5
,	054	44	^VALID INSIDE TEXT AND CHARACTER CONSTANTS,
OTHERWISE SEPARATOR BETWEEN PARAMETERS AND BETWEEN INDICES.
.B 1;.p -40,0,5
-	055	45	^VALID INSIDE TEXT AND CHARACTER
CONSTANTS, OTHERWISE SUBTRACT AND USED IN ":-" OPERATOR.
.B 1;.p -40,0,5
_.	056	46	^VALID INSIDE TEXT AND CHARACTER
CONSTANTS, DECIMAL POINT IN REAL CONSTANTS, SEPARATES
REFERENCE VARIABLE AND CLASS PARAMETER FOR REMOTE ACCESSING.
.B 1;.p -40,0,5
/	057	47	^VALID INSIDE TEXT AND CHARACTER CONSTANTS,
OTHERWISE DIVISION AND RELATIONAL (USED IN =/=) OPERATOR.
.B 1;.p -40,0,5
0	060	48	^DIGIT.
.index ^^Digit\\
.B 1;.p -40,0,5
1	061	49	^DIGIT.
.B 1;.p -40,0,5
2	062	50	^DIGIT.
.B 1;.p -40,0,5
3	063	51	^DIGIT.
.B 1;.p -40,0,5
4	064	52	^DIGIT.
.B 1;.p -40,0,5
5	065	53	^DIGIT.
.B 1;.p -40,0,5
6	066	54	^DIGITL
.B 1;.p -40,0,5
7	067	55	^DIGIT.
.B 1;.p -40,0,5
8	070	56	^DIGIT.
.B 1;.p -40,0,5
9	071	57	^DIGIT.

.p -40,0,5
.IF FOA;.NUMBER 333;.PS 80,80;.PAGE;
.ENDIF FOA
:	072	58	^ITSELF IN TEXT AND CHARACTER CONSTANTS.
^USED TO SEPARATE LOWER AND UPPER ARRAY BOUND, USED IN
":=" AND ":-" OPERATOR.
.B 1;.p -40,0,5
;	073	59	^ITSELF IN TEXT AND CHARACTER CONSTANTS.
^SIGNIFIES END OF COMMENT, END OF DECLARATION OR END OF STATEMENT.
.B 1;.p -40,0,5
<	074	60	^ITSELF IN TEXT AND CHARACTER CONSTANTS.
^OTHERWISE COMPARATIVE OPERATOR
.B 1;.p -40,0,5
=	075	61	^ITSELF IN TEXT AND CHARACTER CONSTANTS.
^USED IN ":=" OPERATOR.
^USED FOR SEVERAL COMPARATIVE OPERATORS.
.B 1;.p -40,0,5
>	076	62	^ITSELF IN TEXT AND CHARACTER CONSTANTS.
^OTHERWISE COMPARATIVE OPERATOR.
.B 1;.p -40,0,5
?	077	63	^ITSELF IN TEXT AND CHARACTER CONSTANTS.
^OTHERWISE ILLEGAL(2).
.B 1;.p -40,0,5
@	100	64	^SWEDISH LETTER "^O^E".
^EQUIVALENT TO "_`" IN IDENTIFIERS.
.index ^^Swedish letter\\
.index ^^National character\\
.B 1;.p -40,0,5
^A	101	65	^LETTER.
.B 1;.p -40,0,5
^B	102	66	^LETTER.
.B 1;.p -40,0,5
^C	103	67	^LETTER.
.B 1;.p -40,0,5
^D	104	68	^LETTER.
.B 1;.p -40,0,5
^E	105	69	^LETTER.
.B 1;.p -40,0,5
^F	106	70	^LETTER.
.B 1;.p -40,0,5
^G	107	71	^LETTER.
.B 1;.p -40,0,5
^H	110	72	^LETTER.
.B 1;.p -40,0,5
^I	111	73	^LETTER.
.IF FOA;.NUMBER 334;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.p -40,0,5
^J	112	74	^LETTER.
.B 1;.p -40,0,5
^K	113	75	^LETTER.
.B 1;.p -40,0,5
^L	114	76	^LETTER.
.B 1;.p -40,0,5
^M	115	77	^LETTER.

.p -40,0,5
^N	116	78	^LETTER.
.B 1;.p -40,0,5
^O	117	79	^LETTER.
.B 1;.p -40,0,5
^P	120	80	^LETTER.
.B 1;.p -40,0,5
^Q	121	81	^LETTER.
.B 1;.p -40,0,5
^R	122	82	^LETTER.
.B 1;.p -40,0,5
^S	123	83	^LETTER.
.B 1;.p -40,0,5
^T	124	84	^LETTER.
.B 1;.p -40,0,5
^U	125	85	^LETTER.
.B 1;.p -40,0,5
^V	126	86	^LETTER.
.B 1;.p -40,0,5
^W	127	87	^LETTER.
.B 1;.p -40,0,5
^X	130	88	^LETTER.
.B 1;.p -40,0,5
^Y	131	89	^LETTER.
.B 1;.p -40,0,5
^Z	132	90	^LETTER.
.B 1;.p -40,0,5
[	133	91	^ITSELF INSIDE TEXT AND CHARACTER
CONSTANTS, OTHERWISE ARRAY INDEX INDICATOR.
.IF FOA;.NUMBER 335;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.p -40,0,5
_\	134	92	^ITSELF INSIDE TEXT AND CHARACTER
CONSTANTS, OTHERWISE THE "^N^O^T" OPERATOR AND USED IN THE
"_\=" OPERATOR.
.B 1;.p -40,0,5
]	135	93	^ITSELF INSIDE TEXT AND CHARACTER CONSTANTS,
OTHERWISE ARRAY INDEX INDICATOR.
.B 1;.p -40,0,5
_^	136	94	^ITSELF INSIDE TEXT AND CHARACTER
CONSTANTS, OTHERWISE EXPONENTIATION.
.B 1;.p -40,0,5
__	137	95	^ITSELF INSIDE TEXT AND CHARACTER
CONSTANTS, ALLOWED IN IDENTIFIERS.
.B 1;.p -40,0,5
_`	140	96	^SWEDISH LETTER "OE". ^EQUIVALENT TO
.index ^^Swedish letter\\
.index ^^National character\\
"_@" IN IDENTIFIERS.

.p -40,0,5
A	141	97	^LETTER. ^EQUIVALENT TO "^A" IN IDENTIFIERS.
.B 1;.p -40,0,5
B	142	98	^LETTER. ^EQUIVALENT TO "^B" IN IDENTIFIERS.
.B 1;.p -40,0,5
C	143	99	^LETTER. ^EQUIVALENT TO "^C" IN IDENTIFIERS.
.B 1;.p -40,0,5
D	144	100	^LETTER. ^EQUIVALENT TO "^D" IN IDENTIFIERS.
.B 1;.p -40,0,5
E	145	101	^LETTER. ^EQUIVALENT TO "^E" IN IDENTIFIERS.
.B 1;.p -40,0,5
F	146	102	^LETTER. ^EQUIVALENT TO "^F" IN IDENTIFIERS.
.B 1;.p -40,0,5
G	147	103	^LETTER. ^EQUIVALENT TO "^G" IN IDENTIFIERS.
.B 1;.p -40,0,5
H	150	104	^LETTER. ^EQUIVALENT TO "^H" IN IDENTIFIERS.
.IF FOA;.NUMBER 336;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.p -40,0,5
I	151	105	^LETTER. ^EQUIVALENT TO "^I" IN IDENTIFIERS.
.B 1;.p -40,0,5
J	152	106	^LETTER. ^EQUIVALENT TO "^J" IN IDENTIFIERS.
.B 1;.p -40,0,5
K	153	107	^LETTER. ^EQUIVALENT TO "^K" IN IDENTIFIERS.
.B 1;.p -40,0,5
L	154	108	^LETTER. ^EQUIVALENT TO "^L" IN IDENTIFIERS.
.B 1;.p -40,0,5
M	155	109	^LETTER. ^EQUIVALENT TO "^M" IN IDENTIFIERS.
.B 1;.p -40,0,5
N	156	110	^LETTER. ^EQUIVALENT TO "^N" IN IDENTIFIERS.
.B 1;.p -40,0,5
O	157	111	^LETTER. ^EQUIVALENT TO "^O" IN IDENTIFIERS.
.B 1;.p -40,0,5
P	160	112	^LETTER. ^EQUIVALENT TO "^P" IN IDENTIFIERS.
.B 1;.p -40,0,5
Q	161	113	^LETTER. ^EQUIVALENT TO "^Q" IN IDENTIFIERS.

.p -40,0,5
R	162	114	^LETTER. ^EQUIVALENT TO "^R" IN IDENTIFIERS.
.B 1;.p -40,0,5
S	163	115	^LETTER. ^EQUIVALENT TO "^S" IN IDENTIFIERS.
.B 1;.p -40,0,5
T	164	116	^LETTER. ^EQUIVALENT TO "^T" IN IDENTIFIERS.
.B 1;.p -40,0,5
U	165	117	^LETTER. ^EQUIVALENT TO "^U" IN IDENTIFIERS.
.IF FOA;.NUMBER 337;.PS 80,80;.PAGE;
.ENDIF FOA
.B 1;.p -40,0,5
V	166	118	^LETTER. ^EQUIVALENT TO "^V" IN IDENTIFIERS.
.B 1;.p -40,0,5
W	167	119	^LETTER. ^EQUIVALENT TO "^W" IN IDENTIFIERS.
.B 1;.p -40,0,5
X	170	120	^LETTER. ^EQUIVALENT TO "^X" IN IDENTIFIERS.
.B 1;.p -40,0,5
Y	171	121	^LETTER. ^EQUIVALENT TO "^Y" IN IDENTIFIERS.
.B 1;.p -40,0,5
Z	172	122	^LETTER. ^EQUIVALENT TO "^Z" IN IDENTIFIERS.
.B 1;.p -40,0,5
_{	173	123	^SWEDISH LETTER "AE". ^EQUIVALENT
.index ^^Swedish letter\\
.index ^^National character\\
TO "_#" IN IDENTIFIERS.
.B 1;.p -40,0,5
	174	124	^ONLY LEGAL IN TEXT AND CHARACTER CONSTANTS(2).
.B 1;.p -40,0,5
_$	175	125	^SWEDISH LETTER "AA". ^EQUIVALENT TO
.index ^^Swedish letter\\
.index ^^National character\\
"_$" IN IDENTIFIERS.
.B 1;.p -40,0,5
_~	176	126	^ONLY ALLOWED IN TEXT AND CHARACTER CONSTANTS(2).
.B 1;.p -40,0,5
^RUBOUT ^R^O	177	127	^IGNORED IN SOURCE PROGRAM INPUT.

.IFNOT FOA;.test page 16
.ENDIF FOA;.LM 0;.RM 70;.NF;.NJ
----------------------------------------------------------------------
.B 2;.LM 0;.RM 70;.F;.J
^NOTE THAT THE USE OF THE ^SWEDISH LETTERS ^A WITH TWO DOTS ABOVE IT (^^AE\\),
.index ^^Swedish letter\\
.index ^^National character\\
^A WITH A CIRCLE ABOVE IT (^^AA)\\ AND ^O WITH TWO DOTS ABOVE IT (^^OE)\\
AND THEIR LOWER CASE REPRESENTATIONS IS NOT
ALLOWED IN IDENTIFIERS ACCORDING TO THE ^^SIMULA\\ 67 ^STANDARD.
^THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ COMPILER ACCEPTS THESE LETTERS IN
IDENTIFIERS, BUT PROGRAMMERS ARE RECOMMENDED NOT TO USE
THEM IF THEY WANT THEIR PROGRAMS TO CONFORM TO THE ^^SIMULA\\
STANDARD.
.B 1
^CHARACTER CONSTANTS IN ^^SIMULA\\ ARE INITIALIZED TO ^^CHAR(0).\\
.B 1
^WHEN COMPARING TWO TEXT STRINGS OR CHARACTER CONSTANTS,
THE NUMERICAL VALUES IN THE TABLE ABOVE ARE USED.

.ST ^^APPENDIX B\\
.IFNOT FOA;.PG;
.ENDIF FOA;.C
^^APPENDIX B\\
.IF FOA;.NUMBER 338;.PS 80,80;.PAGE;
.ENDIF FOA
.BR;.C
----------
.B 1;.C
^^THE SYSTEM DEFINED PROCEDURES\\
.BR;.C
-----------------------------
.B 3
^CALLS TO SYSTEM DEFINED PROCEDURES CONFORM TO THE SYNTAX OF
CALLS TO DECLARED PROCEDURES.  ^THE IDENTIFIER OF A STANDARD
PROCEDURE MAY BE REDEFINED TO HAVE ANOTHER MEANING AT ANY BLOCK
LEVEL.  ^THE IDENTIFIER THEN ASSUMES THE NEW MEANING THROUGHOUT
THE SCOPE OF THE BLOCK.  ^STANDARD PROCEDURES ARE AVAILABLE TO
ANY ^^SIMULA\\ PROGRAM.
.B 1
^THE SYSTEM DEFINED PROCEDURES DETAILED BELOW ARE GROUPED INTO
THE FOLLOWING SECTIONS
.B 1;.LM 10
^ARITHMETIC FUNCTIONS
.index ^^Mathematical functions\\
.BR
^^CHARACTER\\ HANDLING
.BR
^RANDOM DRAWING PROCEDURES
.BR
^UTILITY PROCEDURES
.B 1;.LM 0
^FOR DETAILS OF OTHER PROCEDURES:
.B 1;.LM 0;.TS 37
FOR ^^TEXT\\ HANDLING	SEE ^CHAPTER 3, SECTION 4
.B 1
FOR ^SEQUENCING PROCEDURES	SEE ^CHAPTER 3, SECTION 1
.B 1
FOR ^PROCEDURES LOCAL TO ^^SIMSET\\	SEE ^CHAPTER 3, SECTION 2
.B 1
FOR ^PROCEDURES LOCAL TO ^^SIMULATION\\	SEE ^CHAPTER 3, SECTION 3
.B 1
FOR ^PROCEDURES LOCAL TO SUBCLASSES
.BR
####OF ^^CLASS\\ FILE	SEE ^CHAPTER 5, SECTION 5
.B 2;.LM 0;.RM 70
^A SKELETON OUTLINE OF ALL SYSTEM DEFINED PROCEDURES AND CLASSES
IS GIVEN AS ^^APPENDIX C\\.
.B 3
.IF FOA;.NUMBER 339;.PS 80,80;.PAGE;
.ENDIF FOA
^ARITHMETIC FUNCTIONS
.BR
--------------------
.B 1
^CERTAIN IDENTIFIERS, EXPRESSED AS PROCEDURES ARE DEFINED BY
.index ^^EXP function\\
THE ^^SIMULA\\ SYSTEM FOR STANDARD ARITHMETIC FUNCTIONS.
.B 1;.LM 15;.TS 15;.I -15
^^ABS(E)\\	MODULUS (ABSOLUTE VALUE) OF ^E
.index ^^ABS function\\
.B 1;.I -15
^^ARCCOS(E)#*
.index ^^Trigonometric functions\\
.index ^^COS function\\
.index ^^ARCCOS function\\
.I -15
ARCSIN(E)#*
.index ^^ARCSIN function\\
.I -15
ARCTAN(E)\\	RETURN THE PRINCIPAL VALUES OF THE ARC-COSINE,
.index ^^ARCTAN function\\
ARC-SINE, ARC-TANGENT OF ^E (THE RESULT IS MEASURED IN RADIANS)

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1;.I -15
^^COS(E)
.I -15
SIN(E)
.index ^^SIN function\\
.I -15
TAN(E)#*\\	RETURN THE COSINE, SINE, TANGENT OF ^E (^E IS
.index ^^TAN function\\
MEASURED IN RADIANS)
.B 1;.I -15
^^COSH(E)#*
.index ^^COSH function\\
.I -15
SINH(E)#*
.index ^^SINH function\\
.I -15
TANH(E)#*\\	RETURN THE HYPERBOLIC COSINE, HYPERBOLIC SINE,
.index ^^TANH function\\
.index ^^Hyperbolic functions\\
HYPERBOLIC TANGENT OF ^E
.B 1;.I -15
^^EXP(E)\\	EXPONENTIAL FUNCTION OF ^E (E_^^E).
.B 1;.I -15
^^LN(E)\\	NATURAL LOGARITHM OF ^E (LN ^E).
.index ^^Logarithm\\
.index ^^LN function\\
^IF ^E <= 0, A RUN TIME ERROR RESULTS.
.B 1;.I -15
^^SQRT(E)\\	RETURNS THE SQUARE ROOT OF ^E IF ^E >= 0.  ^IF
.index ^^Square root function\\
.index ^^SQRT function\\
^E < 0, A RUN TIME ERROR RESULTS.
.B 1;.LM 0;.RM 70
^THE ABOVE 13 FUNCTIONS OPERATE ON ARITHMETIC ARGUMENTS.  ^IF THE
TYPE OF ^E IS ^^INTEGER\\ OR ^^REAL\\, THEN THE FUNCTION VALUE IS
OF TYPE ^^REAL\\.  ^IF THE TYPE OF ^E IS ^^LONG REAL\\, THEN THE FUNCTION
.index ^^LONG REAL, availability of functions in\\
VALUE IS OF TYPE ^^LONG REAL\\.  ^HOWEVER, ^^LONG REAL\\ VERSIONS
OF THE FUNCTIONS MARKED WITH AN ASTERISK ABOVE (^^ARCCOS, ARCSIN,
TAN, COSH, SINH\\ AND ^^TANH\\) WILL NOT INITIALLY BE AVAILABLE
IN THE ^^DEC\\SYSTEM-10 ^^SIMULA\\ SYSTEM.
^THEREFORE, EVEN IF ^E IS OF TYPE ^^LONG REAL\\, THE ^^REAL\\
FUNCTION WILL BE USED AND A WARNING MESSAGE WILL BE GIVEN AT COMPILE-TIME.
.B 1;.LM 15;.TS 15;.I -15
.IF FOA;.NUMBER 340;.PS 80,80;.PAGE;
.ENDIF FOA
^^SIGN(E)\\	SIGN OF THE VALUE OF ^E
.index ^^SIGN function\\
.B 1
###1 IF ^E > 0
.BR
=##0 IF ^E = 0
.BR
##-1 IF ^E < 0
.B 1;.I -15
^^ENTIER(E)\\	LARGEST WHOLE NUMBER LESS THAN OR EQUAL TO ^E
.index ^^IFIX function\\
.index ^^INT function\\
.index ^^REAL to INTEGER conversion\\
.index ^^INTEGER from REAL conversion\\
.index ^^ENTIER function\\
.index ^^Conversion from REAL to INTEGER\\
(EQUAL TO OR TO THE LEFT OF ^E ON THE REAL AXIS).
.B 1;.LM 21;.I -6
E.G.##^^ENTIER\\(5.3)##=##5
.BR
^^ENTIER\\(-4.7)#=#-5
.BR
^^ENTIER\\(1)####=##1
.B 1;.LM 0;.RM 70;.F;.J
^THE ABOVE 2 FUNCTIONS OPERATE UPON ^^[LONG]#REAL\\ OR ^^INTEGER\\
VALUES OF ^E AND YIELD VALUES OF TYPE ^^INTEGER\\.
.B 1;.LM 15;.TS 15;.I -15
.IF FOA;.NUMBER 341;.PS 80,80;.PAGE;
.ENDIF FOA
^^MOD(M,N)\\	^M MODULO ^N, THAT IS
.index ^^MOD function\\
.index ^^Modulo function\\
.index ^^Remainder at division, function for\\
.B 1
^^M-(M//N)*N\\
.B 1;.LM 21;.I -6
E.G.##^^MOD\\#(7,3)######IS 1
.BR
^^MOD\\#(-48,5)####IS -3
.B 1;.LM 0;.RM 70
^^Note that MOD is not equivalent to the mathematical
modulo function for negative arguments.
.skip
\\^THE FUNCTION OPERATES ON ^^INTEGER\\ ARGUMENTS, ^^[LONG]REAL\\
ARGUMENTS BEING ROUNDED.  ^THE RESULT IS ^^INTEGER\\.
^WE ARE INVESTIGATING THE POSSIBILITY OF MODIFYING THE ^^MOD\\
FUNCTION FOR NEGATIVE VALUES OF ^M TO THE DEFINITION ^^M-ENTIER(M/N)*N.\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
.IF FOA;.NUMBER 342;.PS 80,80;.PAGE;
.ENDIF FOA
^^CHARACTER\\ HANDLING
.BR
------------------
.B 1
^TWO ^^CHARACTER\\ SUBSETS ARE DEFINED BY THE STANDARD PROCEDURES:
.B 1;.I 5
^^BOOLEAN PROCEDURE DIGIT(C); CHARACTER C;\\
.index ^^DIGIT, BOOLEAN PROCEDURE\\
.I 5
----------------------------------------
.B 1
WHICH IS ^^TRUE\\ IF ^C IS A DIGIT, ^^FALSE\\ OTHERWISE.
.B 1;.I 5
^^BOOLEAN PROCEDURE LETTER(C); CHARACTER C;\\
.index ^^LETTER, BOOLEAN PROCEDURE\\
.I 5
-----------------------------------------
.B 1
WHICH IS ^^TRUE\\ IF ^C IS AN UPPER OR LOWER CASE LETTER,
^^FALSE\\ OTHERWISE.
.B 1
^THE COLLATING SEQUENCE DEFINES A ONE-ONE MAPPING BETWEEN THE
^^INTEGERS\\ AND THE INTERNAL ^^CHARACTER\\ REPRESENTATION (SEE
^^APPENDIX A)\\.
.B 1;.I 5
^^INTEGER PROCEDURE RANK(C); CHARACTER C;\\
.index ^^RANK, INTEGER PROCEDURE\\
.I 5
.index ^^Conversion between CHARACTER and INTEGER\\
.index ^^CHARACTER-INTEGER conversion\\
.index ^^INTEGER-CHARACTER conversion\\
---------------------------------------
.B 1
RETURNS A VALUE IN THE RANGE 0 THROUGH 127.
.B 1;.I 5
^^CHARACTER PROCEDURE CHAR(N); INTEGER N;\\
.index ^^CHAR PROCEDURE converts integer to character\\
.I 5
--------------------------------------
.B 1
IF THE PARAMETER VALUE IS NOT IN THE RANGE 0 THROUGH 127, A
RUN TIME ERROR RESULTS.  ^OTHERWISE THE PROCEDURE RETURNS THE
^^CHARACTER\\ WITH VALUE ^N.
.B 1
^EXAMPLES:
.BR
--------
.B 1;.LM 10
^^RANK\\('+')##=##43
.BR
^^RANK\\('^A')##=##65
.BR
^^CHAR\\(57)###=#'9'
.BR
^^CHAR\\(8^R40)#=#'#'
.I -5
^^RANK(CHAR\\(127))#=#127
.B 1;.LM 10;.NF;.NJ
.IF FOA;.NUMBER 343;.PS 80,80;.PAGE;
.ENDIF FOA
^^DIGIT(C)##=##RANK(C) >= 48 AND RANK(C) <=57
DIGIT(C)##=##C >= '0' AND C <= '9'
LETTER(C)#= (C>= 'A' AND C <= 'Z')
             OR (C >= '\A' AND C <= '\Z')\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 344;.PS 80,80;.PAGE;
.ENDIF FOA
^RANDOM DRAWING PROCEDURES
.index ^^Random drawing procedures\\
.BR
-------------------------
.B 1
^THE RANDOM DRAWING PROCEDURES PRODUCE, IN SUCCESSIVE CALLS,
A STREAM OF RANDOM NUMBERS TAKEN FROM A SPECIFIED DISTRIBUTION.
^AS A SIDE EFFECT, THE PROCEDURES UPDATE THE STREAM VARIABLE ^U
(WHICH MUST ALWAYS BE AN ^^INTEGER\\ VARIABLE) THUS ADVANCING THE
SPECIFIED STREAM BY ONE STEP.
.B 1;.LM 9;.I -3
^^BOOLEAN#PROCEDURE#DRAW(A,U);#NAME#U;#REAL#A;#INTEGER#U;\\
.index ^^DRAW random drawing procedure\\
.I -3
-------------------------------------------------------
.B 1
^IF 0 < ^A < 1, THE VALUE IS ^^TRUE\\ WITH PROBABILITY ^A, ^^FALSE\\
WITH PROBABILITY 1-^A.
.B 1
^IF ^A <= 0, THE VALUE IS ALWAYS ^^FALSE\\.
.B 1
^IF ^A >= 1, THE VALUE IS ALWAYS ^^TRUE\\.
.B 2;.I -3
^^INTEGER#PROCEDURE#RANDINT(A,B,U);#NAME#U;#INTEGER#A,B,U;\\
.index ^^RANDINT random drawing procedure\\
.I -3
--------------------------------------------------------
.B 1
^IF ^A <= ^B, THE VALUE IS ONE OF THE ^^INTEGERS\\
.B 1;.I 5
^^A, A+1, A+2, ....., B-1, B\\
.B 1
WITH EQUAL PROBABILITY.
.B 1
^IF ^A > ^B, A RUN TIME ERROR RESULTS.
.B 2;.I -3
^^REAL#PROCEDURE#UNIFORM(A,B,U);#NAME#U;#REAL#A,B;#INTEGER#U;\\
.index ^^UNIFORM random drawing procedure\\
.I -3
-----------------------------------------------------------
.B 1
^IF ^A < ^B, THE VALUE IS UNIFORMLY DISTRIBUTED BETWEEN ^A AND ^B.
.B 1
^IF ^A >= ^B, A RUN TIME ERROR RESULTS.
.B 2;.I -3
.IF FOA;.NUMBER 345;.PS 80,80;.PAGE;
.ENDIF FOA
^^REAL#PROCEDURE#NORMAL(A,B,U);#NAME#U;#REAL#A,B;#INTEGER#U;\\
.index ^^NORMAL random drawing procedure\\
.I -3
----------------------------------------------------------
.B 1
^THE VALUE IS NORMALLY DISTRIBUTED WITH MEAN "^A" AND
STANDARD DEVIATION "^B".  ^AN APPROXIMATION FUNCTION IS
USED FOR THE NORMAL DISTRIBUTION.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.I -3
^^REAL#PROCEDURE#NEGEXP(A,U);#NAME#U;#REAL#A;#INTEGER#U;\\
.index ^^NEGEXP random drawing procedure\\
.I -3
------------------------------------------------------
.B 1
^IF ^A > 0, THE VALUE IS DRAWN FROM A NEGATIVE EXPONENTIAL
DISTRIBUTION WITH MEAN "1/^A".  ^THIS IS THE SAME AS A
RANDOM WAITING TIME IN A ^POISSON DISTRIBUTED ARRIVAL
PATTERN WITH AN EXPECTED NUMBER OF ARRIVALS PER TIME
UNIT EQUAL TO "^A".
.B 1
^IF ^A <= 0, A RUN TIME ERROR RESULTS.
.B 2;.I -3
^^INTEGER#PROCEDURE#POISSON(A,U);#NAME#U;#REAL#A;#INTEGER#U;\\
.index ^^POISSON random drawing procedure\\
.I -3
----------------------------------------------------------
.B 1
^THE VALUE IS A DRAWING FROM THE ^POISSON DISTRIBUTION WITH
PARAMETER "^A".
.B 1
^IF ^A > 20.0, THE VALUE IS APPROXIMATED BY
.B 1;.I 5
^^ENTIER(0.5 + NORMAL(A,SQRT(A),U)).\\
.B 1
^IF ^A < 0, THE VALUE IS ZERO.
.B 2;.I -3
^^REAL#PROCEDURE#ERLANG(A,B,U);#NAME#U;#REAL#A,B;#INTEGER#U;\\
.index ^^ERLANG random drawing procedure\\
.I -3
----------------------------------------------------------
.B 1
^IF ^A <= 0 OR ^B <= 0, A RUN TIME ERROR RESULTS.
.B 1
^IF ^A > 0 AND ^B > 0, THEN THE VALUE IS A DRAWING FROM
THE ^ERLANG DISTRIBUTION WITH MEAN "1/^A" AND STANDARD
DEVIATION "1/(^^A*SQRT(B))\\.

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.I -3
.IF FOA;.NUMBER 346;.PS 80,80;.PAGE;
.ENDIF FOA
^^INTEGER#PROCEDURE#DISCRETE(A,U);#NAME#U;#REAL#ARRAY#A;##(1)
.FOOTNOTE 3
(1)##^NOTE. ^NO CHECKING OF THE CORRECTNESS OF THE ARRAY PARAMETER
CONTENTS IS PERFORMED.
.END FOOTNOTE
.index ^^DISCRETE random drawing procedure\\
.I -3
------------------------------------------------------
.I 25
INTEGER U;\\
.I 25
----------
.B 1
^THE ONE DIMENSIONAL ^^REAL ARRAY A\\, AUGMENTED BY A UNIT
ELEMENT ONE TO THE RIGHT, IS INTERPRETED AS A STEP FUNCTION
OF THE SUBSCRIPT, DEFINING A DISCRETE (CUMULATIVE)
DISTRIBUTION FUNCTION.  ^THE FUNCTION VALUE IS AN ^^INTEGER\\
IN THE RANGE
.B 1;.I 5
"^A.LOWER BOUND" THROUGH "^A.UPPER BOUND+1"
.B 1
^IT IS DEFINED AS THE SMALLEST ^I SUCH THAT
.B 1;.I 5
^^A(I) > U\\
.B 1
WHERE ^U IS A BASIC DRAWING AND ^A(UPPER BOUND+1)#=#1.0.
.B 2;.I -3
^^REAL#PROCEDURE#LINEAR(A,B,U);#NAME#U;#REAL#ARRAY#A,B;##(1)
.index ^^LINEAR random drawing procedure\\
.I -3
-----------------------------------------------------
.I 25
INTEGER U;\\
.I 25
----------
.B 1
^THE VALUE IS A DRAWING FROM A CUMULATIVE DISTRIBUTION
FUNCTION ^F, WHICH IS OBTAINED BY LINEAR INTERPOLATION
IN A NON-EQUIDISTANT TABLE DEFINED BY ^A AND ^B, SUCH THAT
.B 1;.I 5
^^A(K)##=##F(B(I))\\
.B 1
^IT IS ASSUMED THAT ^A AND ^B ARE ONE DIMENSIONAL ^^REAL ARRAYS\\
WITH THE SAME BOUNDS, THAT THE FIRST AND LAST ELEMENTS
OF ^A ARE EQUAL TO 0.0 AND 1.0 RESPECTIVELY, AND THAT
.B 1;.I 5
^^A(I) >= A(J)\\
.I 19
FOR ^I > ^J
.I 5
^^B(I) >= B(J)\\
.PG;.I -3
^^INTEGER PROCEDURE HISTD(A,U); NAME U; REAL ARRAY A;#(1)
.index ^^HISTD random drawing procedure\\
.I -3
---------------------------------------------------
.I 25
INTEGER U;\\
.I 25
----------
.B 1
^THE VALUE IS AN ^^INTEGER\\ IN THE RANGE "^A.LOWER BOUND"
THROUGH "^A.UPPER BOUND", WHERE ^A IS A ONE DIMENSIONAL
^^REAL ARRAY\\ INTERPRETED AS A HISTOGRAM DEFINING THE
RELATIVE FREQUENCIES OF VALUES.

.B 3;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 347;.PS 80,80;.PAGE;
.ENDIF FOA
#####^UTILITY PROCEDURES
.BR
#####------------------
.B 1
.I 5
^^PROCEDURE HISTO(A,B,C,D); REAL ARRAY A,B;\\##(1)
.B 1;.I 31
^^REAL C,D;\\
.B 1
^A CALL ON ^^HISTO\\ UPDATES A HISTOGRAM DEFINED BY THE ONE
DIMENSIONAL ^^ARRAYS (INTEGER \O\R REAL) A,B\\ ACCORDING TO OBSERVATION ^C
WITH WEIGHT ^D.  ^A(^I) IS INCREMENTED BY ^D, WHERE ^I IS THE SMALLEST
^^INTEGER\\ SUCH THAT ^C#<=#^B(I).  ^IT IS ASSUMED THAT THE LENGTH OF ^A
IS ONE GREATER THAN THE LENGTH OF ^B.  ^THE LAST ELEMENT OF ^A
CORRESPONDS TO THOSE OBSERVATIONS WHICH ARE GREATER THAN ALL THE
ELEMENTS OF ^B.
.FOOTNOTE 3
(1)##^NOTE. ^NO CHECKING OF THE CORRECTNESS OF THE ARRAY PARAMETER
CONTENTS IS PERFORMED.
.END FOOTNOTE
.B 2;.I 5
^^PROCEDURE#LOWTEN(C);#CHARACTER#C;\\
.index ^^LOWTEN\\
.BR;.I 5
---------------------------------
.B 1
^WITHOUT USE OF ^^LOWTEN\\, THE ^^CHARACTER 'E' \\REPRESENTS THE EXPONENT
SIGN IN ANY NUMERIC ITEM TO EDITED OR DE-EDITED.
^A CALL ON "^^LOWTEN\\" WITH ACTUAL PARAMETER "^^EXPSIGN\\" WILL
REPLACE "^E" BY THE VALUE OF ^^EXPSIGN\\ IN FUTURE EDITING AND DE-EDITING.
^C MUST NOT BE A DIGIT, SIGN, PERIOD, OR AN ^^ASCII\\ CHARACTER WITH ^^RANK#<=#32\\ OR ^^RANK#=#127.\\


.ST ^^APPENDIX C\\
.IF FOA;.NUMBER 348;.PS 80,80;.PAGE;
.ENDIF FOA
.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.C
^^APPENDIX C\\
.C
----------
.B 1;.C
^^SKELETON OF THE SYSTEM CLASSES AND SYSTEM PROCEDURES\\
.C
----------------------------------------------------
.B 3
^CONTENTS:
.BR
--------
.B 1;.LM 10;.I -5
.IF FOA;.NUMBER 349;.PS 80,80;.PAGE;
.ENDIF FOA
^^SYSTEM DEFINED PROCEDURES
.BR
ARITHMETIC FUNCTIONS
.BR
.IF FOA;.NUMBER 350;.PS 80,80;.PAGE;
.ENDIF FOA
CHARACTER HANDLING
.BR
TEXT HANDLING
.BR
.IF FOA;.NUMBER 351;.PS 80,80;.PAGE;
.ENDIF FOA
SEQUENCING PROCEDURES
.BR
RANDOM DRAWING PROCEDURES
.BR
UTILITY PROCEDURES
.B 1;.I -5
.IF FOA;.NUMBER 352;.PS 80,80;.PAGE;
.ENDIF FOA
SYSTEM DEFINED CLASSES
.BR
CLASS SIMSET
.index ^^SIMSET\\
.BR
.IF FOA;.NUMBER 353;.PS 80,80;.PAGE;
.ENDIF FOA
CLASS SIMULATION
.index ^^SIMULATION\\
.BR
.IF FOA;.NUMBER 354;.PS 80,80;.PAGE;
.ENDIF FOA
SUBCLASSES\\ OF FILE
.B 1;.I -5
^^PROGRAM ENVIRONMENT\\
.B 2;.LM 0;.C
^^SYSTEM DEFINED PROCEDURES
.C
-------------------------
.B 1;.C
ARITHMETIC FUNCTIONS\\
.C
--------------------
.B 1;.LM 0;.RM 70;.NF;.NJ
^^*REAL PROCEDURE ABS(X); REAL X;
*REAL PROCEDURE ARCCOS(X); REAL X;
*REAL PROCESURE ARCSIN(X); REAL X;
#REAL PROCEDURE ARCTAN(X); REAL X;
#REAL PROCEDURE COS(X); REAL X;
*REAL PROCEDURE COSH(X); REAL X;
#REAL PROCEDURE EXP(X); REAL X;
#REAL PROCEDURE LN(X); REAL X;
#REAL PROCEDURE SIN(X); REAL X;
*REAL PROCEDURE SINH(X); REAL X;
#REAL PROCEDURE SQRT(X); REAL X;
*REAL PROCEDURE TAN(X); REAL X;
*REAL PROCEDURE TANH(X); REAL X;\\
.B 1;.LM 0;.RM 70;.F;.J
^N.^B.##^IF THE ACTUAL PARAMETER ON A CALL TO SOME OF THE ABOVE NON-STARRED
PROCEDURES IS ^^LONG REAL\\, THEN A ^^LONG REAL\\ RESULT WILL BE RETURNED.
.B 1;.NF;.NJ
^^INTEGER PROCEDURE ENTIER(X); REAL X;
INTEGER PROCEDURE MOD(X,Y); INTEGER X,Y;
INTEGER PROCEDURE SIGN(X); REAL X;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3;.F;.J;.C
^^CHARACTER HANDLING\\
.C
------------------
.B 2;.LM 10;.I -8
^^BOOLEAN PROCEDURE DIGIT(C);# CHARACTER C;
.I -8
BOOLEAN PROCEDURE LETTER(C); CHARACTER C;
.I -10
CHARACTER PROCEDURE CHAR(N);## INTEGER N;
.I -8
INTEGER PROCEDURE RANK(C);   CHARACTER C;
.B 3;.LM 0;.C
^^TEXT HANDLING
.C
-------------
.B 2;.LM 0
^^TEXT OBJECT GENERATION
.BR
----------------------
.B 1;.LM 10;.I -5
TEXT PROCEDURE COPY(T);   VALUE T; TEXT T;
.I -5
TEXT PROCEDURE BLANKS(N); INTEGER N;
.B 1;.LM 0
TEXT ATTRIBUTES
.BR
---------------
.B 1;.LM 10;.I -10
CHARACTER PROCEDURE GETCHAR;
.I -8
INTEGER PROCEDURE GETFRAC;
.I -8
INTEGER PROCEDURE GETINT;
.I -5
REAL PROCEDURE GETREAL;
.I -8
INTEGER PROCEDURE LENGTH;
.I -5
TEXT PROCEDURE MAIN;
.I -8
BOOLEAN PROCEDURE MORE;
.I -8
INTEGER PROCEDURE POS;
.BR
PROCEDURE PUTCHAR(C);   CHARACTER C;
.BR
PROCEDURE PUTFIX(X,N);  [LONG] REAL X; INTEGER N;
.BR
PROCEDURE PUTFRAC(I,N); INTEGER I,N;
.BR
PROCEDURE PUTINT(I);    INTEGER I;
.BR
PROCEDURE PUTREAL(X,N); [LONG] REAL X; INTEGER N;
.BR
PROCEDURE SETPOS(N);    INTEGER N;
.I -5
TEXT PROCEDURE STRIP;
.I -5
TEXT PROCEDURE SUB(I,N);     INTEGER I,N;
.B 2;.LM 0;.C
SEQUENCING PROCEDURES
.C
---------------------
.B 1;.LM 10
PROCEDURE CALL(X);     REF(\\ANYCLASS^^)X;
.BR
PROCEDURE DETACH;
.BR
PROCEDURE RESUME(Y);   REF(\\ANYCLASS^^)X;

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.C
RANDOM DRAWING PROCEDURES
.C
-------------------------
.B 1;.LM 10;.I -8
INTEGER PROCEDURE DISCRETE(A,U); NAME U; ARRAY A; INTEGER U;
.I -8
BOOLEAN PROCEDURE DRAW(A,U); NAME U; REAL A; INTEGER U;
.I -5
REAL PROCEDURE ERLANG(A,B,U); NAME U; REAL A,B; INTEGER U;
.I -8
INTEGER PROCEDURE HISTD(A,U); NAME U; ARRAY A; INTEGER U;
.I -5
REAL PROCEDURE LINEAR(A,B,U); NAME U; ARRAY A,B; INTEGER U;
.I -5
REAL PROCEDURE NEGEXP(A,U); NAME U; REAL A; INTEGER U;
.I -5
REAL PROCEDURE NORMAL(A,B,U); NAME U; REAL A,B; INTEGER U;
.I -8
INTEGER PROCEDURE POISSON(A,U); NAME U; REAL A; INTEGER U;
.I -8
INTEGER PROCEDURE RANDINT(A,B,U); NAME U; INTEGER A,B,U;
.I -5
REAL PROCEDURE UNIFORM(A,B,U); NAME U; REAL A,B; INTEGER U;
.B 2;.LM 0;.C
UTILITY PROCEDURES
.C
------------------
.B 1;.LM 10
PROCEDURE HISTO(A,B,C,D); ARRAY A,B; REAL C,D;
.BR
PROCEDURE LOWTEN(C); CHARACTER C;

.IFNOT FOA;.PG;
.ENDIF FOA;.B 2;.LM 0;.C
SYSTEM DEFINED CLASSES
.C
----------------------
.B 2
CLASS SIMSET:
.BR
------------
.B 2;.LM 0;.RM 70;.NF;.NJ
CLASS SIMSET;
BEGIN  CLASS LINKAGE;
       BEGIN  REF(LINK) PROCEDURE SUC;
              REF(LINK) PROCEDURE PRED;
              REF(LINKAGE) PROCEDURE PREV;
       END ***LINKAGE*** ;
.B 1
LINKAGE CLASS LINK;
       BEGIN  PROCEDURE OUT;
              PROCEDURE INTO(H); REF(HEAD)H;
              PROCEDURE PRECEDE(X); REF(LINKAGE)X;
              PROCEDURE FOLLOW(X); REF(LINKAGE)X;
       END ***LINK*** ;
.B 1
LINKAGE CLASS HEAD;
       BEGIN  REF(LINK) PROCEDURE FIRST;
              REF(LINK) PROCEDURE LAST;
              PROCEDURE CLEAR;
              BOOLEAN PROCEDURE EMPTY;
              INTEGER PROCEDURE CARDINAL;
       END ***HEAD*** ;
.B 1
END ***SIMSET*** ;

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
CLASS SIMULATION
----------------
.B 1
SIMSET CLASS SIMULATION;
       BEGIN  LINK CLASS PROCESS;
              BEGIN  BOOLEAN PROCEDURE IDLE;
                     BOOLEAN PROCEDURE TERMINATED;
                     REAL PROCEDURE EVTIME;
                     REF(PROCESS) PROCEDURE NEXTEV;
              END ***PROCESS*** ;
.B 1
              REF(PROCESS) PROCEDURE CURRENT;
              LONG REAL PROCEDURE TIME;
              PROCEDURE HOLD(T); REAL T;
              PROCEDURE PASSIVATE;
              PROCEDURE WAIT(Q); REF(HEAD)Q;
              PROCEDURE CANCEL(X); REF(PROCESS)X;
              PROCEDURE ACCUM(A,B,C,D); NAME A,B,C;
                                        REAL A,B,C,D;
              REF(\\MAIN PROGRAM)^^MAIN;
              <ACTIVATION\\-STATEMENTS>^^
       END;

.IFNOT FOA;.PG;
.ENDIF FOA;.B 3
SUBCLASSES \\OF FILE
------------------
.B 1
^^CLASS\\ FILE(NAME); ^^VALUE \\NAME; ^^TEXT\\ NAME;
                  ^^VIRTUAL\\ : ^^PROCEDURE OPEN, CLOSE;
.B 1
BEGIN  TEXT IMAGE;
       INTEGER PROCEDURE LENGTH;
       BOOLEAN PROCEDURE MORE;
       INTEGER PROCEDURE POS;
       PROCEDURE SETPOS(I); INTEGER I;
END ***\\FILE^^*** ;
.B 1
\\FILE^^ CLASS INFILE; VIRTUAL : BOOLEAN PROCEDURE ENDFILE;
.index ^^INFILE\\
                                     PROCEDURE IMAGE;
.B 1
BEGIN           PROCEDURE CLOSE;
        BOOLEAN PROCEDURE ENDFILE;
      CHARACTER PROCEDURE INCHAR;
                PROCEDURE INIMAGE;
        INTEGER PROCEDURE ININT;
        INTEGER PROCEDURE INFRAC;
           REAL PROCEDURE INREAL;
           TEXT PROCEDURE INTEXT(N); INTEGER N;
        BOOLEAN PROCEDURE LASTITEM;
                PROCEDURE OPEN(T); TEXT T;
END ***INFILE*** ;
.B 1
.IF FOA;.NUMBER 355;.PS 80,80;.PAGE;
.ENDIF FOA
\\FILE^^ CLASS OUTFILE; VIRTUAL : PROCEDURE OUTIMAGE;
.index ^^OUTFILE\\
BEGIN  PROCEDURE CLOSE;
       PROCEDURE OPEN(T); TEXT T;
       PROCEDURE OUTCHAR(C); CHARACTER C;
       PROCEDURE OUTFIX(R,N,W); [LONG] REAL R; INTEGER N,W;
       PROCEDURE OUTFRAC(I,N,W); INTEGER I,N,W;
       PROCEDURE OUTIMAGE;
       PROCEDURE BREAKOUTIMAGE;
       PROCEDURE OUTINT(I,W); INTEGER I,W;
       PROCEDURE OUTREAL(X,N,W); [LONG] REAL R; INTEGER N,W;
       PROCEDURE OUTTEXT(T); VALUE T; TEXT T;
END ***OUTFILE*** ;

.IFNOT FOA;.PG;
.ENDIF FOA;.B 1
OUTFILE CLASS PRINTFILE;
.index ^^PRINTFILE\\
BEGIN         PROCEDURE CLOSE;
              PROCEDURE EJECT(N); INTEGER N;
      INTEGER PROCEDURE LINE;
              PROCEDURE LINESPERPAGE(N); INTEGER N;
              PROCEDURE OPEN(T); TEXT T;
              PROCEDURE OUTIMAGE;
              PROCEDURE SPACING(N); INTEGER N;
END ***PRINTFILE*** ;
.B 1
.IF FOA;.NUMBER 356;.PS 80,80;.PAGE;
.ENDIF FOA
\\FILE^^ CLASS DIRECTFILE; VIRTUAL : PROCEDURE LOCATE OUTIMAGE, INIMAGE;
.index ^^DIRECTFILE\\
                                 BOOLEAN PROCEDURE ENDFILE;
BEGIN           PROCEDURE CLOSE;
        BOOLEAN PROCEDURE ENDFILE;
      CHARACTER PROCEDURE INCHAR;
        INTEGER PROCEDURE INFRAC;
                PROCEDURE INIMAGE;
        INTEGER PROCEDURE ININT;
      LONG REAL PROCEDURE INREAL;
           TEXT PROCEDURE INTEXT(N); INTEGER N;
        BOOLEAN PROCEDURE LASTITEM;
                PROCEDURE LOCATE(I); INTEGER I;
        INTEGER PROCEDURE LOCATION;
                PROCEDURE OPEN(T); TEXT T;
                PROCEDURE OUTCHAR(C); CHARACTER C;
                PROCEDURE OUTFIX(X,N,W); [LONG] REAL X; INTEGER N,W;
                PROCEDURE OUTFRAC(I,N,W); INTEGER I,N,W;
                PROCEDURE OUTIMAGE;
                PROCEDURE OUTINT(I,W); INTEGER I,W;
                PROCEDURE OUTREAL(X,N,W); [LONG] REAL X; INTEGER N,W;
                PROCEDURE OUTTEXT(T); VALUE T; TEXT T;
END ***DIRECTFILE*** ;\\

.IFNOT FOA;.PG;
.ENDIF FOA;.LM 0;.RM 70;.F;.J
.IF FOA;.NUMBER 357;.PS 80,80;.PAGE;
.ENDIF FOA
^^PROGRAM ENVIRONMENT\\
.BR
-------------------
.B 1
^A USER'S PROGRAM BEHAVES AS THOUGH ENCLOSED AS BELOW:##(1)
.B 1;.LM 5;.NJ;.NF
BASICIO(80,80)##^^BEGIN##INSPECT SYSIN DO
                       INSPECT SYSOUT DO\\
                          <PROGRAM>
^^              END\\
.B 1;.LM 0;.F;.J
WHERE "BASICIO" IS DEFINED BY
.B 1;.LM 5;.NJ;.NF.TS 13
^^
  CLASS\\ BASICIO(SYSINLENGTH,SYSOUTLENGTH);
  ^^INTEGER \\SYSINLENGTH,SYSOUTLENGTH;
  ^^BEGIN	REF(INFILE) PROCEDURE SYSIN;
	####SYSIN:- sysin;
	REF(OUTFILE) PROCEDURE SYSOUT;\\
	####SYSOUT:- sysout;
   FILE	^^CLASS INFILE;\\
   FILE	^^CLASS OUTFILE;\\
^^OUTFILE	CLASS PRINTFILE;\\
   FILE	^^CLASS DIRECTFILE;\\
	SYSIN :- ^^NEW INFILE("SYSIN");
	SYSIN.OPEN(BLANKS(\\SYSINLENGTH));)##(1)
.FN 4
.B 1
-----------------------------------------------------------
.BR
(1)##^THE IMAGE LENGTH OF SYSIN AND SYSOUT IS DEVICE DEPENDENT, SEE SECTION 3.5.
!
	SYSOUT :- ^^NEW OUTFILE("SYSOUT");
	^^SYSOUT.OPEN(BLANKS(\\SYSOUTLENGTH));##(1)
	^^INNER;
	SYSIN.CLOSE;
	SYSOUT.CLOSE;\\
    ^^END ***\\BASICIO*** ;
.NUMBER 1000
.if foa
.paper size 51,68
.paper size 4000,68
.endif foa
.PAGE
.LM 0
.B 3
.C
INDEX
.C
-----
.B 2
^^References in the index to the page number 1000 are to be
interpreted as references to parts II or III of the DECsystem-10
SIMULA Language Handbook.
.B 2
.index ^^Safe conversational i/o, see part III\\
.index ^^Reserved words (table) see part II\\
.index ^^Process control applications, see part III\\
.index ^^Real time applications with many terminals, see part III\\
.index ^^Multi-terminal applications, see part III\\
.index ^^Conversational i/o, see part III\\
.index ^^Data Base Handling, see part III\\
.index ^^Input-output, record oriented, see part III\\
.index ^^Binary i/o, see part III\\
.index ^^Unformatted i/o, see part III\\
.index ^^Non-formatted i/o, see part III\\
.index ^^input-output, non-formatted, binary, see part III\\
.index ^^Record oriented i/o, see part III\\
.index ^^Packing and unpacking into parts of words, see part III\\
.index ^^Data base handling, see part III\\
.index ^^Plotting, see part III\\
.index ^^Graphic terminal handling, see part III\\
.index ^^Program library, see part III\\
.index ^^Text handling utility package, see part III\\
.index ^^Concatenation of texts, see part III\\
.index ^^DIRECTFILE, see part II\\
.index ^^EXTERNAL CLASS, see part II\\
.index ^^EXTERNAL PROCEDURE, see part II\\
.index ^^File handling, DEC 10 dependent parts, see part II\\
.index ^^INFILE, see part II\\
.index ^^Input-output, DEC 10 dependent parts, see part II\\
.index ^^OUTFILE, see part II\\
.index ^^Part-compilation, see part II\\
.index ^^PRINTFILE, see part II\\
.index ^^Random access to disk file records, see part II and III\\
.index ^^Separate compilation, see part II\\
.index ^^Transput, DEC 10 dependent parts, see part II\\

.index ^^Assembly language(MACRO 10) procedures, see part II\\
.index ^^Batch jobs, see part II\\
.index ^^Compile time error messages, see part II\\
.index ^^Compiler switches, see part II\\
.index ^^Debugging system (SIMDDT), see part II\\
.index ^^DECsystem-10 dependent parts of SIMULA, see part II\\
.index ^^Diagnostics from the SIMULA system, see part II\\
.index ^^Editing of SIMULA source programs, see part II\\
.index ^^Error messages, see part II\\
.index ^^Error report form, see part II\\
.index ^^FOR statement, restrictions on, see part II\\
.index ^^FORTRAN subroutine called from SIMULA, see part II\\
.index ^^Hardware representation, see part II\\
.index ^^Line numbered source program files, see part II\\
.index ^^MACRO 10 procedure called from SIMULA, see part II\\
.index ^^Object-time error messages, see part II\\

.index ^^OPTIONS statement, see part II\\

.index ^^Restrictions in the DEC 10 SIMULA system, see part II\\
.index ^^Run-time error messages, see part II\\
.index ^^SIMDDT (Debugging system), see part II\\
.index ^^Switches to the compiler, see part II\\
.index ^^Text editing of SIMULA source programs, see part II\\
.print index
