Project

General

Profile

Fopen » History » Revision 2

Revision 1 (Per Amundsen, 02/10/2014 09:48 PM) → Revision 2/4 (Per Amundsen, 12/29/2019 05:05 PM)

_Added in 1.8.10_ 

 */fopen [-nox] [-no] <handle> <filename>* 

 Opens the specified file and assigns a name to it for later reference. The open fails if the file does not exist. 

 *Switches* 

 -n - Creates the file if it does not exists, fails if the file exists. 
 -o - Creates a new file, overwrites if it exists. 
 -x - Opens the file in exclusive access. 

 *Parameters* 

 <handle> - Handle to assign the file. 
 <filename> - Path/Filename to open. 

 *Example* 

 <pre> 
 alias fopen_example { 
   ;Open hello.txt file. 
   /fopen -n h hello.txt 

   ;Error check 
   if ($ferr) { 
     /echo -sce info * /fopen_example: $err 
     /halt 
   } 

   ;Write 'Hello There' to the file. 
   /fwrite h Hello There 

   ;Close the handle. 
   /fclose h 

   ;Open file in default editor. 
   /run hello.txt 
 } 
 </pre>