This file is indexed.

/usr/share/doc/dpuser-doc/ifandloop.html is in dpuser-doc 3.3+p1+dfsg-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Thomas Ott">
   <title>DPUSER - The Next Generation: Conditional statements, Loops and Statement blocks</title>
 <style type="text/css" title="currentStyle">
  @import "dpuser.css";
 </style>
<link rel="shortcut icon" href="dpuser.ico" type="image/xicon">
</head>
<body>

<div id="header">DPUSER - The Next Generation</div>
<div id="menu">
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a href="history.html">History</a></li>
<li><a href="syntax.html">Syntax</a></li>
<li><a href="operators.html">Operators</a></li>
<li><a class="current" href="ifandloop.html">Structural commands</a></li>
<li><a href="variables.html">Data types</a></li>
<li><a href="plotting.html">Graphics</a></li>
<li><a href="fitsfiles.html">Fits files</a></li>
<li><a href="category.html">Category index</a></li>
<li><a href="functions.html">Function index</a></li>
<li><a href="procedures.html">Procedure index</a></li>
<li><a href="pgplot.html">Pgplot index</a></li>
<li><a href="examples.html">Examples</a></li>
<hr>
<li><a href="qfitsview.html">QFitsView documentation</a></li>
<hr>
</ul>
<form method="GET" action="search.html">
<input type="text" size=15 name="keywords">
<input type="submit" value="Search">
</form>
</div>
<div id="content">
<h1>Conditional statements, Loops and Statement blocks</h1>
DPUSER provides language elements that allow to take action only when a
certain condition is met (commonly called <tt>if-then-else</tt> statements).
Also, you can construct loops using the <tt>for</tt> and the <tt>while</tt>
constructs.
<ul>
<li>
<a href="#ifthenelse"><b><tt>if-then-else</tt></b> statements</a></li>

<li>
<a href="#loops"><b><tt>for</tt></b> and <b><tt>while</tt></b> loops</a></li>
</ul>

<h2>
<a NAME="ifthenelse"></a>Conditional statements</h2>
There are two ways to evaluate conditional statements in DPUSER, as well
as two kinds of loops. Both have in common that they can execute statement
blocks. The general syntax for a conditional statement is:
<blockquote><tt>if (boolean) {</tt>
<br><tt>&nbsp; do something</tt>
<br><tt>&nbsp; ...</tt>
<br><tt>} else {</tt>
<br><tt>&nbsp; do something else</tt>
<br><tt>&nbsp; ...</tt>
<br><tt>}</tt></blockquote>
The else part is optional.
<br>The second way to evaluate a conditional statement is using the following:
<blockquote><tt>boolean ? do this : do that</tt></blockquote>

<h3>
Examples</h3>

<blockquote><tt>if (a == 1) {</tt>
<br><tt>&nbsp; print "A is one"</tt>
<br><tt>} else {</tt>
<br><tt>&nbsp; print "A is not one but " + a</tt>
<br><tt>}</tt>
<p>The same thing in one line:
<br><tt>print "A is " + (a == 1 ? "one" : "not one but " + a)</tt></blockquote>
Note that nesting conditional statements is not allowed. Therefore, the
following code creates a syntax error:
<blockquote><tt>if (a == 1) {</tt>
<br><tt>&nbsp; print "one"</tt>
<br><tt>} else if (a == 2) {&nbsp;&nbsp; &lt;== THIS IS NOT ALLOWED</tt>
<br><tt>&nbsp; print "two"</tt>
<br><tt>} else {</tt>
<br><tt>&nbsp; print "neither one or two"</tt>
<br><tt>}</tt></blockquote>
If you want to do something like this, do the following:
<blockquote><tt>if (a == 1) {</tt>
<br><tt>&nbsp; print "one"</tt>
<br><tt>} else {</tt>
<br><tt>&nbsp; if (a == 2) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; print "two"</tt>
<br><tt>&nbsp; } else {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; print "neither one or two"</tt>
<br><tt>&nbsp; }</tt>
<br><tt>}</tt></blockquote>
Or, as a (complicated) one-liner, since nesting is allowed using the second
construct:
<blockquote><tt>print (a == 1 ? "one" : (a == 2 ? "two" : "neither one
or two"))</tt>
<br>(You can leave out all the parentesis, but for readibility it is better
to use them)</blockquote>

<h2>
<a NAME="loops"></a>Loops</h2>
A loop can be constructed using the <tt>for</tt>&nbsp; as well as the <tt>while
</tt>statements.
The general syntax for the <tt>for</tt> loop is:
<blockquote><tt>for (start_condition; boolean; change_condition) {</tt>
<br><tt>&nbsp; do something</tt>
<br><tt>&nbsp; ...</tt>
<br><tt>}</tt></blockquote>
A <tt>while</tt> loop is constructed like this:
<blockquote><tt>while (condition) {</tt>
<br><tt>&nbsp; do something</tt>
<br><tt>&nbsp; ...</tt>
<br><tt>}</tt></blockquote>

<h3>
Examples</h3>
Print out all numbers from 1 to 9
<blockquote><tt>for (i = 1; i &lt; 10; i++) print i</tt>
<p><tt>i = 1</tt>
<br><tt>while (i &lt; 10) {</tt>
<br><tt>&nbsp; print i</tt>
<br><tt>&nbsp; i++</tt>
<br><tt>}</tt></blockquote>
Note that in the second example, it is easy to create an endless loop if
you forget the <tt>i++</tt> statement. You can always use curly brackets
to execute more than one statement in a loop or as a result of a conditional
statement.
<p>Assign the ASCII character set to a string variable:
<blockquote><tt>s = ""</tt>
<br><tt>for (i = 32; i &lt;= 255; i++) s += char(i)</tt></blockquote>

</div>
<div id="copyright">
Copyright &copy; Thomas Ott ---- DPUSER - The Next Generation 3.3 (Rev. )
</div>
</body>
</html>