[back] [prev] [next] [index] [root]
 
Open
(Re)opens a file.
Syntax:
f := Open(name, mode);
ok := Open(f);
| File | 
  f    | 
 | 
| string | 
  name    | 
 | 
| string | 
  mode    | 
 | 
| boolean | 
  ok    | 
 | 
See also:  BagRead, BagWrite, Close, ECHOon, ECHOoff, FLDin, FLDout, LOFILES
Description:
The  Open function opens the file specified in the
argument  name. The type of operations you intend to
perform on the file must be given in the argument {\tt
mode}. The following table explains the values that the
 mode string can take.\medskip
\begin{tabular}{lp{7cm}}
Access mode & Interpretation \hline
 "r" & Opens file for read operations.
 "w" & Opens a new file for writing. If the file
exists, its content is destroyed.
 "a" & Opens file for appending. A new file
is created if the file does not exist.
 "R" & Opens file for {\sl unbuffered} read
operations. This mode should be used
in connection with the  FLDin
function.
\end{tabular}\medskip
If the file is successfully opened,  Open returns a
 File object  f, an object to be used in
subsequent I/O operations on the file. The  File object
is a structure which contains information about the name of
the file, the access mode and the status indicating whether
the file is opened or closed. In case of an error, {\tt
Open} returns  false.\bigskip
Example:
We will open, close and reopen a file named "dummy". 
kash> f := Open("dummy","w");
Filename: dummy / Mode: w / Open (fid): 5
kash> Close(f);
true
kash> f;
Filename: dummy / Mode: w / Closed
kash> Open(f);
true
kash> f;
Filename: dummy / Mode: w / Open (fid): 5
<- back[back] [prev] [next] [index] [root]