Home > source > @penlab > logfile.m

# logfile

## PURPOSE

open/close log file based on option settings (in obj.allopts)

## SYNOPSIS

function [] = logfile(obj,task)

## DESCRIPTION

     open/close log file based on option settings (in obj.allopts)
     (task==0 -> close, otherwise->open)

## CROSS-REFERENCE INFORMATION

This function calls:

- disp overloading default disp()

This function is called by:

- penlab PenLab (Pennon Laboratory for Matlab, previously PennonM)

## SOURCE CODE

    0001 % open/close log file based on option settings (in obj.allopts)
    0002 % (task==0 -> close, otherwise->open)
    0003 function [] = logfile(obj,task)
    0004
    0005   % first of all, close it if it is open
    0006   if (obj.fid~=-1)
    0007     %disp('PenLAB DBG: closing file');
    0008     fclose(obj.fid);
    0009     obj.fid=-1;
    0010   end
    0011
    0012   if (task && obj.allopts.outlev_file>0 && ~isempty(obj.allopts.out_filename))
    0013     obj.fid = fopen(obj.allopts.out_filename, 'wt');
    0014     if (obj.fid==-1)
    0015       disp('PenLAB DBG: warning: cannot open the log file');
    0016       warning('PenLAB: Cannot open the log file for writing!')
    0017     end
    0018   end
    0019