X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fmissing-functions-1.0.2%2F__matlabfunctionlist__.m;fp=octave_packages%2Fmissing-functions-1.0.2%2F__matlabfunctionlist__.m;h=c3a019d7291717e466fd6a13c26508d04e189495;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/missing-functions-1.0.2/__matlabfunctionlist__.m b/octave_packages/missing-functions-1.0.2/__matlabfunctionlist__.m new file mode 100644 index 0000000..c3a019d --- /dev/null +++ b/octave_packages/missing-functions-1.0.2/__matlabfunctionlist__.m @@ -0,0 +1,92 @@ +## Copyright (C) 2008 Bill Denney +## +## This software is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## This software is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this software; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{funlist}, @var{funloc}, @var{catlist}, @var{catloc}, @var{catlvl}] =} __matlabfunctionlist__ (@var{url}) +## Return a list of matlab functions, @var{funlist}, from the @var{url}. +## It will also return the list of locations of the functions within the +## file, the categories in the url (@var{catlist}), the location of the +## categories within the url (@var{catloc}), and the level of the +## categories (@var{catlvl}, 2 = h2, 3 = h3, ...). Note, the locations +## may not be sorted or unique. +## @end deftypefn + +function [funlist, funloc, catlist, catloc, catlvl] = __matlabfunctionlist__ (url = "http://www.mathworks.com/access/helpdesk/help/techdoc/ref/f16-6011.html") + + [raw, success, message] = urlread(url); + if (! success) + warning ("__matlabfunctionlist__:url", + "__matlabfunctionlist__: Could not read\n%s\n%s", url, message); + funlist = {}; + funloc = []; + catlist = {}; + catloc = []; + catlvl = []; + return + endif + ## Building up a really rough single-purpose XML parser + + ## Tags + tagopen = find (raw == "<"); + tagclose = find (raw == ">"); + ## categories + h2loc = findstr (raw, " tmpfunloc(i), 3)(3))+1: + tagopen(find (tagopen > tmpfunloc(i), 3)(3))-1); + ## convert all whitespace to actual spaces + tmpfunname(isspace (tmpfunname)) = " "; + if (numel (tmpfunname) > 2) + tmpfunname = split (tmpfunname, ", "); + endif + for j = 1:rows (tmpfunname) + idx++; + funlist{idx} = strtrim (tmpfunname(j,:)); + funloc(idx) = tmpfunloc(i); + endfor + endfor + +endfunction + +function name = getname (raw, loc, tagopen, tagclose) + + name = cell (size (loc)); + for i = 1:numel (loc) + name{i} = raw(tagclose(find (tagclose > loc(i), 1))+1:tagopen(find (tagopen > loc(i), 1))-1); + endfor + +endfunction