<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 02/03/2016 12:24, David Chèze a
      écrit :<br>
    </div>
    <blockquote cite="mid:1456917849551-4033598.post@n3.nabble.com"
      type="cite">
      <pre wrap="">Hi all,

I would like to define a variable in a user module in such a way that this
constant would be available for all functions (also out of the module) as a
"hidden(you don't need to see it inbrowsvar), protected (should not be
possible to clear it, even with clearglobal )" global variable as soon the
module is loaded: do you have suggestions how to do it within scilab?</pre>
    </blockquote>
    <br>
    There is still no actual solution to protect variables against
    clear.<br>
    But you may do the following:<br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(100,174,100);font-style:italic;">// Save that in set_constantes.sci and build a library with it, thanks to genlib()</span>, say constantes_lib
<span style="color:rgb(176,24,19);">function</span> <span style="color:rgb(0,0,0);">set_constantes</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">L0</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(0,0,0);">;</span> <span style="color:rgb(0,0,0);">L0</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(0,0,0);">who</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">local</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span> 
    <span style="color:rgb(0,0,0);">c0</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">299792458</span>
    <span style="color:rgb(0,0,0);">avog</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">6.022045e23</span>
    <span style="color:rgb(0,0,0);">planck</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">6.626176e-34</span>
    <span style="color:rgb(0,0,0);">qproton</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">1.6022e-19</span>
    <span style="color:rgb(0,0,0);">L0</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(0,0,0);">setdiff</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">who</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">local</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(0,0,0);">L0</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(0,0,0);">execstr</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">[</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(0,0,0);">strcat</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">L0</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">] = resume(</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(0,0,0);">strcat</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">L0</span>,<span
 style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">+</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">)</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span>
<span style="color:rgb(176,24,19);">endfunction

</span></pre>
    <span style="color:rgb(176,24,19);"><font color="#000000">// In your
        scilab.ini/.scilab : </font></span><br>
    <span style="color:rgb(176,24,19);"><font color="#000000">load(path_to_set_constantes_sci+"/lib")</font></span><br>
    <span style="color:rgb(176,24,19);"></span><br>
    <span style="color:rgb(176,24,19);"><font color="#000000">// Where
        you need constantes:</font></span><br>
    <span style="color:rgb(176,24,19);"><font color="#000000">set_constantes()<br>
        <br>
      </font></span><span style="color:rgb(176,24,19);"><font
        color="#000000">// Then use the constantes defined in
        set_constantes()</font></span><br>
    <span style="color:rgb(176,24,19);"></span><br>
    <span style="color:rgb(176,24,19);"><font color="#000000">The main
        advantage with this is that you don't need to remember where
        set_constantes.sci is stored (to exec() it).</font></span><br>
    <span style="color:rgb(176,24,19);"><font color="#000000">But
        nothing is protected: neither the library, nor set_constantes(),
        nor the constantes it defines.<br>
      </font></span><br>
    <span style="color:rgb(176,24,19);"></span><tt>--> clear avog</tt><tt><br>
    </tt><tt>--> set_constantes()</tt><tt><br>
    </tt><tt>--> avog</tt><tt><br>
    </tt><tt> avog  = </tt><tt><br>
    </tt><tt>   6.022D+23</tt><tt><br>
    </tt><br>
    HTH<br>
    Samuel<br>
    <br>
  </body>
</html>