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.

144/van Wijngaarden, et al.ALGOL <strong>68</strong> Revised Report 145then the assignment to the field of intape violates the scoperestriction, since the scope of the routine (ref file file) boo/: goto f issmaller than the scope of intape, so he has to write:begin int n : = O; file auxin : = intape;on logical file end (auxin, (ref file file) bool : goto f);do get (auxin, Ioc int); n +: = 1 od;f: print (n)end.• on physical file end. The corresponding event routine is called whenthe current page number of the file exceeds the number of pages in thebook and further transput is attempted (see 10.3.1.6.dd).• onpageend. The corresponding event routine is called whenthe current line number exceeds the number of lines in the current pageand further transput is attempted (see 10.3.1.6.dd).• on line end. The corresponding event routine is called whenthe current character number of the file exceeds the number ofcharacters in the current line and further transput is attempted (see10.3.1.6.dd).Example:The programmer wishes automatically to give a heading at the startof each page on his file f:on page end (f, proc (ref file file) bool :(put (file, (newpage, "page number ", whole (i +: = 1, 0),newline)); frue)¢ it is assumed that i has been declared elsewhere ¢) .• on charerror. The corresponding event routine is called when acharacter conversion was unsuccessful or when, during input, acharacter is read which was not "expected" (10.3.4.1.11). The eventroutine is called with a reference to a character suggested as areplacement. The event routine provided by the programmer mayassign some character other than the suggested one. If the eventroutine returns true, then that suggested character as possibly modifiedis used.Example:The programmer wishes to read sums of money punched as"$123.45", ".$23.45", "..$3.45", etc.:on char error (stand in, (ref file f, ref char sugg) bool :if sugg = "0"then char c; backspace (f); get (f, c);(c = "$"1 get (f, sugg); gruel false)else falsefl );int cents; readf (($ 3z ","ridS, cents))• on value error. The corresponding event routine is called when:(i) during formatted transput an attempt is made to transput a valueunder the control of a "picture" with which it is incompatible, or whenthe number of "frames" is insufficient. If the routine returns true, thenthe current value and picture are skipped and transput continues; ifthe routine returns false, then first, on output, the value is output by •put, and next undefined is called;(ii) during input it is impossible to convert a string to a value of somegiven mode (this would occur if, for example, an attempt were made toread an integer larger than max int (10.2.1.c)).• on format end. The corresponding event routine is called when,during formatted transput, the format is exhausted while some valuestill remains to be transput. If the routine returns true, then undefinedis called if a new format has not been provided for the file by theroutine; otherwise, the current format is repeated.dd) The cony field of a file is its current conversion key (10.3.1.2.bb).After opening a file, a default conversion key is provided. Some otherconversion key may be provided by the programmer by means of a call ofmake conv (j). Note that such a key must have been provided in thelibrary-prelude.ee) The routine maketerm is used to associate a string with a file.This string is used when inputting a variable number of characters, any ofits characters serving as a terminator.ff) The available methods of access to a book which has been openedon a file may be discovered by calla of the following routines (note that theyield of such a call may be a function of both the book and the channel,and of other environmental factors not defined by this Report):• get possible, which returns true if the file may be used for input:• put possible, which returns true if the file may be used for output:• bin possible, which returns true if the file may be used for binarytransput:• compressible, which returns true if lines and pages will becompressed (lO.3.l.6.aa) during output, in which case the book is saidto be "compressible";• reset possible, which returns true if the file may be reset, i.e., itscurrent position set to (1, 1, 1);• set possible, which returns true if the file may be set, i.e., the currentposition changed to some specified value: the book is then said to be a"random access" book and, otherwise, a "sequential access" book:• reidfpossible, which returns true if the idf field of the book may bechanged;y• chan, which returns the channel on which the file has been opened(this may be used, for example, by a routine assigned byon physical file end, in.order to open another file on the same channel}.

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

Saved successfully!

Ooh no, something went wrong!