📄 mf_st_updata.hlp
字号:
{smcl}
{* 28mar2005}{...}
{cmd:help mata st_updata()}
{hline}
{* index st_updata()}{...}
{title:Title}
{p 4 4 2}
{bf:[M-5] st_updata() -- Determine or set data-have-changed flag}
{title:Syntax}
{p 8 12 2}
{it:real scalar}
{cmd:st_updata()}
{p 8 12 2}
{it:void}{bind: }
{cmd:st_updata(}{it:real scalar value}{cmd:)}
{title:Description}
{p 4 4 2}
{cmd:st_updata()} returns 0 if the data in memory have not changed
since they were last saved, and returns 1 otherwise.
{p 4 4 2}
{cmd:st_updata(}{it:value}{cmd:)} sets the data-have-changed flag
to 0 if {it:value}==0 and 1 otherwise.
{title:Remarks}
{p 4 4 2}
Stata's {cmd:describe} command reports whether the data have changed since
they were last changed. Stata's {cmd:use} command refuses to load a new dataset
if the data currently in memory have not been saved since they were last
saved. Other components of Stata also react to the data-have-changed flag.
{p 4 4 2}
{cmd:st_updata()} allows you to respect that same flag.
{p 4 4 2}
In addition, as a Mata programmer, it is your responsibility to set the flag if
your function changes the data in memory. Mata attempts to set the flag for
you (for instance, when you add a new variable using
{bf:{help mf_st_addvar:[M-5] st_addvar()}}), but there are other places where
the flag ought to be set, and it is your responsibility to do so. For
instance, Mata does not set the flag every time you change a value in the
dataset. Setting the flag what may be many thousands of times would reduce
performance too much.
{p 4 4 2}
Moreover, even when Mata does set the flag, it might do so inappropriately,
because the logic of your program fooled Mata. For instance, perhaps you
added a variable and later dropped it. In such cases, the appropriate
code is
{cmd:priorupdatavalue = st_updata()}
...
{cmd:st_updata(priorupdatavalue)}
{title:Conformability}
{cmd:st_updata()}:
{it:result}: 1 {it:x} 1
{cmd:st_updata(}{it:value}{cmd:)}:
{it:value}: 1 {it:x} 1
{it:result}: {it:void}
{title:Diagnostics}
{p 4 4 2}
None.
{title:Source code}
{p 4 4 2}
Function is built-in.
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-5] st_updata()}
{p 4 13 2}
Online: help for
{bf:{help m4_stata:[M-4] stata}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -