 ; Spr - spreadsheet emulator.
 ; Copyright 1994, 2005 by Rocket Software ltd.
 ; 

 ; Currently processes only the first line of code.
 (defun proco (num dalisa / sub afa str)
  (setq sub (nth num dalisa))
  (setq sub (cddr sub))
  (setq afa (car sub))
  (if (/= afa "") (setq str (eval (read afa))))
 str)

 (DEFUN VAL (tag)
  (setq tag (strcase tag))
  (read (cadr (assoc tag dalisa))))

 (DEFUN VALA (enam / malist entt vall esav)
  (setq esav enam)
  (while (/= "SEQEND" (cdr (assoc 0 (setq entt (entget
                                              (setq enam (entnext enam)))))))
         (setq vall (strcase (cdr (assoc 1 entt))))
         (setq malist (cons vall malist)))
 (append (reverse malist) (list esav)))

 (DEFUN PUT (enam val / malist entt)
  (setq entt (entget (entnext (entnext enam))))
  (entmod (subst (cons 1 val) (assoc 1 entt) entt))
  (entupd enam))

 (DEFUN C:SPR (/ ss num enam dalisa strval)
  (setq ss (ssget "x" (list (cons 2 "dbtag"))))
  (setq num 0)
  (while (setq enam (ssname ss num))
         (setq num (1+ num))
         (setq dalisa (cons (vala enam) dalisa)))
  (setq num 0)
  (while (nth num dalisa)
         (if (setq strval (proco num dalisa))
             (progn
                  (setq enam (last (nth num dalisa)))
                  (cond ((= (type strval) 'INT)
                         (setq strval (itoa strval)))
                        ((= (type strval) 'REAL)
                         (setq strval (rtos strval))))
                  (put enam strval)))
         (setq num (1+ num)))
 (princ))