Home Online Manual
Top
Back: dbprint
Forward: deg
FastBack: Functions and system variables
FastForward: Control structures
Up: Functions
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

5.1.18 defined

Syntax:
defined ( name )
Type:
int
Purpose:
returns a value <>0 (TRUE) if there is a user-defined object with this name, and 0 (FALSE) otherwise.
A non-zero return value is the level where the object is defined (level 1 denotes the top level, level 2 the level of a first procedure, level 3 the level of a procedure called by a first procedure, etc.). For ring variables and other constants, -1 is returned.
Note:
A local object m may be identified by if (defined(m)==voice).
Example:
 
  ring r=(0,t),(x,y),dp;
  matrix m[5][6]=x,y,1,2,0,x+y;
  defined(mm);
==> 0
  defined(r) and defined(m);
==> 1
  defined(m)==voice;   // m is defined in the current level
==> 1
  defined(x);
==> -1
  defined(z);
==> 0
  defined("z");
==> -1
  defined(t);
==> -1
  defined(42);
==> -1
See rvar; voice.