(defun c:dat2 (/ p1 p2 p3 p4 p5 p6 x1 x2 dimsc dimtx txhig txhi txh txsty x y olderr)
  (setq	olderr	*ERROR*
	*error*	ai_abort)
  (setq dimsc (getvar "dimscale"))
  (setq dimtx (getvar "dimtxt")
	txsty (getvar "textstyle"))
  (command "-style" "my" "txt" "" "1" "0" "" "" "")
  (setvar "cmdecho" 0)
  (setq txhig (* dimsc dimtx)
        txhi (/ txhig 1.5)
        txh (* txhi 0.8))
  (setq y (* 3 txhi)
        x (* 8 txhi))
  (setq p1 (getpoint "select target point of the DATUM:"))
  (setq p6 (getpoint p1 "select the direction of the DATUM")
	x1 (car p1)
	x2 (car p6))
  (if (< x1 x2)
    (progn
  	(setq p2 (list (+ (CAR p1) x) (cadr p1)))
  	(setq p3 (list (car p1) (- (cadr p1) y)))
  	(setq p4 (list (+ (car p1) (* 1.2 txhi)) (- (cadr p1) txhi))
              p5 (list (+ (car p1) (* 0.3 txh)) (- (cadr p4) (* 0.4 txh))))
        (command "text" "j" "tl" p5 txhig "0" "DATUM" "")
      )
    (progn
      (setq p2 (list (- (CAR p1) x) (cadr p1)))
      (setq p3 (list (car p1) (- (cadr p1) y)))
      (setq p4 (list (- (car p1) (* 1.2 txhi)) (- (cadr p1) txhi))
            p5 (list (- (car p1) (* 0.3 txh)) (- (cadr p4) (* 0.4 txh))))
      (command "text" "j" "tr" p5 txhig "0" "DATUM" "")
      )
  )
  (command "line" p3 p1 p2 "")
  (command "rectang" p1 p4)
  (setq *error* olderr)
  (setvar "textstyle" txsty)
  (princ)
)