This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Checking objects

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


prog::check(object, <infolevel>, options)


The call prog::check(object) checks the MuPAD® object object. object may be a procedure, a function environment, or a domain. One may also give a list of such objects.

If All is given as first parameter, all defined procedures, function environments and domains are checked (see anames).

infolevel determines the amount of information given while checking. The following values are useful:

  • 1

    summarizing number of warnings per checked object, if at least one warning occurs (default)

  • 2

    as 1, but a short message is printed even if no warning was produced

  • 3

    summary of warnings per checked object

  • 5

    displays each checked object, followed by individual warnings, followed by a summary and the number of warnings, if any.

  • 10 15

    additional outputs (for debugging/information)

options can be any of the described options.

With option All, all are checked. Without options, the set {Domain, Global, Interface, Level, Local, Protect, Save} is used.


The arguments of hold expressions are not checked.


Example 1

The following function contains a number of mistakes, some of which were actually legal in previous versions of MuPAD.

Lines 1 and 2 contains declarations of local variables. In line 4 an undeclared (global) variable g is used. Line 7 applies level to a local variable (the call simply returns the value of X in MuPAD 2.0). Line 10 contains an assignment to a formal parameter. This parameter will be overwritten and its old value lost:

f:= proc(X, Y)                //  1  Local
      local a, b;             //  2  Local
    begin                     //  3
      g:= proc(X)             //  4  Global
            option hold;      //  5
          begin               //  6
            a:= level(X, 2);  //  7  Level
            a:= a + X         //  8
          end_proc;           //  9
      Y:= g(Y);               // 10  Assign, Global
prog::check(f, 3)
Critical usage of 'level' on local variable ' [f]
Function 'level' applied to variables: {X} in [f, proc in 'f']
Global idents: {g} in [f]
Unused local variables: {b} in [f]
Warnings: 3 [f]

Only search for global variables, but give more messages:

prog::check(f, 5, Global)
Checking f (DOM_PROC)
  Global variable 'g' in [f]
  Global variable 'g' in [f]
  Global idents: {g} in [f]
  Warnings: 1 [f]

Now check everything:

prog::check(f, 5, All)
Checking f (DOM_PROC)
  Global variable 'g' in [f]
  Critical usage of 'level' on local variable ' [f]
  Function 'level' applied to variables: {X} in [f, proc in 'f']
  Procedure environment of [f] used by [f, proc in 'f']
  Assignment to formal parameter 'Y' in [f].
  Global variable 'g' in [f]
  Global idents: {g} in [f]
  Unused local variables: {b} in [f]
  Unused formal parameters: {X} in [f]
  Assignments to formal parameters: {Y} in [f]
  Warnings: 8 [f]

Global variables declared with the option “save” are allowed:

f:= proc(X)                   //  1  Local
      save g;                 //  2  Save
    begin                     //  3
      g:= X
prog::check(f, 2, Global, Save)
Warnings: 0 [f]



Procedure, function environment or domain to check, the identifier All, or a list of objects


Positive integer that determines the completeness of messages



Enables all known options


Report unknown global identifiers


Report unused local variables

These are variables that were declared by local, but never used in the procedure.


Report unused local variables and unused formal parameters

The same as Local, but the same check is additionally performed for formal parameters of a procedure. Those are the argument names as given in the definition of the procedure.


Report assignments to formal parameters of procedures

Because a formal parameter will be overwritten, those assignments could indicate a programming error (however, not imperative).


The application of level to local variables is reported. Starting with MuPAD 2.0, local variables are simply replaced by their values on evaluation and calling level on them does not have any effect.


Report undefined entries of domains (uses the slot "undefinedEntries")


Information about undefined entries of a domain interface are printed, i.e., entries in the domain interface, that are not defined as entries of the domain.


Information about assignments to environment variables of MuPAD are printed. These assignments could change the global behavior of MuPAD if the change is not undone (preferably using save, to catch error conditions).


Information about assignments to protected variables of MuPAD are printed.


A message about a global identifier is suppressed, when the checked object is a procedure and the identifier is saved with option “save”.


Information about some special cases are printed. Currently, the only implemented special case is assignments to HISTORY.


prog::check prints warnings about procedures which may require the option escape.

Return Values

prog::check returns the void object null(). Output messages are printed on the screen.

Was this topic helpful?