PING
0.9
Statistical data handling and processing in production environment
|
Perform simple logical/acceptance test on a given NUMERIC or CHAR (list of) parameter(s).
par
: (list of) parameter(s) to test; can be either of NUMERIC or CHAR type;type
: (option) flag set to check whether the input parameter is NUMERIC
, INTEGER
or CHAR
; in the case type=INTEGER
, and par
is actually NUMERIC
, it is further tested whether par
is an integer or not; default: empty, i.e. the type of par
is not tested;range
: (option) range of acceptance values for the input parameter; this is a list of length <=2 of the form min max
representing the minimum and maximum values of the range ]min, max[
to be tested against par
in the case it is NUMERIC
; in the case the length of range
is 1, then only the minimum value is tested, i.e. it is regarded as range=min
; this option is incompatible with type
when type
is set to CHAR
; default: empty, i.e. no range is tested;norange
: (option) ibid for the exlusion range for the input parameter, i.e. the range ]min, max[
of values to which par
should not belong; in the case the length of range
is 1, then only the maximum value is tested, i.e. it is regarded as norange=max
default: empty, i.e. no range is tested;set
: (option) list supporting the set of acceptance values for the input parameter which will be tested against all the values in it; default: empty, i.e. no values are tested;noset
: (option) ibid for the list of exluded values for the input parameter; default: empty, i.e. no values are tested;casense
: (option) boolean flag (yes/no
) set to perform cases sensitive checking when the input parameter tested is CHAR; default: casense=no
, i.e. the checking does not take into account the cases.ans
: (list of) error codes of the test (hence of same length as par
) where for each item in par
the corresponding item in ans
is set to:
0
if the item verifies all the conditions expressed by type
, range
, norange
, set
, and/or noset
,1
if the item does not verify the conditions on type
and/or (in the case par
is of NUMERIC
type and type=INTEGER
is tested) it is also an integer,2
if the item does not verify the value conditions on noset
(e.g., par
is NUMERIC
and is listed in noset
),3
if the item does not verify the conditions on range
and/or norange
(e.g., par
is NUMERIC
and does not lie in the range range
).Simples checks can be ran over NUMERIC parameters, for instance we can test whether a parameter is a strictly positive or negative integer, e.g.:
will both return ans=0
. More practically, we can also test whether a given parameter par
is within the range ]0,10[, e.g. using:
then we will have ans=2
; we may also want to test whether that same parameter is in the range [0 10]
(i.e. including the bounds) using:
which returns ans=0
; finally, we can test whether it is an integer:
which will return ans=1
this time. To test whether it is a positive or nul value, we can simply run:
which aims in fact at testing whether par
is in the range ]0,+inf[
or equal to {0}
, and returns ans=0
. It is then possible to test several parameters together, e.g.:
which returns ans=0 1 2 1 0
since it checks the items in the list par
are integers in the range ]0,0[. As for CHAR parameters, the test consists simply in checking the inclusion of the par
string into the set formed by set
, e.g.:
will return ans=0
(since casense=no
by default).
Run %_example_par_check
for more examples.
[&a,&b]
, you shall run: so as to test in practice whether it is in the union: ]&a,&b[ U {&a,&b}
. Note that the order in set
does not matter, i.e. set=&b &a
is also accepted.
par
, the following command: tests whether par
is in the set represented by (]&a,&b[ U {&c}) \ (]&x,&y[ U {&z})
.
Wilson, S.A. (2011): "The validator: A macro to validate parameters".