(defun string-to-number (n)
(car (list (read-from-string n))))
(defun degrees-minutes-seconds-to-radians (d m s)
(+ (* (string-to-number d) (/ pi 180))
(* (string-to-number m) (/ pi (* 180 60)))
(* (string-to-number s) (/ pi (* 180 60 60)))
))
;;;(let* ((n 4)
;;; (m (expt 10 n)))
;;;(/ (fround 0.2398476566 (/ 1 m)) m))
;;; Round a flout number to required number of digits
(defun my-round (x digits)
(let* ((n (string-to-number digits))
(m (expt 10 n)))
(/ (fround x (/ 1 m)) m)))
(defun dms ()
(with-ltk ()
(let* ((window (make-instance 'frame))
#-:tk84
;;;; Explanation
(fcriteria (make-instance 'frame :master window))
(criteria (make-instance 'label
:master fcriteria
:width 60
:text "rad = aº * (π / 180) + a' * (π / (180 * 60) + a'' * (π / (180 * 60 * 60))"))
(fdigits (make-instance 'frame :master window))
(before-digits (make-instance 'label
:master fdigits
:text "Округлить до "))
(e-digits (make-instance 'entry
:master fdigits
:width 1))
(after-digits (make-instance 'label
:master fdigits
:text " знаков после запятой"))
;;;; ENTER DATA
(fdms (make-instance 'frame :master window))
(e-degrees (make-instance 'entry
:master fdms
:width 3))
(e-minutes (make-instance 'entry
:master fdms
:width 2))
(e-seconds (make-instance 'entry
:master fdms
:width 2))
(l-d (make-instance 'label
:master fdms
:text "º "))
(l-m (make-instance 'label
:master fdms
:text "' "))
(l-s (make-instance 'label
:master fdms
:text "''"))
(l1 (make-instance 'label
:master fdms
:text " = "))
(l2 (make-instance 'label
:master fdms
:text " rad"))
a
r
rslt
(b1 (make-instance 'button
:master window
:text "Run"
:command (lambda ()
(setf
a (degrees-minutes-seconds-to-radians
(text e-degrees)
(text e-minutes)
(text e-seconds)))
(setf r (my-round a (text e-digits)))
(setf (text rslt) r)))))
(setf rslt (make-instance 'label :master fdms :text 0))
(pack window)
(pack fcriteria)
(pack criteria)
(pack fdigits)
(pack before-digits :side :left)
(pack e-digits :side :left)
(pack after-digits :side :left)
(pack fdms)
(pack e-degrees :side :left)
(pack l-d :side :left)
(pack e-minutes :side :left)
(pack l-m :side :left)
(pack e-seconds :side :left)
(pack l-s :side :left)
(pack l1 :side :left)
(pack rslt :side :left)
(pack l2 :side :left)
(pack b1))))
результат будет иметь d0 в конце результата, как это убрать?