deblank and empty arguments
Ben Abbott
bpabbott at mac.com
Tue Jan 29 05:13:06 CST 2008
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
More information about the Help-octave
mailing list