Project

General

Profile

Fopen » History » Version 4

Per Amundsen, 02/22/2023 04:52 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 4 Per Amundsen
_See also [[/fclose]], [[/fwrite]], [[/fseek]], [[/flist]], [[$fread]], [[$fgetc]], [[$feof]], [[$ferr]], [[$fopen]]._
8
9 1 Per Amundsen
*Switches*
10
11 3 Per Amundsen
table(ktable).
12
|*Switch*|*Description*|
13
| -n | Creates the file if it does not exists, fails if the file exists. |
14
| -o | Creates a new file, overwrites if it exists. |
15
| -x | Opens the file in exclusive access. |
16 1 Per Amundsen
17
*Parameters*
18
19 3 Per Amundsen
table(ktable).
20
|*Parameter*|*Description*|
21
| <handle> | Handle to assign the file. |
22
| <filename> | Path/Filename to open. |
23 1 Per Amundsen
24
*Example*
25
26
<pre>
27
alias fopen_example {
28
  ;Open hello.txt file.
29
  /fopen -n h hello.txt
30
31
  ;Error check
32
  if ($ferr) {
33
    /echo -sce info * /fopen_example: $err
34
    /halt
35
  }
36
37
  ;Write 'Hello There' to the file.
38
  /fwrite h Hello There
39
40
  ;Close the handle.
41
  /fclose h
42
43
  ;Open file in default editor.
44
  /run hello.txt
45
}
46
</pre>