;;;----------------------str2num.lsp------------------- ;;;converts a string representing a number into a real or integer ;;;---------------------------------------------------- (defun str2num (str / chlst) (cond ((member (type str) '(INT REAL)) str);is a number, so return it ((= (type str) 'STR) (progn (setq chlst (vl-string->list str)) (if (member nil (mapcar (function (lambda (x) (and (/= x 47) (> 58 x 44) ) ) ) chlst ) ) nil ; the string does not represent a number (if (member 46 chlst) ;contains a decimal point (atof str) ;real (atoi str) ;integer );if );if );progn ) ((= (type str) 'SYM) (str2num (eval str)));recurse on evaluated arg (T nil);not a number or a string which represents a number ) );str2num