4.6. Miscellaneous Unknown Spots

4.6.1. Maximum variable name length

Scilab accepts variables names that are longer than 1024 characters, but only the first 24 characters are significant. The identifying string of a tlist, or mlist can have more than 1024 characters, all of which are significant. The tlist/mlist-identifier length limit when overloading functions (see Section 4.2.2) with the percent-syntax is 8 characters.

4.6.2. Starting scilex

For debugging purposes it is sometimes desirable to directly start the main Scilab binary, scilex. Scilab is usually launched via the scilab shell script. Both, the script and the binary live in the SCI/bin directory. The script takes care of setting all environment variables, and finally fires up scilex. On the other hand, if one wants to run a debugger, say gdb, or ddd, or a profiler on Scilab, then a manual invocation is the order of the day. See also Section 8.1.2.

Starting scilex directly is an option as long as the command-line editing goodies are not required, and there is no need for any graphics. Actually, for minimum functionality only the environment variable SCI must be set, then we are all set to call scilex. A bash sequence to start Scilab "manually" could look as shown in Example 4-1.

Tip

From Enrico Segre: Under Win*, runscilab can be called from DOS prompt much as scilab is in UNI*, e.g., runscilab -nw. The DOS output of commands invoked with unix go to the shell window.

Example 4-1. Manually launching scilex


lydia@orion:~$ cd /site/X11R6/src/scilab
lydia@orion:/site/X11R6/src/scilab$ SCI=`pwd`
lydia@orion:/site/X11R6/src/scilab$ export SCI
lydia@orion:/site/X11R6/src/scilab$ cd bin
lydia@orion:/site/X11R6/src/scilab/bin$ ./scilex -nw
                           ===========
                           S c i l a b
                           ===========


                          Scilab-2.5
                  Copyright (C) 1989-99 INRIA


Startup execution:
  loading initial environment

-->
   

or shorter


lydia@orion:~$ export SCI=/site/X11R6/src/scilab   
lydia@orion:~$ $SCI/bin/scilex -nw
                           ===========
                           S c i l a b
                           ===========


                          Scilab-2.5
                  Copyright (C) 1989-99 INRIA


Startup execution:
  loading initial environment

-->
   

where we are assuming that Scilab is installed in /site/X11R6/src/scilab.

4.6.3. Tuple Assignment

The most commonly used form of assignment is single variable assignment. Nonetheless, assigning multiple values in one statement is possible (and no surprise for Perl or Python programmers).


-->[x1, x2, x3] = (1, 2, 3)
 x3  =
    3.  
 x2  =
    2.  
 x1  =
    1.  

Tuple assigment works as expected, performing the whole assigment operation in one single step.

Warning

In version 2.5 the online documentation, help parents, gives the following, wrong explanatory code:

[x1, x2, ...] = (e1, e2, ...) is equivalent to x1 = e1, x2 = e2, ...

The correct explanation is

[x1, x2, ...] = (e1, e2, ...) is equivalent to first performing %t1 = e1, %t2 = e2, ..., and then x1 = %t1, x2 = %t2, ..., where the variables %ti, i = 1, 2, ... are invisible to the user.

To prove that tuple assigment works as promised, we swap the values of two variables a and b.


-->a = 1, b = 2
 a  =

    1.  
 b  =

    2.  

-->[b, a] = (a, b) // swap
 a  =

    2.  
 b  =

    1.  

What one might expect, but what does not work is multiple assignment to parts of matrices (or lists), i.e. the following code snipped does not work as naively expected


-->v = [0, 0, 0], a = 0
 v  =
!   0.    0.    0. !
 a  =
    0.

-->[a, v(1)] = (1, 2)
 Warning: obsolete use of = instead of ==
            !
                   !--error 41
incompatible LHS

The obvious, but ugly workaround is using only scalar variables on the left-hand side of a aggregate assignment, and then assigning these scalars to the appropriate matrix or list parts.

4.6.4. Dot as Member Selector

Scilab provides two different syntax constructs for the symbolic extraction/indertion of elements of a tlist. (The extraction/insertion by index numbers follows the extraction/insertion) of elements from matrices.) The documented syntax uses parenthesis and a selector string which has been defined for the specific tlist.


-->d = tlist(["dict", "key", "value"], "snafaz", 3.0 + 4.0*%i)
 d  =

       d(1)
!dict  key  value  !

       d(2)
 snafaz

       d(3)
    3. + 4.i  

-->abs( d("value") )
 ans  =
    5.  

The alternative syntax uses dots "." to seperate the name of the tlist-variable from the name of the element, uncluttering the code.


-->-real(d.value) + imag(d.value)
 ans  =
    1.  

The advantages of the string notation are: (i) The element-names can contain whitespace. (ii) Extraction/insertion under program control is easier.

Everything in this sub-sectionapplies to mlists, too.