⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rcof.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 10mar2005}{...}
{cmd:help rcof}{right:also see:  {help undocumented}}
{hline}

{title:Title}

{p 4 14 2}
{hi:rcof} {hline 2} Verify return code


{title:Syntax}

{p 8 13 2}{cmd:rcof} [{cmd:"}]{it:stata_cmd}[{cmd:"}] {it:rest_of_expression}


{pstd}
This command is intended for authors of certification scripts -- do-files
used to test that commands work properly; see {helpb cscript}.


{title:Description}

{pstd}
{cmd:rcof} executes {it:stata_cmd} and then verifies that the return code
is as indicated.


{title:Remarks}

{pstd}
In a certification script, one might purposely issue a {it:stata_cmd} that
should produce an error and then verify that the expected error is produced.
If the assertion is true, the script continues.  If the assertion is false,
the script stops.


{title:Examples}

{phang2}{cmd:. discard} {space 2} /* thus removing estimation results */{p_end}
{phang2}{cmd:. rcof "regress" == 301}

{phang2}{cmd:. rcof "regress mpg weight badvar" == 111}

{pstd}
If the return code from the command is 111, i.e., if, had you typed just
the command, you would have seen,

{phang2}{cmd:. regress mpg weight badvar}{p_end}
{phang2}{err:badvar not found}{p_end}
{phang2}{search r(111):r(111);}

{pstd}
then the certification script will continue.  Output from {it:stata_cmd} is
suppressed.  If you want to see the output (which would typically be an error
message), include {cmd:noisily} (see {helpb noisily}) in the
{it:stata_cmd}:

{phang2}{cmd:. rcof "noisily regress mpg weight badvar" == 111}

{pstd}
In that case, you will see

{phang2}{cmd:. rcof "noisily regress mpg weight badvar" == 111}{p_end}
{phang2}{err:badvar not found}

{pstd}
but the certification script will not stop.  On the other hand, here is what
happens when the return code is not as you assert:

{phang2}{cmd:. rcof "regress mpg weight badvar" == 198}

	{err}rcof:  _rc  == 198 *NOT TRUE* from
	       regress mpg weight badvar
	       _rc == 111{txt}
	{search r(9):r(9);}

{pstd}
You may omit the double quotes when {it:stata_cmd} does not contain the
characters {cmd:=}, {cmd:<}, {cmd:>}, {cmd:~}, and {cmd:!}.

{phang2}{cmd:. rcof noisily regress mpg weight badvar == 111}

    would work but

{phang2}{cmd:. rcof gen mpg = 3 == 110}

{pstd}
would not have the intended result.  In this case, you must code

{phang2}{cmd:. rcof "gen mpg = 3" == 110}

{pstd}
Omitting the double quotes is not encouraged.


{title:Also see}

{psee}
Online:  {helpb cscript}; {helpb assert}
{p_end}

⌨️ 快捷键说明

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