[cells-devel] c-formula and setf
Frank Goenninger
frgo at me.com
Sun Feb 15 18:40:22 UTC 2009
Hi Bastian,
Am 15.02.2009 um 16:23 schrieb Bastian Müller:
> Hi,
>
> I don't know if that has been discussed yet, but I've several use
> cases
> where I want to do sth. like that: A cell should be calculated by a
> formula if it isn't set to a value. I thought that's possible with
> (c-formula (:inputp t) ... ), which does calculate the slot by a
> formula
> and can be setf, but how is it possible to unset the setf value and
> let
> cells calculate it again?
>
> Example: A textbox is by default calculated by a formula. If the user
> enters sth. into it, that value is used. If the user clears the
> field of
> his input, the value should be calculated again.
>
> Maybe the c-formula ... approach is completely the wrong way or that's
> not possible at all. I've read the documentation and primer but
> couldn't
> find anything helpful. Sorry, I'm new to cells.
>
> Cheers,
> Bastian
Hi Bastian (wow - another Cells user in Germany ;-) - We're three now)
As Kenny and Jakub have suggested one common solution I find myself
using from time to time is:
(defmd frgo ()
(entered-value (c-in nil))
(value (c? (or (^entered-value)
(computed-value)))))
(defun computed-value () ;;; Just making a simple function that fakes
a computed value
'computed)
(defun test-it ()
(let ((self (make-instance 'frgo)))
(format t "~&Entered value: ~s~%" (^entered-value))
(format t "~&Value: ~s~%" (^value))
(setf (^entered-value) 'entered)
(format t "~&Entered value: ~s~%" (^entered-value))
(format t "~&Value: ~s~%" (^value))))
Cheers
Frank
--
Frank Goenninger
Cell: +49 175 4321058
E-Mail: frgo at me.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cells-devel/attachments/20090215/da9348f3/attachment.sig>
More information about the cells-devel
mailing list