From: <prn...@us...> - 2010-08-18 21:35:35
|
Revision: 7555 http://octave.svn.sourceforge.net/octave/?rev=7555&view=rev Author: prnienhuis Date: 2010-08-18 21:35:28 +0000 (Wed, 18 Aug 2010) Log Message: ----------- Improved logic for opening files to avoid unneeded error message clutter in the terminal Modified Paths: -------------- trunk/octave-forge/main/io/inst/xlsread.m trunk/octave-forge/main/io/inst/xlswrite.m Modified: trunk/octave-forge/main/io/inst/xlsread.m =================================================================== --- trunk/octave-forge/main/io/inst/xlsread.m 2010-08-18 21:33:58 UTC (rev 7554) +++ trunk/octave-forge/main/io/inst/xlsread.m 2010-08-18 21:35:28 UTC (rev 7555) @@ -122,6 +122,8 @@ ## 2009-12-29 bug fixes ## 2010-01-12 added unwind_protect to get rid of stray Excel invocations i.c.o. COM errors ## 2010-05-31 Updated help text (delays i.c.o. empty range due to getusedrange call) +## 2010-08-18 Added check for existence of xls after call to xlsopen to +## avoid unneeded error message clutter function [ numarr, txtarr, rawarr, lims ] = xlsread (fn, wsh, datrange, reqintf=[]) @@ -151,13 +153,17 @@ reqintf= "JXL"; printf ("BASIC (BIFF5) support request translated to JXL. \n"); endif + + if (nargout < 1) printf ("Warning: no output spreadsheet file pointer specified as argument.\n"); endif # Checks done. Get raw data into cell array "rawarr". xlsopen finds out # what interface to use. If none found, suggest csv unwind_protect # Needed to catch COM errors & able to close stray Excel invocations # Get pointer array to Excel file + xls_ok = 0; xls = xlsopen (fn, 0, reqintf); + xls_ok = 1; if (strcmp (xls.xtype, 'COM') || strcmp (xls.xtype, 'POI') || strcmp (xls.xtype, 'JXL')) @@ -184,7 +190,7 @@ unwind_protect_cleanup # Close Excel file - xls = xlsclose (xls); + if (xls_ok) xls = xlsclose (xls); endif end_unwind_protect Modified: trunk/octave-forge/main/io/inst/xlswrite.m =================================================================== --- trunk/octave-forge/main/io/inst/xlswrite.m 2010-08-18 21:33:58 UTC (rev 7554) +++ trunk/octave-forge/main/io/inst/xlswrite.m 2010-08-18 21:35:28 UTC (rev 7555) @@ -93,6 +93,8 @@ ## 2010-01-04 (Adapted range capacity checks to OOXML) ## 2010-01-12 (Bug fix; added unwind_protect to xlsopen...xlsclose calls) ## 2010-01-15 Fixed typos in texinfo +## 2010-08-18 Added check for existence of xls after call to xlsopen to +## avoid unneeded error message clutter function [ rstatus ] = xlswrite (filename, arr, arg3, arg4, arg5) @@ -152,12 +154,14 @@ endif unwind_protect # Needed to besure Excel can be closed i.c.o. errors + xls_ok = 0; xls = xlsopen (filename, 1, reqintf); + xls_ok = 1; [xls, rstatus] = oct2xls (arr(1:nr, 1:nc), xls, wsh, topleft); unwind_protect_cleanup - xls = xlsclose (xls); + if (xls_ok) xls = xlsclose (xls); endif end_unwind_protect This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |