Here is an oldie.
;; CAB 10/5/2006
;;
;; Function to return the current osmode setting in the form of a string
;; If (getvar "osmode") = 175
;; (get_osmode) returns "_end,_mid,_cen,_nod,_int,_per"
;; Usage
;; (osnap (getpoint) (get_osmode))
;;
(defun get_osmode (/ cur_mode mode$)
(setq mode$ "")
(if (< 0 (setq cur_mode (getvar "osmode")) 16383)
(mapcar
'(lambda (x)
(if (not (zerop (logand cur_mode (car x))))
(setq mode$ (strcat mode$ (cadr x)))
)
)
'((0 "_non,") (1 "_end,") (2 "_mid,") (4 "_cen,") (8 "_nod,")
(16 "_qua,") (32 "_int,") (64 "_ins,") (128 "_per,") (256 "_tan,")
(512 "_nea,")(1024 "_qui,")(2048 "_app,")(4096 "_ext,")(8192 "_par")
)
)
)
mode$
)