openfile

PURPOSE ^

Open a file in read/write mode, catching errors

SYNOPSIS ^

function fid = openfile(filename,permission)

DESCRIPTION ^

Open a file in read/write mode, catching errors
  FID = OPENFILE(FILENAME,PERMISSION) opens file FILENAME
  in PERMISSION mode ('r' or 'w') and return a file identifier FID.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fid = openfile(filename,permission)
0002 %Open a file in read/write mode, catching errors
0003 %  FID = OPENFILE(FILENAME,PERMISSION) opens file FILENAME
0004 %  in PERMISSION mode ('r' or 'w') and return a file identifier FID.
0005 
0006 %  Copyright (C) 2003 Guillaume Flandin <Guillaume@artefact.tk>
0007 %  $Revision: 1.1 $Date: 2008-09-03 08:36:22 $
0008 
0009 [fid, errmsg] = fopen(filename,permission);
0010 if ~isempty(errmsg)
0011     switch permission
0012         case 'r'
0013             error(sprintf('Cannot open %s in read mode.',filename));
0014         case 'w'
0015             error(sprintf('Cannot open %s in write mode.',filename));
0016         otherwise
0017             error(errmsg);
0018     end
0019 end

Generated on Fri 22-Aug-2008 15:38:13 by m2html © 2003