File: evstr.sci

package info (click to toggle)
scilab 5.3.3-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 330,656 kB
file content (80 lines) | stat: -rw-r--r-- 1,912 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
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
// Copyright (C) DIGITEO - 2010 - Allan CORNET
//
// 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


function [%val, %ierr] = evstr(%str)

  [lhs, rhs] = argn(0);
  %val = [];
  select type(%str)

  case 10 then
    // matrix of character strings

    // bug 7003
    if ~isdef('Nan') then
      Nan = %nan;
    end
    if ~isdef('NaN') then
      NaN = %nan;
    end

    if ~isdef('Inf') then
      Inf = %inf;
    end

    if ~isdef('INF') then
      INF = %inf;
    end

    for %l = 1:size(%str, 'r')
      %t1(%l) = strcat(%str(%l, :), ',') + ';'
    end
    %t1(1) = '%val=[' + %t1(1);
    %t1($) = part(%t1($), 1:length(%t1($)) - 1) + ']';
    if lhs == 2 then
      %ierr = execstr(%t1, 'errcatch');
    else
      execstr(%t1)
    end
    
  case 15 then
    // list
    %sexp = %str(2),
    %nstr = prod(size(%sexp));
    % = list();
    if lhs == 2 then
      for %k_ = 1:%nstr,
        [%w, %ierr] = evstr(%sexp(%k_));
        %(%k_) = %w;
        if %ierr <>0  then
         %val = [];
         return;
        end
      end
      [%val, %ierr] = evstr(%str(1));
    else
      for %k_ = 1:%nstr,
        %(%k_) = evstr(%sexp(%k_));
      end
      %val = evstr(%str(1))
    end
    
  case 1 then
    // real or complex constant matrix
    %val = %str;
    %ierr = 0;
  else
    error(msprintf(gettext("%s: Wrong type for input argument #%d: Real or Complex matrix, Matrix of character strings or list expected.\n"), "evstr", 1));
  end
  if exists('%val', 'local') == 0 then
    error(msprintf(gettext("%s: Given expression has no value.\n"), "evstr"));
  end
endfunction