m2_if.hlp

来自「是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到」· HLP 代码 · 共 95 行

HLP
95
字号
{smcl}
{* 09feb2005}{...}
{cmd:help m2 if}
{hline}
{* index if tt}{...}

{title:Title}

{p 4 4 2}
{bf:[M-2] if -- if (exp) ... else ...}


{title:Syntax}

	{cmd:if (}{it:exp}{cmd:)} {it:stmt1}


	{cmd:if (}{it:exp}{cmd:)} {it:stmt1}
	{cmd:else} {it:stmt2}


	{cmd:if (}{it:exp}{cmd:) {c -(}}
		{it:stmts1}
	{cmd:{c )-}}
	{cmd:else {c -(}}
		{it:stmts2}
	{cmd:{c )-}}


	{cmd:if (}{it:exp1}{cmd:)} ...
	{cmd:else if (}{it:exp2}{cmd:)} ...
	{cmd:else if (}{it:exp3}{cmd:)} ...
	...
	{cmd:else} ...


{p 4 4 2}
where {it:exp}, {it:exp1}, {it:exp2}, {it:exp3}, ..., must evaluate to real
scalars.


{title:Description}

{p 4 4 2}
{cmd:if} evaluates the expression, and if it is true (evaluates to a nonzero 
number), {cmd:if} executes the statement or statement block that immediately
follows it; otherwise, {cmd:if} skips the statement or block.

{p 4 4 2}
{cmd:if} ... {cmd:else} 
evaluates the expression, and if it is true (evaluates to a nonzero 
number), {cmd:if} executes the statement or statement block that immediately
follows it and skips the statement or statement block following the 
{cmd:else}; otherwise it skips the statement or statement block immediately
following it and executes the statement or statement block following the 
{cmd:else}.


{title:Remarks}

{p 4 4 2}
{cmd:if} followed by multiple {cmd:else}s is interpreted as being nested, 
i.e., 

	{cmd:if (}{it:exp1}{cmd:)} ...
	{cmd:else if (}{it:exp2}{cmd:)} ...
	{cmd:else if (}{it:exp3}{cmd:)} ...
	...
	{cmd:else} ...

{p 4 4 2}
is equivalent to

	{cmd:if (}{it:exp1}{cmd:)} ...
	{cmd:else {c -(}}
		{cmd:if (}{it:exp2}{cmd:)} ...
		{cmd:else {c -(}}
			{cmd:if (}{it:exp3}{cmd:)} ...
			{cmd:else {c -(}}
				...
			{cmd:{c )-}}
		{cmd:{c )-}}
	{cmd:{c )-}}


{title:Also see}

{p 4 13 2}
Manual:  {hi:[M-2] if}

{p 4 13 2}
Online:  help for 
{bf:{help m2_intro:[M-2] intro}}
{p_end}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?