File: add_help_chapter.sci

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (134 lines) | stat: -rw-r--r-- 4,079 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL
// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt

// Parameters
//
// title      : A string array - Chapter title 
// path       : A string array - Chapter path 
// modulemode : A boolean      - %F by default
//                             - if TRUE, the chpater is consider as internal module online help,
//                               otherwise, it's consider as external online help,

// Description
//
// This function adds a new entry in the helps list. The help chapter files are to
// be located in a single directory. If the given path already exists in the helps
// list, nothing is done. The function checks if the directory exist.

function ok = add_help_chapter(helptitle,path,modulemode)
	
	ok = [];
	
	// Check input arguments
	// =========================================================================
	
	[lhs,rhs] = argn(0);
	
	// Input arguments number
	// -------------------------------------------------------------------------
	
	if rhs < 2 | rhs > 3 then
		error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"add_help_chapter",2,3));
	end
	
	// Input arguments types
	// -------------------------------------------------------------------------
	
	if type(helptitle) <> 10 then
		error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"add_help_chapter",1));
	end
	
	if type(path) <> 10 then
		error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"add_help_chapter",2));
	end
	
	if (rhs>2) & (type(modulemode) <> 4) then
		error(msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"add_help_chapter",3));
	end
	
	// Input arguments dimensions
	// -------------------------------------------------------------------------
	
	if or( size(helptitle) <> size(path) ) then
		error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"add_help_chapter",1,2));
	end
	
	// Default value
	// =========================================================================
	
	if rhs < 3 then
		modulemode = %F;
	end
	
	if modulemode then
		global %helps_modules;
		this_help = %helps_modules;
	else
		global %helps;
		this_help = %helps;
	end
	
	// Save the current path
	// =========================================================================
	current_directory = pwd();
	
	// Loop on "path"
	// =========================================================================	
	path = pathconvert(path,%F);
	
	for i=1:size(path,"*") 
		
		ok(i) = %F;
		
		// Get the absolute path of "path"
		// ---------------------------------------------------------------------
		
		if ~isdir(path(i)) then 
			chdir(current_directory);
			error(msprintf(gettext("%s: Wrong value for input argument #%d: An existing directory expected.\n"),"add_help_chapter",2));
		end
		
		chdir(path(i));
		
		if MSDOS then
			path(i) = getlongpathname(pwd());
		else
			path(i) = pwd();
		end
		
		// Check if the path is already added
		// ---------------------------------------------------------------------
		
		if find( this_help(:,1) == path(i)) <> [] then
			continue;
		end
		
		this_help = [ this_help ; path(i) helptitle(i) ];
		
		ok(i) = %T;
	end
	
	// Go to the original location
	// =========================================================================	
	chdir(current_directory);
	
	// Reshape ok
	// =========================================================================	
	ok = matrix(ok,size(path));
	
	// That's all
	// =========================================================================
	if modulemode then
		%helps_modules = this_help;
	else
		%helps = this_help;
	end
	
endfunction