aboutsummaryrefslogtreecommitdiff
path: root/pkg/language/doc/break.hlp
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /pkg/language/doc/break.hlp
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/language/doc/break.hlp')
-rw-r--r--pkg/language/doc/break.hlp49
1 files changed, 49 insertions, 0 deletions
diff --git a/pkg/language/doc/break.hlp b/pkg/language/doc/break.hlp
new file mode 100644
index 00000000..fce2cf9f
--- /dev/null
+++ b/pkg/language/doc/break.hlp
@@ -0,0 +1,49 @@
+.help break Feb86 language
+.ih
+NAME
+break -- break out of a loop
+.ih
+USAGE
+break
+.ih
+DESCRIPTION
+The \fIbreak\fR statement is used to exit (break out of) the \fIfor\fR or
+\fIwhile\fR loop in which it is found. In the case of nested loop constructs
+only the innermost loop is terminated.
+Unlike C usage the \fIbreak\fR statement does not break out of a switch.
+.ih
+EXAMPLES
+1. Scan a list (file), printing each list element until either the list is
+exhausted or a list element "exit" or "quit" is encountered.
+
+.nf
+ while (fscan (list, s1) != EOF) {
+ if (s1 == "exit" || s1 == "quit")
+ break
+ print (s1)
+ }
+.fi
+
+
+2. Sum the pixels in a two dimensional array, terminating the sum for each
+line if a negative pixel is encountered, and terminating the entire process
+when the total sum passes a predefined limit.
+
+.nf
+ total = 0
+ for (i=1; i <= NCOLS; i+=1) {
+ for (j=1; j <= NLINES; j+=1) {
+ if (pixel[i,j] < 0)
+ break # exit the J loop
+ total += pixel[i,j]
+ }
+ if (total > NPHOT)
+ break # exit the I loop
+ }
+.fi
+.ih
+BUGS
+.ih
+SEE ALSO
+next, while, for
+.endhelp