/* _gtvnot.ado  10-5-2000
By David Kantor, Institute for Policy Studies, Johns Hopkins University.
This is a user-added feature for Stata's egen command.
As such, it goes in c:\ado rather than c:\stata\ado\_.

This is a three-valued logic NOT function in an egen context.
It is based on the earlier tvlnot.ado, but this is now set in the context
of egen; consequently, it uses egen grammar.

This is part of a suite of three-valued logic egen utilities:
 tvnot, rtvor, rtvand, tvor, tvand.
(There are also tvlnot, tvlor, & tvland.  Those are earlier, less complete
versions, which stand as separate programs; they are not egen utilities.
These egen utilities are to be preferred.)


(This does not have "r" in the name, as do some of the others, since it is
not a "row" operation.  But it is not really a column operation either.
It is just a function, set in the egen context.)

This borrows ideas from c:\stata\ado\_\_gmax.ado and _gcount.ado.
*/

*! version 2.2  11/27/2000
program define _gtvnot
version 5.0
	
if "`1'" == " " {
local typ1 "byte"
}
else {
local typ1 ""
}
/* We use typ1 to force a type of byte as a default. 
egen sends a value of one single space if the type was not specified.
*/
	
local varlist "req new max(1)"
local exp "req nopre"
local if "opt"
local in "opt"
parse "`typ1' `*'"
tempvar x
quietly {
	gen double `x'=`exp' 
	replace `varlist'= cond(`x'==., ., ~`x') `if' `in'
}
end