type

AutoCad AutoLISP Functions

 
type
 
 
 

Returns the type of a specified item

(type item)

Arguments

item

A symbol.

Return Values

The data type of item. Items that evaluate to nil (such as unassigned symbols) return nil. The data type is returned as one of the atoms listed in the following table:

Data types returned by the type function

Data type

Description

ENAME

Entity names

EXRXSUBR

External ObjectARX applications

FILE

File descriptors

INT

Integers

LIST

Lists

PAGETB

Function paging table

PICKSET

Selection sets

REAL

Floating-point numbers

SAFEARRAY

Safearray

STR

Strings

SUBR

Internal AutoLISP functions or functions loaded from compiled

(FAS or VLX) files

Functions in LISP source files loaded from the AutoCAD Command prompt may also appear as SUBR

SYM

Symbols

VARIANT

Variant

USUBR

User-defined functions loaded from LISP source files

VLA-object

ActiveX objects

Examples

For example, given the following assignments:

(setq a 123 r 3.45 s "Hello!" x '(a b c))
(setq f (open "name" "r"))

then

(type 'a)                   returns  SYM
(type a)                    returns  INT
(type f)                    returns  FILE
(type r)                    returns  REAL
(type s)                    returns  STR
(type x)                    returns  LIST
(type +)                    returns  SUBR
(type nil)                  returns  nil

The following code example uses the type function on the argument passed to it:

(defun isint (a)
   (if (= (type a) 'INT)    is TYPE integer?
     T                      yes, return T 
     nil                    no, return nil 
   )
)