* Bug 15433 fixed: getPreferencesValue() => xmlGetValues() in [xml]
[scilab.git] / scilab / modules / preferences / help / en_US / setPreferencesValue.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
5  *
6  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
8  * This file is hereby licensed under the terms of the GNU GPL v2.0,
9  * pursuant to article 5.3.4 of the CeCILL v.2.1.
10  * This file was originally licensed under the terms of the CeCILL v2.1,
11  * and continues to be available under such terms.
12  * For more information, see the COPYING file which you should have received
13  * along with this program.
14  *
15  -->
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="setPreferencesValue" xml:lang="en">
17     <refnamediv>
18         <refname>setPreferencesValue</refname>
19         <refpurpose>Set preferences value</refpurpose>
20     </refnamediv>
21     <refsynopsisdiv>
22         <title>Syntax</title>
23         <synopsis>
24             setPreferencesValue(xpath, key_value [, doc])
25         </synopsis>
26     </refsynopsisdiv>
27     <refsection>
28         <title>Arguments</title>
29         <variablelist>
30             <varlistentry>
31                 <term>xpath</term>
32                 <listitem>
33                     <para>a string, represents the XPath request to get the node in the preferences file.</para>
34                 </listitem>
35             </varlistentry>
36             <varlistentry>
37                 <term>key_value</term>
38                 <listitem>
39                     <para>a 2xN matrix of strings, the key-values to set.</para>
40                 </listitem>
41             </varlistentry>
42         </variablelist>
43         <variablelist>
44             <varlistentry>
45                 <term>doc</term>
46                 <listitem>
47                     <para>a mlist typed XMLDoc, the XML document associated to the preference file.
48                     </para>
49                 </listitem>
50             </varlistentry>
51         </variablelist>
52     </refsection>
53     <refsection>
54         <title>Description</title>
55         <para>
56             Set the values of the attributes in preferences file (<literal>SCIHOME+'/XConfiguration.xml'</literal>).
57         </para>
58         <warning>
59             Modifying incorrectly some preferences can alter Scilab's behaviour.
60         </warning>
61         <para>
62             When doc is specified, the values are searched in this document. It is useful when several requests need to be done to avoid to parse again and again the same configuration file.
63         </para>
64         <para>
65             All valid XPath requests are possible. For example to write the XPath request to set proxy settings:
66         </para>
67         <simplelist type="inline">
68             <member>
69                 <para>
70                     Open the file <literal>SCIHOME+'/XConfiguration.xml'</literal> and gets the nodes names to access to the expected node:
71                 </para>
72                 <programlisting role="xml"><![CDATA[
73 <?xml version="1.0" encoding="utf-8" standalone="no"?>
74 <interface height="600" path="1/" version="0.17" width="800">
75     <general title="_(General)">
76     ...
77     </general>
78     <web title="_(Web)">
79         <body>
80             <web command-browser="" command-mailer="" default-browser="true" default-mailer="true"/>
81             <proxy enabled="false" host="" password="" port="" user=""/>
82             <previous-proxy enabled="false" host="" password="" port="" user=""/>
83         </body>
84     </web>
85     ...
86 </interface>
87               ]]></programlisting>
88                 <para>
89                     The path will be <literal>"/interface/web/body/proxy"</literal> (or to simplify <literal>"//web/body/proxy"</literal>).
90                 </para>
91             </member>
92         </simplelist>
93     </refsection>
94     <refsection>
95         <title>Examples</title>
96         <programlisting role="example"><![CDATA[
97 // Get the current values
98 prev = xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]);
99 setPreferencesValue("//web/body/proxy", ["enabled", "host", "port"; "true", "my.proxy.org", "1234"]);
100
101 // Ok that's work
102 xmlGetValues("//web/body/proxy", ["enabled", "host", "port"])
103
104 // We restore the previous values
105 setPreferencesValue("//web/body/proxy", ["enabled", "host", "port" ; prev]);
106 xmlGetValues("//web/body/proxy", ["enabled", "host", "port"])
107  ]]></programlisting>
108     </refsection>
109     <refsection role="see also">
110         <title>See also</title>
111         <simplelist type="inline">
112             <member>
113                 <link linkend="xmlGetValues">xmlGetValues</link>
114             </member>
115         </simplelist>
116     </refsection>
117 </refentry>