Difference between revisions of "Fopen"

From Scriptwiki
Jump to: navigation, search
(added category:commands)
m
 
Line 28: Line 28:
 
This will create "moo oo.txt" on C:\ and open it with the name moo. If moo.txt already existed on C:\, it fails.
 
This will create "moo oo.txt" on C:\ and open it with the name moo. If moo.txt already existed on C:\, it fails.
  
 +
== See Also ==
 +
* [[Fclose|/fclose]] to close an open file handler.
 +
* [[Why and how to use File Handlers]]
  
 
[[Category:File Handling]][[Category:Commands]]
 
[[Category:File Handling]][[Category:Commands]]

Latest revision as of 09:59, 2 July 2007

Opens the specified file and assigns a name to it for later reference.

/fopen [-no] <name> <filename>


If the file doesn't exist, the opening fails (if -n switch isn't specified).

Explanation of the switches:

Switch Meaning
n creates the file if it doesn't already exist, fails if the file does exist.
o creates a new file, overwrites if it exists.


Note that if /fopen fails, the script will continue to run. To check whether it failed or not, you have to take a look at $ferr and $feof. It also echos it to the active window: * fopen unable to open '<name>' (<filename>), however, if you want to make it silent, use .fopen.

Example

/fopen version version.txt

This will "open" the file version.txt in your mircdirectory and assings the name "version" to it. If it doesn't exist in your mircdirectory, /fopen will fail (and echo it to the active window).


/fopen -n moo "C:\moo oo.txt"

This will create "moo oo.txt" on C:\ and open it with the name moo. If moo.txt already existed on C:\, it fails.

See Also