5b78aac517f04e7dd311c99f8c33179833539957
[scilab.git] / scilab / modules / helptools / macros / help.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008 - INRIA - Vincent COUVERT
3 //
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution.  The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
9
10 function help(varargin)
11
12     [lhs,rhs]=argn(0);
13
14     if rhs >= 1 then
15         key = varargin(1);
16     else
17         key = "";
18     end
19
20     if (findfiles("SCI/modules/helptools/jar","*_help.jar") <> []) then
21
22         if getscilabmode() <> "NWNI" then
23
24             // No input argument: launch help browser
25             if argn(2)==0 then
26                 global %helps
27                 helpbrowser(%helps(:,1), getlanguage());
28                 return
29             end
30
31             if type(key) <> 10 then
32                 error(999,msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"help",1));
33             end
34
35             // Search a function name
36             key=stripblanks(key)
37
38             if or(part(key,1)==["(",")","[","]","{","}","%","''","""",":","*","/","\",".","<",">","&","^","|","~","+","-"]) & exists(key)==0 then
39                 key="symbols";
40             end
41
42             global %helps
43             helpbrowser(%helps(:,1), key, getlanguage(), %f);
44
45             // If the function name does not exists then full-text search is done (See Java code)
46
47         else
48             error(msprintf(gettext("%s: The help browser is disabled in %s mode.\n"), "help", getscilabmode()));
49         end
50     else
51         error(msprintf(gettext("%s: help file(.jar) is not installed.\n"), "help"));
52     end
53
54 endfunction