help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: deblank and empty arguments


From: Ben Abbott
Subject: Re: deblank and empty arguments
Date: Tue, 29 Jan 2008 06:13:06 -0500


On Jan 29, 2008, at 3:34 AM, H. Wziontek wrote:

Hello,

I'd like to propose, that the function deblank should return
the argument itself instead of an error message if an empty
value is provided. Sometimes it can happen, that a value is
not defined, but for some reason, all values are "deblanked"
inside a loop. A script should not stop in such a case with
an error. Below my suggestion to change the code.

Hartmut


*** deblank.m.orig      Tue Jan 22 17:54:13 2008
--- deblank.m   Tue Jan 29 09:16:10 2008
*************** function s = deblank (s)
*** 34,39 ****
--- 34,41 ----
       print_usage ();
     endif

+   if (!isempty (s))
+
       if (ischar (s))

         k = find (! isspace (s) & s != "\0");
*************** function s = deblank (s)
*** 51,54 ****
--- 53,58 ----
         error ("deblank: expecting string argument");
       endif

+   endif
+
   endfunction
______________

I thought I'd compare to Matlab

>> deblank('')
ans =
     ''
>> deblank([])
ans =
     []
>>

Which is consistent with your patch.

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]