Project

General

Profile

Fopen » History » Version 1

Per Amundsen, 02/10/2014 09:48 PM

1 1 Per Amundsen
_Added in 1.8.10_
2
3
*/fopen [-no] <handle> <filename>*
4
5
Opens the specified file and assigns a name to it for later reference. The open fails if the file does not exist.
6
7
*Switches*
8
9
-n - Creates the file if it does not exists, fails if the file exists.
10
-o - Creates a new file, overwrites if it exists.
11
12
*Parameters*
13
14
<handle> - Handle to assign the file.
15
<filename> - Path/Filename to open.
16
17
*Example*
18
19
<pre>
20
alias fopen_example {
21
  ;Open hello.txt file.
22
  /fopen -n h hello.txt
23
24
  ;Error check
25
  if ($ferr) {
26
    /echo -sce info * /fopen_example: $err
27
    /halt
28
  }
29
30
  ;Write 'Hello There' to the file.
31
  /fwrite h Hello There
32
33
  ;Close the handle.
34
  /fclose h
35
36
  ;Open file in default editor.
37
  /run hello.txt
38
}
39
</pre>