Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/doc/en/html/macro/command/ifthenelseif.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6702 - (show annotations) (download) (as text)
Tue May 9 11:50:55 2017 UTC (7 years ago) by doda
File MIME type: text/html
File size: 2378 byte(s)
typo fix (macro command)
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <title>if, then, elseif, else, endif</title>
7 <meta http-equiv="Content-Style-Type" content="text/css">
8 <link rel="stylesheet" href="../../style.css" type="text/css">
9 </head>
10
11 <body>
12
13
14 <h1>if, then, elseif, else, endif</h1>
15
16 <p>
17 Conditional branching
18 </p>
19
20 <h2>1) Format 1</h2>
21
22 <pre class="macro-syntax">
23 if &lt;expression&gt; &lt;statement&gt;
24 </pre>
25
26 <h3>Remarks</h3>
27
28 <p>
29 Executes a &lt;statement&gt;, if &lt;expression&gt; is true(non-zero).
30 </p>
31
32 <h3>Example</h3>
33
34 <pre class="macro-example">
35 ; If A&gt;1, jump to ':label'.
36 if A&gt;1 goto label
37
38 ; If result&lt;&gt;0, assign 0 to A.
39 if result A=0
40 </pre>
41
42
43 <h2>2) Format 2</h2>
44
45 <pre class="macro-syntax">
46 if &lt;expression 1&gt; then
47 ...
48 (Statements for the case: &lt;expression 1&gt; is true (non-zero).)
49 ...
50 [elseif &lt;expression 2&gt; then]
51 ...
52 (Statements for the case: &lt;expression 1&gt; is false (zero) and &lt;expression 2&gt; is true.)
53 ...
54 [elseif &lt;expression N&gt; then]
55 ...
56 (Statements for the case: &lt;expression 1&gt;, &lt;expression 2&gt;,... and &lt;expression N-1&gt; are all false, and &lt;expression N&gt; is true.)
57 ...
58 [else]
59 ...
60 (Statements for the case: all the conditions above are false (zero).)
61 ...
62 endif
63 </pre>
64
65 <h3>Remarks</h3>
66
67 <p>
68 'if' and 'elseif' statements must end with 'then'.<br>
69 'elseif' and 'else' can be omitted.<br>
70 'endif' can not be omitted.
71 </p>
72
73 <h3>Example</h3>
74
75 <pre class="macro-example">
76 if a=1 then
77 b = 1
78 c = 2
79 d = 3
80 endif
81
82 if i&lt;0 then
83 i=0
84 else
85 i=i+1
86 endif
87
88 if i=1 then
89 c = '1'
90 elseif i=2 then
91 c = '2'
92 elseif i=3 then
93 c = '3'
94 else
95 c = '?'
96 endif
97 </pre>
98
99
100 <h3>*) NOTICE</h3>
101
102 <em>(version 4.90 or later)</em><br>
103 By using Format 2(if - endif), the syntax error occurs when then is not described.
104
105 <pre class="macro-example">
106 code = 100
107 if code != 100
108 messagebox 'The code value is not 100.' 'error'
109 goto error
110 else
111 messagebox 'The code value is 100.' 'OK'
112 endif
113
114 :error
115 end
116 </pre>
117
118
119 <h2>See also</h2>
120 <ul>
121 <li><a href="../syntax/expressions.html">Expressions and operators</a></li>
122 </ul>
123
124 </body>
125 </html>

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26