📄 m2_break.hlp
字号:
{smcl}
{* 18mar2005}{...}
{cmd:help m2 break}
{hline}
{* index for tt}{...}
{* index while tt}{...}
{* index do ... while tt}{...}
{* index break tt}{...}
{title:Title}
{p 4 4 2}
{bf:[M-2] break -- Break out of for, while, or do loop}
{title:Syntax}
{cmd:for}, {cmd:while}, {it:or} {cmd:do {c -(}}
...
{cmd:if (}...{cmd:) {c -(}}
...
{cmd:break}
{cmd:{c )-}}
{cmd:{c )-}}
{it:stmt} <- {cmd:break} {it:jumps here}
...
{title:Description}
{p 4 4 2}
{cmd:break} exits the innermost {cmd:for}, {cmd:while}, or {cmd:do} loop.
Execution continues with the statement immediately following the close of the
loop, just as if the loop had terminated normally.
{p 4 4 2}
{cmd:break} nearly always occurs following an {cmd:if}.
{title:Remarks}
{p 4 4 2}
In the following code,
{cmd}for (i=1; i<=rows(A); i++) {
for (j=1; j<=cols(A); j++) {
{txt}...{cmd}
if (A[i,j]==0) break
}
printf("j = %d\n", j)
}{txt}
{p 4 4 2}
the {cmd:break} statement will be executed if any element of {cmd:A[i,j]} is
zero. Assume that the statement is executed for {cmd:i}=2 and {cmd:j}=3.
Execution will continue with the {cmd:printf()} statement, which is to say,
the {cmd:j} loop will be canceled but the {cmd:i} loop will continue.
The value of {it:j} upon exiting the loop will be 3; when you break out
of the loop, the {cmd:j++} is not executed.
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-2] break}
{p 4 13 2}
Online: help for
{bf:{help m2_for:[M-2] do}},
{bf:{help m2_for:[M-2] for}},
{bf:{help m2_while:[M-2] while}},
{bf:{help m2_continue:[M-2] continue}};
{bf:{help m2_intro:[M-2] intro}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -