Project

General

Profile

Fopen » History » Version 3

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