154/van Wijngaarden, et al.ALGOL <strong>68</strong> Revised Report 155g)h)i)proc .~ page ended = (ref file f) bool :(int l = l of current pos (f); l > l of book bounds (f)) ;proc .~ physical file ended = (ref file f) bool :(int p = p of current pos (f); p > p of book bounds (f)) ;proc .~ logical file ended = (ref file f) bool :(lpos of book of f beyond current pos (f)) ;10.3.1.6. Layout routines{aa) A book input from an external medium by some system-task maycontain lines and pages not all of the same length. Contrariwise, the linesand pages of a book which has been established (10:3.1.4.cc) are allinitially of the size specified by the user. However if, during output to acompressible book (10.3.1.3.ff), newline (newpage) is called with thecurrent position in the same line (page) as the logical end of the book,then that line (the page containing that line) is shortened to the characternumber (line number) of the logical end. Thus print (("abcde", newline))could cause the current line to be reduced to 5 characters in length. Notethat it is perfectly meaningful for a line to contain no characters and for apage to contain no lines.Although the effect of a channel whose books are both compressibleand of random access (10.3.1.3.ff) is well defined, it is.not anticipated thatsuch a combination is likely to occur in actual implementations.bb) The routines space (a), newline (c) and newpage (d) serve to advancethe current position to the next character, line or page, respectively. Theydo not, however, (except as provided in cc below) alter the contents of thepositions skipped over. Thus print (Ca", backspace, space)) has a differenteffect from print (Ca", backspace, blank)).The current position may be altered also by calls of backspace (b), setchar number (k) and, on appropriate channels, of set (i) and reset (j).cc) The contents of a newly established book are undefined and both itscurrent position and its logical end are at (1, 1, 1). As output proceeds, itis filled with characters and the logical end is moved forward accordingly.If, during character output with the current position at the logical end ofthe book, space is called, then a space character is written (similar actionbeing taken in the case of newline and newpage if the book is notcompressible).A call of set which attempts to leave the current position beyond thelogical end results in a call of undefined (a sensible system action mightthen be to advance the logical end to the current position, or even to thephysical end of the book). There is thus no defined way in which thecurrent position can be made to be beyond the logical end, nor in whichany character within the logical file can remain in its initial undefinedstate.dd) A reading or writing operation, or a eaU of space, newline, newpage,set or set char number, may bring the current position outside the physicalor logical file (10.3.1.5.cc, dd), but this does not have any immediateconsequence. However, before any further transput is attempted, or afurther call of space, newline or newpage (but not of set or set charnumber) is made, the current position must be brought to a "good"position. The file is "good" if, on writing (reading), the current position isnot outside the physical (logical) file (10.3.1.5.cc, dd). The page (line) is"good" if the line number (character number) has not overflowed. Theevent routine (10.3.1.3.cc) corresponding to on logical file end, on physicalfile end, on page end or on line end is therefore called as appropriate.Except in the case of formatted transput (which uses check pos,10.3.3.2.c), the default action, if the event routine returns false, is to call,respectively, undefined, undefined, newpage or newline. After this (or iftrue is returned), if the position is still not good, an event routine (notnecessarily the same one) is called again.ee) The state of the file (10.3.1.3.bb) controls some effects of thelayout routines. If the read/write mood is reading, the effect of space,newline and newpage, upon attempting to pass the logical end, is to callthe event routine corresponding to on logical file end with default actionundefined; if it is writing, the effect is to output spaces (or, in bin mood,to write some undefined character) or to compress the current line orpage (see co). If the read/write mood is not determined on entry to alayout routine, undefined is called. On exit, the read/write mood presenton entry is restored.]a) proc space = (ref file f) void :if - opened off then undefinedelsebool reading =(read mood of fl true I: write mood of fl falsel undefined; skip);(- get good line (f, reading) I undefined);ref pos cpos = cpos off;if reading then c of cpos +: = 1elseif logical file ended (f) thenif bin mood off then(text of f l (flextext t2):t2 [p of cpos ] [ l of cpos ] [ c of cpos ] :=skip);c of cpos +: = i; lpos of book off: = cposelse put char (f, ". ")flelse c of cpos +: = 1flfifl;
156van Wijngaarden, et al.ALGOL <strong>68</strong> Revised Report157b)c)d)proc backspace = (ref file f) void :if - opened off then undefinedelse ref int c = c of cpos off;(c > 1 I c -: = 1 I undefined)fi;proc newline = (rot file f) void :if - opened off then undefinedelsebool reading =(read mood of f l true I: write mood of f l falsel undefined; skip);(- get good page (f, reading) l undefined);ref pos cpos = cpos off, lpos = lpos of book off;if p of cpos = p of lpos ^ l of cpos = l of lposthen c of cpos : = c of lpos;if reading then newline (f)elseif compressible (f)then ref int pl = p of lpos, ll = l of lpos;flextext text = (text of fl (flextext t2): t2);text [pl] [ll] := text [pl] Ill] [" cof lpos - 1]else while ~ line ended (f) do space (f) odfi;cpos : = lpos : = (p of cpos, l of cpos + 1, 1)fi;fielse cpos : = (p of cpos, l of cpos + 1, 1)fiproc newpage = (rof file f) void :if - opened off then undefinedelsebool reading =(read mood of f l true I" write mood of f l false I undefined;skip);(- get good file (f, reading) I undefined);ref pos epos = cpos off, lpos = lpos of book off;if p of cpos = p of lposthen cpos : = lpos;if reading then newpage (f)elseif compressible (f) ^ I of lpos ii 1ll 1l- 1) Jfl;else while - page ended (f) do newline (f) odfi;cpos : = lpos : = (p of cpos + 1, 1, 1)flelse cpos : = (p of cpos + 1, 1, 1)fl{Each of the following 3 routines either returns true, in which case theline, page or file is good (dd), or it returns false, in which case the currentposition may be outside the logical file or the page number may haveoverflowed, or it loops until the matter is resolved, or it is terminated by ajump. On exit, the read/write mood is as determined by its readingparameter.}e) proc 9 get good line = (rof file f, bool reading) bool :begin bool not ended;while not ended : = get good page (f, reading);line ended (f) ^ not endeddo (- (line mended off) (f) l set mood (f, reading); newline (f)) od;not endedend;f) proc 9 get good page = (ref file f, bool reading) bool :begin bool not ended;while not ended := get good file (f, reading);page ended (f) ^ not endeddo (- (page mended off) (f) I set mood (f, reading); newpage (f)) od;hot endedend;g) proc 9 get good file = (rof file f, bool reading) bool :begin bool not ended : = true;while set mood (f, reading);not ended a(reading l logical file ended l physical file ended) (f)do not ended : = (reading l logical file mended offI physical file mended off) (f)od;not endedend;h) proc 9 set mood = (ref file f, bool reading) void :(reading l set read mood (f) I set write mood (f)) ;i) proc set = (rot file f, int p, l, c) void :if - opened off v ~ set possible (f) then undefinedelse bool reading =(read mood of fl true I: write mood of fl false I undefined; skip);
- Page 2 and 3:
van Wijngaarden, et al.1.1.4.2. Par
- Page 4:
Acknowledgements{Habent sua fata li
- Page 8 and 9:
14 van Wijngaarden, et al.0.3.4. Mo
- Page 10 and 11:
. . . . . . . 4 " ' 0 . . . . . . .
- Page 12 and 13:
22 van Wijngaarden, et al.• let P
- Page 14 and 15:
26 van Wijngaarden, et al.{Since so
- Page 16 and 17:
30 van Wijngaarden, et aLloperandfo
- Page 18 and 19:
34 van Wijngaarden, et al.j) WHETHE
- Page 20 and 21:
38 van Wijngaarden, et al.A protono
- Page 22 and 23:
42 van Wijngaarden, et al.d) If N i
- Page 24 and 25:
46 van Wijngaarden, et al.c) {There
- Page 26 and 27:
50 van Wijngaarden, et al.c) The ph
- Page 28 and 29: 54 van Wijngaarden, et al.3.1.1. Sy
- Page 30 and 31: 58 van Wijngaarden, et al.where (RO
- Page 32 and 33: 62 van Wijngaarden, et al.1) SOlD N
- Page 34 and 35: 66 van Wijngaarden, et al.ALGOL 68
- Page 36 and 37: 70 van Wijngaarden, et el.For each
- Page 38 and 39: 74 van Wijngaarden, et al.If 'MODE"
- Page 40 and 41: 78 J van Wijngaarden, et al.C) SECO
- Page 42 and 43: 82 van Wijngaarden, et al.ALGOL 68
- Page 44 and 45: 86 van Wijngaarden. et al.ALGOL 68
- Page 46 and 47: 90 van Wijngaarden, et al.5.4.4.1.
- Page 48 and 49: 94van Wijngaarden, et al.ALGOL 68 R
- Page 50 and 51: 98 van Wijngaarden, et al.Assignati
- Page 52 and 53: 102 van Wijngaarden, et at.{A nest,
- Page 54 and 55: 106 van Wijngaarden, et al.'HEAD's
- Page 56 and 57: 110 van Wijngaarden, et al.ALGOL 68
- Page 58 and 59: 114van Wijngaarden, et al.ALGOL 68
- Page 60 and 61: 118 van Wijngaarden, et al.ALGOL 68
- Page 62 and 63: 122 van Wijngaarden, et al.style ii
- Page 64 and 65: 126 van Wijngaarden, et al.b) The c
- Page 66 and 67: 130van Wijngaarden, et al.ALGOL 68
- Page 68 and 69: 134van Wijngaarden, et al.ALGOL 68
- Page 70 and 71: 138d)e)f)g)h)i)J)k)1)m)n)van Wijnga
- Page 72 and 73: 142 van Wijngaarden, et al.physics
- Page 74 and 75: 146 van Wijngaarden, et al.gg) On s
- Page 76 and 77: 150van Wijngaarden, et al.ALGOL 68
- Page 80 and 81: 158 van Wijngaarden, et el.fi;ref p
- Page 82 and 83: 162van Wijngaarden, et al.ALGOL 68
- Page 84 and 85: 166van Wijngaarden, et al.ALGOL 68
- Page 86 and 87: 170/van Wijngaarden, etal.ALGOL 68
- Page 88 and 89: 174J)K)L)M)N)O)P)a)b)c)d)e)van Wijn
- Page 90 and 91: 178/van Wijngaarden, et al.ALGOL 68
- Page 92 and 93: 182 van Wijngaarden, et al.• let
- Page 94 and 95: 186van Wijngaarden, et al./ALGOL 68
- Page 96 and 97: 190 van Wijngaarden, etal.composed
- Page 98 and 99: 194h)i)J)van Wijngaa(rden, et al.pr
- Page 100 and 101: 198 van Wijngaarden, et al.¢ strin
- Page 102 and 103: 202tvan Wijngaarden, et al.ALGOL 68
- Page 104 and 105: 206 van Wijngaa~den. et al.10.3.6.1
- Page 106 and 107: 210 van Wijngaarden, et al.!ALGOL 6
- Page 108 and 109: 214 van Wijngaarden, et al.inoperat
- Page 110 and 111: 218fvan Wijngaarden, et al.¢ move
- Page 112 and 113: 222 van Wijngaarden, etaL{overflow}
- Page 114 and 115: 226 van Wijngaarden, et al.ALGOL 68
- Page 116 and 117: 230max int 10.2.1.cmax real 10.2.l.
- Page 118 and 119: 234 van Wijngaarden, et al.ALGOL 68