File: append_openw.doc

package info (click to toggle)
hol88 2.02.19940316dfsg-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 65,816 kB
  • sloc: ml: 199,939; ansic: 9,666; sh: 6,913; makefile: 6,032; lisp: 2,747; yacc: 894; sed: 201; cpp: 87; awk: 5
file content (39 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (11)
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
30
31
32
33
34
35
36
37
38
39
\DOC append_openw

\TYPE {append_openw : (string -> string)}

\SYNOPSIS
Opens a port for appending to a named file.

\KEYWORDS
file.

\DESCRIBE
When applied to a filename {`name`}, the function {append_openw} opens the file
{name} for writing, such that existing contents are appended to rather than
overwritten. It returns a port descriptor string, which can be used by {write}
to append to the file, and by {close} to close it.

\EXAMPLE
The following example assumes that HOL is being run under Unix. It will
overwrite an existing file {test-file} in the current directory.
{
   #system `echo -n 'Hello ' >test-file`;;
   0 : int

   #let port = append_openw `test-file`;;
   port = `%test-file` : string

   #write(port,`world`);;
   () : void

   #close port;;
   () : void

   #system `cat test-file`;;
   Hello world0 : int
}
\SEEALSO
close, openi, openw, read, write.

\ENDDOC