Project

General

Profile

Fopen » History » Version 2

Per Amundsen, 12/29/2019 05:05 PM

1 1 Per Amundsen
_Added in 1.8.10_
2
3 2 Per Amundsen
*/fopen [-nox] <handle> <filename>*
4 1 Per Amundsen
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 2 Per Amundsen
-x - Opens the file in exclusive access.
12 1 Per Amundsen
13
*Parameters*
14
15
<handle> - Handle to assign the file.
16
<filename> - Path/Filename to open.
17
18
*Example*
19
20
<pre>
21
alias fopen_example {
22
  ;Open hello.txt file.
23
  /fopen -n h hello.txt
24
25
  ;Error check
26
  if ($ferr) {
27
    /echo -sce info * /fopen_example: $err
28
    /halt
29
  }
30
31
  ;Write 'Hello There' to the file.
32
  /fwrite h Hello There
33
34
  ;Close the handle.
35
  /fclose h
36
37
  ;Open file in default editor.
38
  /run hello.txt
39
}
40
</pre>