
testargs - controls parameter testing

Calling sequence:
testargs([ bool ])

Parameter:

bool   --  Boolean value

Summary:

testargs is used to control parameter testing in procedures. Very often when
a procedure is called by the user its parameters are to be tested, whereas when
procedures are called by other procedures this is not necessary (assuming that
the programming is error-free).

With testargs the user can determine if a program was directly called by
the user or by another procedure and then carry out the relevant test. The
expression testargs(), in general, returns TRUE when it was executed in
a procedure called on the interactive level, i.e. by the user.  However, if
testargs() was called by another procedure then the expression returns
FALSE. The user is able to control the testing of parameters as follows:

p := proc(x)
  local ...;

begin
   if testargs() then
     test parameter x...
   end_if;

   The actual algorithm follows here...
end_proc;

Above we mentioned the condition \"in general":  testargs has two states,
the normal state as described above and a test state.  In the test state the
expression testargs() always returns TRUE, i.e. the parameters are always
tested. This is useful during trouble shooting when programming.

  o  The test state is set with testargs(TRUE). The call returns FALSE if
     testargs was already in normal state.

  o  The normal state is reset with testargs(FALSE). The call returns TRUE
     if testargs was already in test state.

testargs is a kernel function.

>>  p1 := proc() begin
        if testargs() then "test" else "no test" end_if
    end_proc:
    p2 := proc() begin p1() end_proc:
    p1(), p2();

      "test", "no test"

>>  testargs(TRUE), p1(), p2();

      FALSE, "test", "test"

See also:  args

