~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to man/programming/if.cat

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
if              Scilab Group              Scilab Function                if
 
2
NAME
 
3
   if then else - conditional execution
 
4
  
 
5
SYNTAX
 
6
 if expr1 then statements
 
7
 elseif expri then statements
 
8
   ....
 
9
 else  statements
 
10
 end
 
11
DESCRIPTION
 
12
   The if statement evaluates a logical expression and executes a group of
 
13
  statements when the expression is true.  The  expri are expressions with
 
14
  numeric or boolean values. If expri are matrix valued the condition is
 
15
  true only if all matrix entries are true.
 
16
  
 
17
    The optional elseif and else provide for the execution of alternate
 
18
  groups of statements. An end keyword, which matches the if, terminates
 
19
  the last group of statements. The line structure given above is not
 
20
  significant, the only constraint is that each then keyword must be on the
 
21
  same line line as its corresponding if or elseif keyword. 
 
22
  
 
23
   The keyword then can be replaced by a carriage return or a comma.
 
24
  
 
25
   Warning: the number of characters used to define the body of any
 
26
  conditionnal instruction (if while for or select/case) must be limited to
 
27
  16k. 
 
28
  
 
29
EXAMPLE
 
30
    i=2
 
31
    for j = 1:3, 
 
32
       if i == j then
 
33
         a(i,j) = 2; 
 
34
       elseif abs(i-j) == 1 then 
 
35
         a(i,j) = -1; 
 
36
       else a(i,j) = 0;
 
37
       end,
 
38
    end
 
39
SEE ALSO
 
40
   while, select, boolean, end, then, else
 
41