Testing a setq..?

C Witt

Usenet Archive
Joined
Jun 23, 2003
Messages
396
Reaction score
0
This is probably a basic question.. but i can't find the answer.

Is there a way of "testing" a setq variable to find out if it is "text" or a "number"?

TIA.
 
Yes,
(eval var); where var is a variable that has been set
Example:
(setq a "a string"); returns "a string"
(setq b 1.20); returns 1.20 (real)
!a returns "a string", notice the "" around it, this is a string !b returns 1.20, notice no "" around it, this is a real / number Bob
 
(setq test "p")
(= (type test) STR)
nil

Why is this not returning True?
 
here is a function to test what type the item is, hth:

(defun what-type (e / typ)
(setq typ (type e))
(cond
((eq typ 'ENAME) 'Entity-name)
((eq typ 'EXRXSUBR) 'External-ObjectARX-application)
((eq typ 'FILE)
'File-descriptor)
((eq typ 'INT)
'Integer)
((eq typ 'LIST)
'List)
((eq typ 'PAGETB)
'Function-paging-table)
((eq typ 'PICKSET)
'Selection-set)
((eq typ 'REAL)
'Floating-point-number)
((eq typ 'SAFEARRAY)
'Safearray)
((eq typ 'STR)
'String)
((eq typ 'SUBR)
'FAS-or-VLX-file)
((eq typ 'SYM)
'Symbol)
((eq typ 'VARIANT)
'Variant)
((eq typ 'USUBR)
'User-defined-function)
((eq typ 'VLA-object)
'ActiveX-object)))
 
Thank you.

Luis said:
here is a function to test what type the item is, hth:

(defun what-type (e / typ)
(setq typ (type e))
(cond
((eq typ 'ENAME) 'Entity-name)
((eq typ 'EXRXSUBR) 'External-ObjectARX-application)
((eq typ 'FILE)
'File-descriptor)
((eq typ 'INT)
'Integer)
((eq typ 'LIST)
'List)
((eq typ 'PAGETB)
'Function-paging-table)
((eq typ 'PICKSET)
'Selection-set)
((eq typ 'REAL)
'Floating-point-number)
((eq typ 'SAFEARRAY)
'Safearray)
((eq typ 'STR)
'String)
((eq typ 'SUBR)
'FAS-or-VLX-file)
((eq typ 'SYM)
'Symbol)
((eq typ 'VARIANT)
'Variant)
((eq typ 'USUBR)
'User-defined-function)
((eq typ 'VLA-object)
'ActiveX-object)))
 

Latest threads

Back
Top