;****************************************;
;* This is pl_time.lsp program 		*;
;* Completely compiled on 02/26/99      *;
;* Last Change time 02/26/99		*;
;* ZX Mold Ltd    Xy.Liao		*;
;****************************************;
;********************************* Main function start **********************************;
(defun save_time(/ k		plt_time	ent_btl 	pltpt 		cu_time 
		cyear 		cmonth 		cdat 		cminute 	csec
		counter		btl_sel		save_sel		sel_ent)
;----------------------------------------;
  (setvar "cmdecho" 0)
  (command "undo" "m")
;----------------------------------------;
  (setq os_old (getvar "osmode"))
  (setq la_old (getvar "clayer"))
  (setq pw_old (getvar "plinewid"))
  (setq st_old (getvar "textstyle"))
;---------------------------------------;
(if (not (tblsearch "layer" "mxb"))
;;LCA - COMMENT: The LAYER command has new options.
   (command "_.layer" "_new" "mxb" "_color" "red" "mxb" "_ltype" "continuous" "mxb" "")
;;LCA - COMMENT: The LAYER command has new options.
   (command "_.layer" "thaw" "mxb" "on" "mxb" "unlock" "mxb" "")
 )
  (setvar "clayer" "mxb")
;;LCA - WARNING: The OSMODE sysvar has changed.
  (setvar "osmode" 0)
  (setvar "plinewid" 0)
  (if (not (tblsearch "appid" "time"))
    (regapp "time")
  )
;---------------------------------------;
  (setq cu_time (rtos (getvar "cdate") 2 6))
  (setq cyear (substr cu_time 1 4))
  (setq cmonth (substr cu_time 5 2))
  (setq cdat (substr cu_time 7 2))
  (setq chour (substr cu_time 10 2))
  (setq cminute (substr cu_time 12 2))
  (setq csec (substr cu_time 14 2))
  (setq cu_time (strcat cyear "-" cmonth "-" cdat " " chour ":" cminute ":" csec))
;-----------------------------------------;
  (setq save_sel (ssget "X" '((0 . "INSERT") (2 . "AC_LXY_save*"))))
  (if save_sel
    (command "erase" save_sel "")
  )
  (setq k 0)
  (setq btl_sel (ssget "X" '((0 . "INSERT") (2 . "BTL_BTL"))))
  (if btl_sel
    (progn
      (setq counter (sslength btl_sel))
      (while (< k counter)
	(setq ent_btl (ssname btl_sel k))
        (setq pt0 (cdr (assoc 10 (entget ent_btl))))
	(setq pt1 (polar pt0 (/ pi 2) 64))
	 (setq pt2   (polar pt1  0 8)
	     pt3   (polar pt2 (/ pi 2) 64)
	     pt4   (polar pt3 pi 8)
	     pltpt (polar (polar pt1 (/ pi 2) 1) 0 7)
    )

        (command "pline" pt1 pt2 pt3 pt4 "c")
        (setq sel_ent (ssget "l"))
        (if (not (tblsearch "style" "lxy"))
	  (command "-style" "lxy" "italic" "" 0.65 "" "" "" "")
	  (setvar "textstyle" "lxy")
        )
        (command "text" "j" "bl" pltpt 3 90 (strcat "Last Save: " cu_time))
        (setq sel_ent (ssadd (entlast) sel_ent))

        (mblk (strcat "AC_LXY_save" (itoa (getvar "useri2"))) pt1 sel_ent)
        (setvar "useri2" (+ 1 (getvar "useri2")))
        ;(setq xd (list (list -3 (list "stime" (cons 1000 "stime")))))
       ; (mxdata (entlast) xd)
        (setq k (+ k 1))
      )
    )
  )
  (ac_lxy_set)
  (setvar "cmddia" 1)
  (prin1)
)
;************************************* function end **************************************;