10.07.2015 Views

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!