This example sets up a dialog in the CLIM window
stream
that displays the current month, date, hour, and minute (as obtained by a call to
get-universal-time
) and allows the user to modify those values. The user can select values to change by using the mouse to select values, typing in new values, and pressing
RETURN
. When done, the user selects
<END>
to accept the new values, or
<ABORT>
to terminate without changes.
(defun reset-clock (stream)
(multiple-value-bind (second minute hour day month)
(decode-universal-time
(get-universal-time))
(declare (ignore second))
(format stream "Enter the time~%")
(restart-case
(progn
(clim:accepting-values (stream)
(setq month
(clim:accept 'integer :stream stream
:default month :prompt "Month"))
(terpri stream)
(setq day
(clim:accept 'integer :stream stream
:default day :prompt "Day"))
(terpri stream)
(setq hour
(clim:accept 'integer :stream stream
:default hour :prompt "Hour"))
(terpri stream)
(setq minute
(clim:accept 'integer :stream stream
:default minute :prompt "Minute")))
;; This could be code to reset the time, but instead
;; we're just printing it out
(format t "~%New values: Month: ~D, Day: ~D, Time: ~D:~2,'0D."
month day hour minute))
(abort () (format t "~&Time not set")))))
Note that in CLIM, calls to accept do not automatically insert newlines. If you want to put each query on its own line of the dialog, use terpri between the calls to accept .
Common Lisp Interface Manager 2.0 User's Guide - 7 Aug 2017