Home > atmlab > files > fileopen.m

fileopen

PURPOSE ^

FILEOPEN Open file with error message if not succesful.

SYNOPSIS ^

function fid = fileopen(filename,varargin)

DESCRIPTION ^

 FILEOPEN   Open file with error message if not succesful.

    This function calls *fopen* to open the given file, and gives an error
    if the file could not be opened. This function saves you the trouble
    of checking the file identified returned by *fopen*.

 FORMAT   See *fopen*.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

fileopen.m

SOURCE CODE ^

0001 % FILEOPEN   Open file with error message if not succesful.
0002 %
0003 %    This function calls *fopen* to open the given file, and gives an error
0004 %    if the file could not be opened. This function saves you the trouble
0005 %    of checking the file identified returned by *fopen*.
0006 %
0007 % FORMAT   See *fopen*.
0008 
0009 % 2002-12-20   Created by Patrick Eriksson.
0010 % 2012-05-24   Improved by Gerrit Holl.
0011 
0012 function fid = fileopen(filename,varargin)
0013                                                                            %&%
0014 %= Check input                                                             %&%
0015 %                                                                          %&%
0016 rqre_nargin( 1, nargin );                                                  %&%
0017 rqre_datatype( filename, @ischar );                                        %&%
0018 
0019 
0020 %= Call fopen
0021 %
0022 [fid, message] = fopen( filename, varargin{:} );
0023 
0024 
0025 %= Was open succesful?
0026 %
0027 if fid < 0
0028   error(['atmlab:' mfilename ':IOError'], 'Could not open file %s: %s', filename, message );
0029 end
0030 
0031 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005