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.

148 van Wijngaarden, etal.bb) A book is "linked" with a file by means of establish (b), create (c)or open (d). The linkage may be terminated by means of close (n), lock(o) or scratch (p).cc) When a file is "established" on a channel, then a book is generated(5.2.3) with a text of the given size, the given identification string, withputting set to true, and the logical end of the book at (1, 1, 1). Animplementation may require (g) that the characters forming theidentification string should be taken from a limited set and that the stringshould be limited in length. It may also prevent two books from having thesame string. If the establishing is completed successfully, then the value 0is returned: otherwise, some nonzero integer is returned (the value of thisinteger might indicate why the file was not established successfully).When a file is "created" on a channel, then a file is established with abook whose text has the default size for the channel and whoseidentification string is undefined.dd) When a file is "opened", then the chain of backfiles is searched forthe first book which is such that match (h) returns true. (The precisemethod of matching is not defined by this Report and will, in general, beimplementation dependent. For example, the string supplied as parameterto open may include a password of some form.) If the end of the chain ofbackfiles is reached or if a book has been selected, but putting of the bookyields true, or if putting to the book via the channel is possible and thebook is already open, then the further elaboration is undefined. If the fileis already open, an up gremlins provides an opportunity for an appropriatesystem action on the book previously linked (in case no other copy of thefile remains to preserve that linkage).ee) The routine associate may be used to associate a file with a valueof the mode specified by either ref [ ] char, ref [ ] [ ] char or ref [ ] [ ] [ ]char, thus enabling such variables to be used as the book of a file.ff) When a file is "closed", its book is attached to the chain ofbackfiles referenced by chainbfile. Some system-task is then activated bymeans of an up gremlins. (This may reorganize the chain of backfiles,removing this book, or adding further copies of it. It may also cause thebook to be output on some external device.)gg) When a file is "locked", its book is attached to the chain ofbackfiles referenced by lockedbfile. Some system-task is then activated bymeans of an up gremlins. A book which has been locked cannot be reopeneduntil some subsequent system-task has re-attached the book to thechain of backfiles available for opening.hh) When a file is "scratched", some system-task is activated bymeans of an up gremlins. (This may cause the book linked to the file to bedisposed of in some manner.)}a)b)c)d)ALGOL <strong>68</strong> Revised Report 149proc .~ undefined = int : c some sensible system action yielding aninteger to indicate what has been done; it is presumed that thesystem action may depend on a knowledge of any valuesaccessible 12.1.2.c} inside the locale of any environ which is olderthan that in which this pseudo-comment is being elaborated{notwithstanding that no ALGOL <strong>68</strong> construct written here couldaccess those values} c ;proc establish =(ref file file, string idf, channel chan, int p, l, c) int :begindown bfileprotect;PRIM book book : =(PRIMflex[l : p]flex[l : l]flex[l : c]char, (1,1,1), idf,true, 1);if file available (chan)^ (put of chan) (book)^ estab of chan^ - (pos (p, l, c) beyond max pos of chan)^ - (pos (1, 1, 1) beyondpos (p, l, c)) ^ idfok (idf)then(opened of file] up gremlins I up bfileprotect);file :=(book, text of book, chan, skip, skip,¢ state: ¢ heap bool : = false, heap bool : = true,heap bool : = false, heap bool : = false, heap bool : = true,heap pos : = (1, 1, 1), "", (standconv of chan) (book),¢ event routines: ¢ false, false, false, false, false, false,(ref file f, ref char a) bool : false);(" bin possible(file) I set char mood (file));0else up bfileprotect; undefinedfiend;proc create = (ref file file, channel chan) int :begin pos max pos = max pos of chan;establish (file, skip, chan, p of max pos, l of max pos,c of max pos)end;proc open = (ref file file, string idf, channel chan) int :begindown bfileprotect;if file available (chan)then ref ref bflle bf : = chainbfile; bool found : = false;while (ref bflle (bf) : ~: nil) ^ - found

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

Saved successfully!

Ooh no, something went wrong!